Mercurial > prosody-hg
comparison plugins/muc/moderated.lib.lua @ 8860:0bb46a1bb398
MUC: Handle and return error in role change when granting voice
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 01 Jun 2018 10:26:18 +0200 |
| parents | 11176f47a03a |
| children | 2a8bbfcb6868 |
comparison
equal
deleted
inserted
replaced
| 8859:11176f47a03a | 8860:0bb46a1bb398 |
|---|---|
| 88 if affected_occupant.role ~= "visitor" then | 88 if affected_occupant.role ~= "visitor" then |
| 89 module:log("debug", "%s tried to grant voice to %s but they already have it", jid_resource(occupant.nick), jid_resource(occupant.jid)); | 89 module:log("debug", "%s tried to grant voice to %s but they already have it", jid_resource(occupant.nick), jid_resource(occupant.jid)); |
| 90 return; | 90 return; |
| 91 end | 91 end |
| 92 | 92 |
| 93 module:log("debug", "%s granted voice to %s", jid_resource(occupant.nick), jid_resource(occupant.jid)); | 93 module:log("debug", "%s granted voice to %s", jid_resource(event.occupant.nick), jid_resource(occupant.jid)); |
| 94 event.room:set_role(actor, affected_occupant.nick, "participant", "Voice granted"); | 94 local ok, errtype, err = event.room:set_role(actor, affected_occupant.nick, "participant", "Voice granted"); |
| 95 | |
| 96 if not ok then | |
| 97 module:log("debug", "Error granting voice: %s", err or errtype); | |
| 98 event.origin.send(st.error_reply(event.stanza, errtype, err)); | |
| 99 end | |
| 95 end); | 100 end); |
| 96 | 101 |
| 97 | 102 |
| 98 return { | 103 return { |
| 99 get = get_moderated; | 104 get = get_moderated; |
