aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2014-03-18 15:15:28 -0400
committerdaurnimator <quae@daurnimator.com>2014-03-18 15:15:28 -0400
commit5a0baa1d2f9dc13a5fce3013b2c8a68d7e0d1b83 (patch)
treef2aa550d6b5b4f940a85e520976ce43d308dc4b2 /plugins/muc
parent32ef3e0c33ede7676d9bf98919997502723a058e (diff)
downloadprosody-5a0baa1d2f9dc13a5fce3013b2c8a68d7e0d1b83.tar.gz
prosody-5a0baa1d2f9dc13a5fce3013b2c8a68d7e0d1b83.zip
plugins/muc/muc: Support mediated declines
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/muc.lib.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 9b54fd2b..0c87574a 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -1067,6 +1067,29 @@ function room_mt:handle_mediated_invite(origin, stanza, payload)
end
end
+function room_mt:handle_mediated_decline(origin, stanza, payload)
+ local declinee = jid_prep(payload.attr.to);
+ if declinee then
+ local from, to = stanza.attr.from, stanza.attr.to;
+ -- TODO: Validate declinee
+ local reason = payload:get_child_text("reason")
+ local decline = st.message({from = to, to = declinee, id = stanza.attr.id})
+ :tag('x', {xmlns='http://jabber.org/protocol/muc#user'})
+ :tag('decline', {from=from})
+ :tag('reason'):text(reason or ""):up()
+ :up()
+ :up()
+ :tag('body') -- Add a plain message for clients which don't support declines
+ :text(from..' declined your invite to the room '..to..(reason and (' ('..reason..')') or ""))
+ :up();
+ self:_route_stanza(decline);
+ return true;
+ else
+ origin.send(st.error_reply(stanza, "cancel", "jid-malformed"));
+ return true;
+ end
+end
+
function room_mt:handle_message_to_room(origin, stanza)
local type = stanza.attr.type;
if type == "groupchat" then
@@ -1081,6 +1104,8 @@ function room_mt:handle_message_to_room(origin, stanza)
-- fallthrough
elseif payload.name == "invite" and payload.attr.to then
return self:handle_mediated_invite(origin, stanza, payload)
+ elseif payload.name == "decline" and payload.attr.to then
+ return self:handle_mediated_decline(origin, stanza, payload)
end
origin.send(st.error_reply(stanza, "cancel", "bad-request"));
return true;