Comparison

plugins/muc/muc.lib.lua @ 6216:50b8b7caf200

plugins/muc/muc.lib: Move occupancy check to later in `deconstruct_stanza_id`: As vcards are from the bare jid, you need to use the `from_jid` out of the encoded `id`
author daurnimator <quae@daurnimator.com>
date Thu, 03 Apr 2014 16:04:04 -0400
parent 6215:1dd09dc04945
child 6217:657c707d9229
comparison
equal deleted inserted replaced
6215:1dd09dc04945 6216:50b8b7caf200
620 620
621 function room_mt:handle_iq_to_occupant(origin, stanza) 621 function room_mt:handle_iq_to_occupant(origin, stanza)
622 local from, to = stanza.attr.from, stanza.attr.to; 622 local from, to = stanza.attr.from, stanza.attr.to;
623 local type = stanza.attr.type; 623 local type = stanza.attr.type;
624 local id = stanza.attr.id; 624 local id = stanza.attr.id;
625 local current_nick = self:get_occupant_jid(from);
626 local occupant = self:get_occupant_by_nick(to); 625 local occupant = self:get_occupant_by_nick(to);
627 if (type == "error" or type == "result") then 626 if (type == "error" or type == "result") then
628 do -- deconstruct_stanza_id 627 do -- deconstruct_stanza_id
629 if not current_nick or not occupant then return nil; end 628 if not occupant then return nil; end
630 local from_jid, id, to_jid_hash = (base64.decode(stanza.attr.id) or ""):match("^(.+)%z(.*)%z(.+)$"); 629 local from_jid, id, to_jid_hash = (base64.decode(stanza.attr.id) or ""):match("^(.+)%z(.*)%z(.+)$");
631 if not(from == from_jid or from == jid_bare(from_jid)) then return nil; end 630 if not(from == from_jid or from == jid_bare(from_jid)) then return nil; end
631 local from_occupant_jid = self:get_occupant_jid(from_jid);
632 if from_occupant_jid == nil then return nil; end
632 local session_jid 633 local session_jid
633 for to_jid in occupant:each_session() do 634 for to_jid in occupant:each_session() do
634 if md5(to_jid) == to_jid_hash then 635 if md5(to_jid) == to_jid_hash then
635 session_jid = to_jid; 636 session_jid = to_jid;
636 break; 637 break;
637 end 638 end
638 end 639 end
639 if session_jid == nil then return nil; end 640 if session_jid == nil then return nil; end
640 stanza.attr.from, stanza.attr.to, stanza.attr.id = current_nick, session_jid, id 641 stanza.attr.from, stanza.attr.to, stanza.attr.id = from_jid, session_jid, id;
641 end 642 end
642 log("debug", "%s sent private iq stanza to %s (%s)", from, to, stanza.attr.to); 643 log("debug", "%s sent private iq stanza to %s (%s)", from, to, stanza.attr.to);
643 self:route_stanza(stanza); 644 self:route_stanza(stanza);
644 stanza.attr.from, stanza.attr.to, stanza.attr.id = from, to, id; 645 stanza.attr.from, stanza.attr.to, stanza.attr.id = from, to, id;
645 return true; 646 return true;
646 else -- Type is "get" or "set" 647 else -- Type is "get" or "set"
648 local current_nick = self:get_occupant_jid(from);
647 if not current_nick then 649 if not current_nick then
648 origin.send(st.error_reply(stanza, "cancel", "not-acceptable")); 650 origin.send(st.error_reply(stanza, "cancel", "not-acceptable"));
649 return true; 651 return true;
650 end 652 end
651 if not occupant then -- recipient not in room 653 if not occupant then -- recipient not in room