aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-10-18 15:28:00 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-10-18 15:28:00 +0500
commitb9fbde5ff7709983de80c6b8fec98416768676d3 (patch)
tree4802950f79aa310b98f0a8e77cb4d7a9b573ab19 /plugins
parentb6af612f7cd2ba2518240c6c50432cc2faa8a84f (diff)
downloadprosody-b9fbde5ff7709983de80c6b8fec98416768676d3.tar.gz
prosody-b9fbde5ff7709983de80c6b8fec98416768676d3.zip
MUC: Rewrote code for mediated invites to be more robust, and to support legacy clients.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/muc/muc.lib.lua36
1 files changed, 27 insertions, 9 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 176d244c..4b923386 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -539,15 +539,33 @@ function room_mt:handle_to_room(origin, stanza) -- presence changes and groupcha
origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
end
elseif stanza.name == "message" and not stanza.attr.type 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" and #stanza.tags[1].tags == 1
- and stanza.tags[1].tags[1].name == "invite" and stanza.tags[1].tags[1].attr.to then
- local _from, _to = stanza.attr.from, stanza.attr.to;
- local _invitee = stanza.tags[1].tags[1].attr.to;
- stanza.attr.from, stanza.attr.to = _to, _invitee;
- stanza.tags[1].tags[1].attr.from, stanza.tags[1].tags[1].attr.to = _from, nil;
- self:route_stanza(stanza);
- stanza.tags[1].tags[1].attr.from, stanza.tags[1].tags[1].attr.to = nil, _invitee;
- stanza.attr.from, stanza.attr.to = _from, _to;
+ 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
+ local _from, _to = stanza.attr.from, stanza.attr.to;
+ 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 invite = st.message({from = _to, to = _invitee, id = stanza.attr.id})
+ :tag('x', {xmlns='http://jabber.org/protocol/muc#user'})
+ :tag('invite', {from=_from})
+ :tag('reason'):text(_reason or ""):up()
+ :up()
+ :up()
+ :tag('x', {xmlns="jabber:x:conference", jid=_to}) -- COMPAT: Some older clients expect this
+ :text(_reason or "")
+ :up()
+ :tag('body') -- Add a plain message for clients which don't support invites
+ :text(_from..' invited you to the room '.._to..(_reason and (' ('.._reason..')') or ""))
+ :up();
+ self:route_stanza(invite);
+ else
+ origin.send(st.error_reply(stanza, "cancel", "jid-malformed"));
+ end
+ else
+ origin.send(st.error_reply(stanza, "cancel", "bad-request"));
+ end
else
if type == "error" or type == "result" then return; end
origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));