Comparison

plugins/mod_admin_shell.lua @ 13603:6e5124f72e9a

mod_admin_shell: Fix reporting origin module for commands The field `_provided_by` comes from module:provides(), but these items comes from moduel:add_item(), which include the originating module as a 'source' field of the event. However, this is absent when items are retrieved at a later time than the initial event.
author Kim Alvefur <zash@zash.se>
date Wed, 08 Jan 2025 08:11:02 +0100
parent 13598:2cd43975a15c
child 13605:74a8006ee7f6
comparison
equal deleted inserted replaced
13602:5033029130f5 13603:6e5124f72e9a
2541 local host_commands = {}; 2541 local host_commands = {};
2542 2542
2543 local function new_item_handlers(command_host) 2543 local function new_item_handlers(command_host)
2544 local function on_command_added(event) 2544 local function on_command_added(event)
2545 local command = event.item; 2545 local command = event.item;
2546 local mod_name = command._provided_by and ("mod_"..command._provided_by) or "<unknown module>"; 2546 local mod_name = event.source and ("mod_"..event.source.name) or "<unknown module>";
2547 if not schema.validate(command_metadata_schema, command) or type(command.handler) ~= "function" then 2547 if not schema.validate(command_metadata_schema, command) or type(command.handler) ~= "function" then
2548 module:log("warn", "Ignoring command added by %s: missing or invalid data", mod_name); 2548 module:log("warn", "Ignoring command added by %s: missing or invalid data", mod_name);
2549 return; 2549 return;
2550 end 2550 end
2551 2551