16 local iterators = require "util.iterators"; |
16 local iterators = require "util.iterators"; |
17 local jid_split = require "util.jid".split; |
17 local jid_split = require "util.jid".split; |
18 local jid_bare = require "util.jid".bare; |
18 local jid_bare = require "util.jid".bare; |
19 local jid_prep = require "util.jid".prep; |
19 local jid_prep = require "util.jid".prep; |
20 local jid_join = require "util.jid".join; |
20 local jid_join = require "util.jid".join; |
|
21 local jid_resource = require "util.jid".resource; |
21 local st = require "util.stanza"; |
22 local st = require "util.stanza"; |
22 local base64 = require "util.encodings".base64; |
23 local base64 = require "util.encodings".base64; |
23 local md5 = require "util.hashes".md5; |
24 local md5 = require "util.hashes".md5; |
24 |
25 |
25 local log = module._log; |
26 local log = module._log; |
240 |
241 |
241 local whois = self:get_whois(); |
242 local whois = self:get_whois(); |
242 |
243 |
243 local actor_nick; |
244 local actor_nick; |
244 if actor then |
245 if actor then |
245 actor_nick = select(3, jid_split(self:get_occupant_jid(actor))); |
246 actor_nick = jid_resource(self:get_occupant_jid(actor)); |
246 end |
247 end |
247 |
248 |
248 local full_p, full_x; |
249 local full_p, full_x; |
249 local function get_full_p() |
250 local function get_full_p() |
250 if full_p == nil then |
251 if full_p == nil then |
561 orig_occupant:set_session(real_jid, stanza); |
562 orig_occupant:set_session(real_jid, stanza); |
562 else |
563 else |
563 log("debug", "session %s is changing from occupant %s to %s", real_jid, orig_occupant.nick, dest_occupant.nick); |
564 log("debug", "session %s is changing from occupant %s to %s", real_jid, orig_occupant.nick, dest_occupant.nick); |
564 local generated_unavail = st.presence {from = orig_occupant.nick, to = real_jid, type = "unavailable"}; |
565 local generated_unavail = st.presence {from = orig_occupant.nick, to = real_jid, type = "unavailable"}; |
565 orig_occupant:set_session(real_jid, generated_unavail); |
566 orig_occupant:set_session(real_jid, generated_unavail); |
566 dest_nick = select(3, jid_split(dest_occupant.nick)); |
567 dest_nick = jid_resource(dest_occupant.nick); |
567 if not is_first_dest_session then -- User is swapping into another pre-existing session |
568 if not is_first_dest_session then -- User is swapping into another pre-existing session |
568 log("debug", "session %s is swapping into multisession %s, showing it leave.", real_jid, dest_occupant.nick); |
569 log("debug", "session %s is swapping into multisession %s, showing it leave.", real_jid, dest_occupant.nick); |
569 -- Show the other session leaving |
570 -- Show the other session leaving |
570 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";}); |
571 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";}); |
571 add_item(x, self:get_affiliation(bare_jid), "none"); |
572 add_item(x, self:get_affiliation(bare_jid), "none"); |
916 if not item.attr.jid and item.attr.nick then -- COMPAT Workaround for Miranda sending 'nick' instead of 'jid' when changing affiliation |
917 if not item.attr.jid and item.attr.nick then -- COMPAT Workaround for Miranda sending 'nick' instead of 'jid' when changing affiliation |
917 local occupant = self:get_occupant_by_nick(self.jid.."/"..item.attr.nick); |
918 local occupant = self:get_occupant_by_nick(self.jid.."/"..item.attr.nick); |
918 if occupant then item.attr.jid = occupant.jid; end |
919 if occupant then item.attr.jid = occupant.jid; end |
919 elseif not item.attr.nick and item.attr.jid then |
920 elseif not item.attr.nick and item.attr.jid then |
920 local nick = self:get_occupant_jid(item.attr.jid); |
921 local nick = self:get_occupant_jid(item.attr.jid); |
921 if nick then item.attr.nick = select(3, jid_split(nick)); end |
922 if nick then item.attr.nick = jid_resource(nick); end |
922 end |
923 end |
923 local actor = stanza.attr.from; |
924 local actor = stanza.attr.from; |
924 local reason = item:get_child_text("reason"); |
925 local reason = item:get_child_text("reason"); |
925 local success, errtype, err |
926 local success, errtype, err |
926 if item.attr.affiliation and item.attr.jid and not item.attr.role then |
927 if item.attr.affiliation and item.attr.jid and not item.attr.role then |
968 if _rol == "none" then _rol = nil; end |
969 if _rol == "none" then _rol = nil; end |
969 local reply = st.reply(stanza):query("http://jabber.org/protocol/muc#admin"); |
970 local reply = st.reply(stanza):query("http://jabber.org/protocol/muc#admin"); |
970 -- TODO: whois check here? (though fully anonymous rooms are not supported) |
971 -- TODO: whois check here? (though fully anonymous rooms are not supported) |
971 for occupant_jid, occupant in self:each_occupant() do |
972 for occupant_jid, occupant in self:each_occupant() do |
972 if occupant.role == _rol then |
973 if occupant.role == _rol then |
973 local nick = select(3,jid_split(occupant_jid)); |
974 local nick = jid_resource(occupant_jid); |
974 self:build_item_list(occupant, reply, false, nick); |
975 self:build_item_list(occupant, reply, false, nick); |
975 end |
976 end |
976 end |
977 end |
977 origin.send(reply:up()); |
978 origin.send(reply:up()); |
978 return true; |
979 return true; |