Comparison

plugins/muc/moderated.lib.lua @ 8859:11176f47a03a

MUC: Add some debug logging for voice requests
author Kim Alvefur <zash@zash.se>
date Fri, 01 Jun 2018 09:56:22 +0200
parent 8858:2096742859c1
child 8860:0bb46a1bb398
comparison
equal deleted inserted replaced
8858:2096742859c1 8859:11176f47a03a
69 local actor = event.stanza.attr.from; 69 local actor = event.stanza.attr.from;
70 local affected_occupant = event.room:get_occupant_by_real_jid(event.fields["muc#jid"]); 70 local affected_occupant = event.room:get_occupant_by_real_jid(event.fields["muc#jid"]);
71 local occupant = event.occupant; 71 local occupant = event.occupant;
72 72
73 if occupant.role ~= "moderator" then 73 if occupant.role ~= "moderator" then
74 module:log("debug", "%s tried to grant voice but wasn't a moderator", jid_resource(occupant.nick));
74 return; 75 return;
75 end 76 end
76 77
77 if not event.fields["muc#request_allow"] then 78 if not event.fields["muc#request_allow"] then
79 module:log("debug", "%s did not grant voice", jid_resource(occupant.nick));
78 return; 80 return;
79 end 81 end
80 82
81 if not affected_occupant then 83 if not affected_occupant then
84 module:log("debug", "%s tried to grant voice to unknown occupant %s", jid_resource(occupant.nick), event.fields["muc#jid"]);
82 return; 85 return;
83 end 86 end
84 87
85 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));
86 return; 90 return;
87 end 91 end
88 92
93 module:log("debug", "%s granted voice to %s", jid_resource(occupant.nick), jid_resource(occupant.jid));
89 event.room:set_role(actor, affected_occupant.nick, "participant", "Voice granted"); 94 event.room:set_role(actor, affected_occupant.nick, "participant", "Voice granted");
90 end); 95 end);
91 96
92 97
93 return { 98 return {