From 740a38cafe15d76c52aca1dffb8899676fbdc392 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 1 Jun 2018 10:26:18 +0200 Subject: MUC: Handle and return error in role change when granting voice --- plugins/muc/moderated.lib.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'plugins/muc') diff --git a/plugins/muc/moderated.lib.lua b/plugins/muc/moderated.lib.lua index 74ce3db8..6e82c71f 100644 --- a/plugins/muc/moderated.lib.lua +++ b/plugins/muc/moderated.lib.lua @@ -90,8 +90,13 @@ module:hook("muc-voice-response", function(event) return; end - module:log("debug", "%s granted voice to %s", jid_resource(occupant.nick), jid_resource(occupant.jid)); - event.room:set_role(actor, affected_occupant.nick, "participant", "Voice granted"); + module:log("debug", "%s granted voice to %s", jid_resource(event.occupant.nick), jid_resource(occupant.jid)); + local ok, errtype, err = event.room:set_role(actor, affected_occupant.nick, "participant", "Voice granted"); + + if not ok then + module:log("debug", "Error granting voice: %s", err or errtype); + event.origin.send(st.error_reply(event.stanza, errtype, err)); + end end); -- cgit v1.2.3