aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_muc.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-02-18 23:30:33 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-02-18 23:30:33 +0500
commitb964df3b328d3b83dc5e466dcb666c40198a19cc (patch)
treee18a23fe2031c0d97b957ad096158cb9e34cda4b /plugins/mod_muc.lua
parent264ed76508ef6a0bf83f28f55e53ff9ae906b7cd (diff)
downloadprosody-b964df3b328d3b83dc5e466dcb666c40198a19cc.tar.gz
prosody-b964df3b328d3b83dc5e466dcb666c40198a19cc.zip
MUC: Various fixes
Diffstat (limited to 'plugins/mod_muc.lua')
-rw-r--r--plugins/mod_muc.lua27
1 files changed, 16 insertions, 11 deletions
diff --git a/plugins/mod_muc.lua b/plugins/mod_muc.lua
index a306c699..7c18b9c4 100644
--- a/plugins/mod_muc.lua
+++ b/plugins/mod_muc.lua
@@ -116,7 +116,7 @@ function set_subject(current_nick, room, subject)
if subject == "" then subject = nil; end
rooms_info:set(room, 'subject', subject);
save_room();
- local msg = st.message({type='groupchat', from=from})
+ local msg = st.message({type='groupchat', from=current_nick})
:tag('subject'):text(subject):up();
broadcast_message_stanza(room, msg, false);
--broadcast_message(current_nick, room, subject or "", nil);
@@ -231,30 +231,35 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc
pr.attr.from = to;
if type == "error" then -- error, kick em out!
if current_nick then
- local data = rooms:get(room, to);
+ local data = rooms:get(room, current_nick);
data.role = 'none';
local pr = st.presence({type='unavailable', from=current_nick}):tag('status'):text('This participant is kicked from the room because he sent an error presence'):up()
- :tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
- :tag("item", {affiliation=data.affiliation, role=data.role}):up();
+ --:tag("x", {xmlns='http://jabber.org/protocol/muc#user'})
+ --:tag("item", {affiliation=data.affiliation, role=data.role}):up();
broadcast_presence_stanza(room, pr);
- --broadcast_presence('unavailable', to, room); -- TODO also add <status>This participant is kicked from the room because he sent an error presence: badformed error stanza</status>
- rooms:remove(room, to);
+ --broadcast_presence('unavailable', current_nick, room); -- TODO also add <status>This participant is kicked from the room because he sent an error presence: badformed error stanza</status>
+ rooms:remove(room, current_nick);
jid_nick:remove(from, room);
end
elseif type == "unavailable" then -- unavailable
if current_nick then
- local data = rooms:get(room, to);
+ local data = rooms:get(room, current_nick);
data.role = 'none';
broadcast_presence_stanza(room, pr);
- --broadcast_presence('unavailable', to, room);
- rooms:remove(room, to);
+ --broadcast_presence('unavailable', current_nick, room);
+ rooms:remove(room, current_nick);
jid_nick:remove(from, room);
end
elseif not type then -- available
if current_nick then
if current_nick == to then -- simple presence
- broadcast_presence_stanza(room, pr);
- -- FIXME check if something was filtered. if it was, then user may be rejoining
+ if #pr == #stanza then
+ broadcast_presence_stanza(room, pr);
+ else -- possible rejoin
+ local pr_ = st.presence({type='unavailable', from=from, to=current_nick}):tag('status'):text('Replaced by new connection');
+ handle_to_occupant(origin, pr_); -- send unavailable
+ handle_to_occupant(origin, pr); -- resend available
+ end
else -- change nick
if rooms:get(room, to) then
origin.send(st.error_reply(stanza, "cancel", "conflict"));