Mercurial > prosody-hg
comparison plugins/mod_admin_adhoc.lua @ 13528:c228f1ffb7b3 0.12
mod_admin_adhoc: Fix log messages for reloading modules.
Also rename for loop item so that it doesn't shadow module variable.
| author | Aidan Epstein <aidan@jmad.org> |
|---|---|
| date | Sun, 29 Sep 2024 18:09:17 -0700 |
| parents | ffff0d8a9c68 |
| children | 3ec7222349ac |
comparison
equal
deleted
inserted
replaced
| 13519:0b6af170617b | 13528:c228f1ffb7b3 |
|---|---|
| 528 end, function(fields, err, data) | 528 end, function(fields, err, data) |
| 529 if err then | 529 if err then |
| 530 return generate_error_message(err); | 530 return generate_error_message(err); |
| 531 end | 531 end |
| 532 local ok_list, err_list = {}, {}; | 532 local ok_list, err_list = {}, {}; |
| 533 for _, module in ipairs(fields.modules) do | 533 for _, module_ in ipairs(fields.modules) do |
| 534 local ok, err = modulemanager.reload(module_host, module); | 534 local ok, err = modulemanager.reload(module_host, module_); |
| 535 if ok then | 535 if ok then |
| 536 ok_list[#ok_list + 1] = module; | 536 ok_list[#ok_list + 1] = module_; |
| 537 else | 537 else |
| 538 err_list[#err_list + 1] = module .. "(Error: " .. tostring(err) .. ")"; | 538 err_list[#err_list + 1] = module_ .. "(Error: " .. tostring(err) .. ")"; |
| 539 end | 539 end |
| 540 end | 540 module:log("info", "mod_%s reloaded by %s", module_, jid.bare(data.from)); |
| 541 module:log("info", "mod_%s reloaded by %s", fields.module, jid.bare(data.from)); | 541 end |
| 542 local info = (#ok_list > 0 and ("The following modules were successfully reloaded on host "..module_host..":\n"..t_concat(ok_list, "\n")) or "") | 542 local info = (#ok_list > 0 and ("The following modules were successfully reloaded on host "..module_host..":\n"..t_concat(ok_list, "\n")) or "") |
| 543 .. ((#ok_list > 0 and #err_list > 0) and "\n" or "") .. | 543 .. ((#ok_list > 0 and #err_list > 0) and "\n" or "") .. |
| 544 (#err_list > 0 and ("Failed to reload the following modules on host "..module_host..":\n"..t_concat(err_list, "\n")) or ""); | 544 (#err_list > 0 and ("Failed to reload the following modules on host "..module_host..":\n"..t_concat(err_list, "\n")) or ""); |
| 545 return { status = "completed", info = info }; | 545 return { status = "completed", info = info }; |
| 546 end); | 546 end); |
| 678 end, function(fields, err, data) | 678 end, function(fields, err, data) |
| 679 if err then | 679 if err then |
| 680 return generate_error_message(err); | 680 return generate_error_message(err); |
| 681 end | 681 end |
| 682 local ok_list, err_list = {}, {}; | 682 local ok_list, err_list = {}, {}; |
| 683 for _, module in ipairs(fields.modules) do | 683 for _, module_ in ipairs(fields.modules) do |
| 684 local ok, err = modulemanager.unload(module_host, module); | 684 local ok, err = modulemanager.unload(module_host, module_); |
| 685 if ok then | 685 if ok then |
| 686 ok_list[#ok_list + 1] = module; | 686 ok_list[#ok_list + 1] = module_; |
| 687 else | 687 else |
| 688 err_list[#err_list + 1] = module .. "(Error: " .. tostring(err) .. ")"; | 688 err_list[#err_list + 1] = module_ .. "(Error: " .. tostring(err) .. ")"; |
| 689 end | 689 end |
| 690 end | 690 module:log("info", "mod_%s unloaded by %s", module_, jid.bare(data.from)); |
| 691 module:log("info", "mod_%s unloaded by %s", fields.module, jid.bare(data.from)); | 691 end |
| 692 local info = (#ok_list > 0 and ("The following modules were successfully unloaded on host "..module_host..":\n"..t_concat(ok_list, "\n")) or "") | 692 local info = (#ok_list > 0 and ("The following modules were successfully unloaded on host "..module_host..":\n"..t_concat(ok_list, "\n")) or "") |
| 693 .. ((#ok_list > 0 and #err_list > 0) and "\n" or "") .. | 693 .. ((#ok_list > 0 and #err_list > 0) and "\n" or "") .. |
| 694 (#err_list > 0 and ("Failed to unload the following modules on host "..module_host..":\n"..t_concat(err_list, "\n")) or ""); | 694 (#err_list > 0 and ("Failed to unload the following modules on host "..module_host..":\n"..t_concat(err_list, "\n")) or ""); |
| 695 return { status = "completed", info = info }; | 695 return { status = "completed", info = info }; |
| 696 end); | 696 end); |
