# HG changeset patch # User Kim Alvefur # Date 1527841578 -7200 # Node ID 0bb46a1bb3986fb653446128adcb5797a3557dce # Parent 11176f47a03a66fcb3416784fb90057a7dfcac5d MUC: Handle and return error in role change when granting voice diff -r 11176f47a03a -r 0bb46a1bb398 plugins/muc/moderated.lib.lua --- a/plugins/muc/moderated.lib.lua Fri Jun 01 09:56:22 2018 +0200 +++ b/plugins/muc/moderated.lib.lua Fri Jun 01 10:26:18 2018 +0200 @@ -90,8 +90,13 @@ 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);