aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-01-29 20:49:32 +0000
committerMatthew Wild <mwild1@gmail.com>2009-01-29 20:49:32 +0000
commit7e20825e9c2a220ef0b58d41bb32bea4b3f81a6a (patch)
tree8c02934b6fd42cc9c3170b6fa1012b34e0697d71 /plugins
parentc341e61787f191439dea79636c9a3c16f40a59fa (diff)
downloadprosody-7e20825e9c2a220ef0b58d41bb32bea4b3f81a6a.tar.gz
prosody-7e20825e9c2a220ef0b58d41bb32bea4b3f81a6a.zip
mod_muc: Add 'nick' to unavailable presence of nick changes. Thanks to Asterix for spotting :)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_muc.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/plugins/mod_muc.lua b/plugins/mod_muc.lua
index 0af18142..602fb5bc 100644
--- a/plugins/mod_muc.lua
+++ b/plugins/mod_muc.lua
@@ -95,11 +95,11 @@ function set_subject(current_nick, room, subject)
return true;
end
-function broadcast_presence(type, from, room, code)
+function broadcast_presence(type, from, room, code, newnick)
local data = rooms:get(room, from);
local stanza = st.presence({type=type, from=from})
:tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
- :tag("item", {affiliation=data.affiliation, role=data.role}):up();
+ :tag("item", {affiliation=data.affiliation, role=data.role, nick = newnick}):up();
if code then
stanza:tag("status", {code=code}):up();
end
@@ -163,11 +163,16 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc
origin.send(st.error_reply(stanza, "cancel", "conflict"));
else
local data = rooms:get(room, current_nick);
- broadcast_presence('unavailable', current_nick, room, '303');
- rooms:remove(room, current_nick);
- rooms:set(room, to, data);
- jid_nick:set(from, room, to);
- broadcast_presence(nil, to, room);
+ local to_nick = select(3, jid_split(to));
+ if to_nick then
+ broadcast_presence('unavailable', current_nick, room, '303', to_nick);
+ rooms:remove(room, current_nick);
+ rooms:set(room, to, data);
+ jid_nick:set(from, room, to);
+ broadcast_presence(nil, to, room, nil);
+ else
+ --TODO: malformed-jid
+ end
end
end
else -- enter room