MUC: Fixed: Presence for user joining the roomi was sent twice to the user
[prosody.git] / plugins / mod_muc.lua
index 36ea04771244f7cf0cc1339e80c843d637cc831c..a306c6997f0aa8e67fd8f76900da89839a6afb58 100644 (file)
@@ -298,7 +298,7 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc
                                        local r = rooms:get(room);
                                        if r then
                                                for occupant, o_data in pairs(r) do
-                                                       if occupant ~= from then
+                                                       if occupant ~= to then
                                                                local pres = get_filtered_presence(o_data.sessions[o_data.jid]);
                                                                pres.attr.to, pres.attr.from = from, occupant;
                                                                pres
@@ -345,7 +345,9 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc
        else -- private stanza
                local o_data = rooms:get(room, to);
                if o_data then
-                       stanza.attr.to, stanza.attr.from = o_data.jid, current_nick;
+                       local jid = o_data.jid;
+                       if stanza.name=='iq' and type=='get' and stanza.tags[1].attr.xmlns == 'vcard-temp' then jid = jid_bare(jid); end
+                       stanza.attr.to, stanza.attr.from = jid, current_nick;
                        core_route_stanza(component, stanza);
                else -- recipient not in room
                        origin.send(st.error_reply(stanza, "cancel", "item-not-found", "Recipient not in room"));