Software /
code /
prosody
Changeset
757:f77843f31c7d
mod_muc: Add 'nick' to unavailable presence of nick changes. Thanks to Asterix for spotting :)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 29 Jan 2009 20:49:32 +0000 |
parents | 756:2ca5fa47f317 |
children | 758:b1885732e979 |
files | plugins/mod_muc.lua |
diffstat | 1 files changed, 12 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_muc.lua Thu Jan 29 20:46:34 2009 +0000 +++ b/plugins/mod_muc.lua Thu Jan 29 20:49:32 2009 +0000 @@ -95,11 +95,11 @@ 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 @@ 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