Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 6198:8936b9fbedfd
plugins/muc/muc.lib: restrict invitations in members only rooms to admins
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Mon, 31 Mar 2014 14:45:42 -0400 |
parent | 6197:1ee4d8953544 |
child | 6199:fa858cd913b1 |
comparison
equal
deleted
inserted
replaced
6197:1ee4d8953544 | 6198:8936b9fbedfd |
---|---|
1202 event.origin.send(st.error_reply(stanza, "auth", "forbidden")); | 1202 event.origin.send(st.error_reply(stanza, "auth", "forbidden")); |
1203 return true; | 1203 return true; |
1204 end | 1204 end |
1205 end); | 1205 end); |
1206 | 1206 |
1207 -- Invitation privileges in members-only rooms SHOULD be restricted to room admins; | |
1208 -- if a member without privileges to edit the member list attempts to invite another user | |
1209 -- the service SHOULD return a <forbidden/> error to the occupant | |
1210 module:hook("muc-pre-invite", function(event) | |
1211 local room, stanza = event.room, event.stanza; | |
1212 if room:get_members_only() and valid_affiliations[room:get_affiliation(stanza.attr.from) or "none"] < valid_affiliations.admin then | |
1213 event.origin.send(st.error_reply(stanza, "auth", "forbidden")); | |
1214 return true; | |
1215 end | |
1216 end); | |
1217 | |
1207 function room_mt:handle_mediated_invite(origin, stanza) | 1218 function room_mt:handle_mediated_invite(origin, stanza) |
1208 local payload = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("invite"); | 1219 local payload = stanza:get_child("x", "http://jabber.org/protocol/muc#user"):get_child("invite"); |
1209 local invitee = jid_prep(payload.attr.to); | 1220 local invitee = jid_prep(payload.attr.to); |
1210 if not invitee then | 1221 if not invitee then |
1211 origin.send(st.error_reply(stanza, "cancel", "jid-malformed")); | 1222 origin.send(st.error_reply(stanza, "cancel", "jid-malformed")); |