# HG changeset patch # User Kim Alvefur # Date 1683458022 -7200 # Node ID 6771acb8e857a216563bc6c72833e871ba3378a8 # Parent 9638ff8b1c815eb3484469ecea463872c489cc1e mod_adhoc: Silence permission errors when listing commands Since throwing a pile of 'access denied', even at debug level, seems akin to calling wolf :) Cutting down on debug noise is also good. Passing a flag instead of using module:could seemed easier here. diff -r 9638ff8b1c81 -r 6771acb8e857 plugins/adhoc/mod_adhoc.lua --- a/plugins/adhoc/mod_adhoc.lua Sun May 07 12:52:31 2023 +0200 +++ b/plugins/adhoc/mod_adhoc.lua Sun May 07 13:13:42 2023 +0200 @@ -14,8 +14,8 @@ module:add_feature(xmlns_cmd); -local function check_permissions(event, node, command) - return (command.permission == "check" and module:may("adhoc:"..node, event)) +local function check_permissions(event, node, command, execute) + return (command.permission == "check" and module:may("adhoc:"..node, event, not execute)) or (command.permission == "local_user" and jid_host(event.stanza.attr.from) == module.host) or (command.permission == "any"); end @@ -62,7 +62,7 @@ local node = stanza.tags[1].attr.node local command = commands[node]; if command then - if not check_permissions(event, node, command) then + if not check_permissions(event, node, command, true) then origin.send(st.error_reply(stanza, "auth", "forbidden", "You don't have permission to execute this command"):up() :add_child(command:cmdtag("canceled") :tag("note", {type="error"}):text("You don't have permission to execute this command")));