aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2014-03-18 14:56:20 -0400
committerdaurnimator <quae@daurnimator.com>2014-03-18 14:56:20 -0400
commit6f7f21479ad928d2b94d497834592c15260cfcf5 (patch)
tree9b2a0ad9c4b1127b3e279d217897c1b60d12dca1 /plugins/muc
parent0eace14ce404db740379a76011e110e2be8c0662 (diff)
downloadprosody-6f7f21479ad928d2b94d497834592c15260cfcf5.tar.gz
prosody-6f7f21479ad928d2b94d497834592c15260cfcf5.zip
plugins/muc/muc: Check for mediated invites in a smarter way
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/muc.lib.lua18
1 files changed, 11 insertions, 7 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 8daa4b9f..8a8680c5 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -1033,6 +1033,10 @@ end
function room_mt:handle_invite_to_room(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
+ 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];
@@ -1069,13 +1073,13 @@ function room_mt:handle_message_to_room(origin, stanza)
return self:handle_groupchat_to_room(origin, stanza)
elseif type == "error" and is_kickable_error(stanza) then
return self:handle_kickable(origin, stanza)
- elseif not(type == "chat" or type == "error" or type == "groupchat" or type == "headline") and #stanza.tags == 1
- and self._jid_nick[stanza.attr.from] and stanza.tags[1].name == "x" and stanza.tags[1].attr.xmlns == "http://jabber.org/protocol/muc#user" then
- local x = stanza.tags[1];
- local payload = (#x.tags == 1 and x.tags[1]);
- if payload and payload.name == "invite" and payload.attr.to then
- return self:handle_invite_to_room(origin, stanza, payload)
- else
+ elseif type == nil then
+ 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)
+ end
origin.send(st.error_reply(stanza, "cancel", "bad-request"));
return true;
end