diff options
author | daurnimator <quae@daurnimator.com> | 2014-03-18 15:15:14 -0400 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2014-03-18 15:15:14 -0400 |
commit | a37f0e8d2a4f0e37be89ad46eaf5b4a3223776d3 (patch) | |
tree | f6ce8ef037a9f3cc7ad45fd138cb17788cd05fcb /plugins/muc/muc.lib.lua | |
parent | 6f7f21479ad928d2b94d497834592c15260cfcf5 (diff) | |
download | prosody-a37f0e8d2a4f0e37be89ad46eaf5b4a3223776d3.tar.gz prosody-a37f0e8d2a4f0e37be89ad46eaf5b4a3223776d3.zip |
plugins/muc/muc: Rename `handle_invite_to_room` to `handle_mediated_invite`; clean up logic
Diffstat (limited to 'plugins/muc/muc.lib.lua')
-rw-r--r-- | plugins/muc/muc.lib.lua | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 8a8680c5..9b54fd2b 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -1031,15 +1031,15 @@ function room_mt:handle_presence_to_room(origin, stanza) return handled; end -function room_mt:handle_invite_to_room(origin, stanza, payload) +function room_mt:handle_mediated_invite(origin, stanza, payload) local _from, _to = stanza.attr.from, stanza.attr.to; - if not self._jid_nick[_from] then -- Should be in room to send invite + if not self._jid_nick[_from] then -- Should be in room to send invite TODO: allow admins to send at any time origin.send(st.error_reply(stanza, "auth", "forbidden")); return true; end local _invitee = jid_prep(payload.attr.to); if _invitee then - local _reason = payload.tags[1] and payload.tags[1].name == 'reason' and #payload.tags[1].tags == 0 and payload.tags[1][1]; + local _reason = payload:get_child_text("reason") local invite = st.message({from = _to, to = _invitee, id = stanza.attr.id}) :tag('x', {xmlns='http://jabber.org/protocol/muc#user'}) :tag('invite', {from=_from}) @@ -1077,8 +1077,10 @@ function room_mt:handle_message_to_room(origin, stanza) local x = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); if x then local payload = x.tags[1]; - if payload and payload.name == "invite" and payload.attr.to then - return self:handle_invite_to_room(origin, stanza, payload) + if payload == nil then + -- fallthrough + elseif payload.name == "invite" and payload.attr.to then + return self:handle_mediated_invite(origin, stanza, payload) end origin.send(st.error_reply(stanza, "cancel", "bad-request")); return true; |