aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2014-03-18 15:15:14 -0400
committerdaurnimator <quae@daurnimator.com>2014-03-18 15:15:14 -0400
commit32ef3e0c33ede7676d9bf98919997502723a058e (patch)
treef6ce8ef037a9f3cc7ad45fd138cb17788cd05fcb /plugins/muc
parentf03d450c5a89c50e313f87041036e643e03b9dfa (diff)
downloadprosody-32ef3e0c33ede7676d9bf98919997502723a058e.tar.gz
prosody-32ef3e0c33ede7676d9bf98919997502723a058e.zip
plugins/muc/muc: Rename `handle_invite_to_room` to `handle_mediated_invite`; clean up logic
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/muc.lib.lua12
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;