Merge with trunk
[prosody.git] / plugins / mod_muc.lua
index 35900f606f8324790707df0db08897b46f0be79d..a7b8db5fae46778d4d8dfba3d76e36cea5397a9a 100644 (file)
@@ -260,7 +260,7 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc
                        end
                elseif not type then -- available
                        if current_nick then
-                               if #pr == #stanza or current_nick ~= to then
+                               --if #pr == #stanza or current_nick ~= to then -- commented because google keeps resending directed presence
                                        if current_nick == to then -- simple presence
                                                log("debug", "%s broadcasted presence", current_nick);
                                                rooms:get(room, current_nick).sessions[from] = pr;
@@ -287,11 +287,11 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc
                                                        end
                                                end
                                        end
-                               else -- possible rejoin
-                                       log("debug", "%s had connection replaced", current_nick);
-                                       handle_to_occupant(origin, st.presence({type='unavailable', from=from, to=to}):tag('status'):text('Replaced by new connection'):up()); -- send unavailable
-                                       handle_to_occupant(origin, stanza); -- resend available
-                               end
+                               --else -- possible rejoin
+                               --      log("debug", "%s had connection replaced", current_nick);
+                               --      handle_to_occupant(origin, st.presence({type='unavailable', from=from, to=to}):tag('status'):text('Replaced by new connection'):up()); -- send unavailable
+                               --      handle_to_occupant(origin, stanza); -- resend available
+                               --end
                        else -- enter room
                                local new_nick = to;
                                if rooms:get(room, to) then
@@ -321,7 +321,7 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc
                elseif type ~= 'result' then -- bad type
                        origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error?
                end
-       elseif not current_nick and type ~= "error" then -- not in room
+       elseif not current_nick and type ~= "error" and type ~= "result" then -- not in room
                origin.send(st.error_reply(stanza, "cancel", "not-acceptable"));
        elseif stanza.name == "message" and type == "groupchat" then -- groupchat messages not allowed in PM
                origin.send(st.error_reply(stanza, "modify", "bad-request"));
@@ -333,7 +333,7 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc
                if o_data then
                        log("debug", "%s sent private stanza to %s (%s)", from, to, o_data.jid);
                        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
+                       -- TODO 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);
                elseif type ~= "error" and type ~= "result" then -- recipient not in room