mod_blocklist: Restructure how we keep track of where to send unavailable presence
[prosody.git] / plugins / mod_presence.lua
index 2577573c4d4b26f2b985016b14b79ea1785fc436..ab57a15811ca1e28a208eb026b2a1fdf46fd24a2 100644 (file)
@@ -55,14 +55,14 @@ local ignore_presence_priority = module:get_option("ignore_presence_priority");
 
 function handle_normal_presence(origin, stanza)
        if ignore_presence_priority then
-               local priority = stanza:child_with_name("priority");
+               local priority = stanza:get_child("priority");
                if priority and priority[1] ~= "0" then
                        for i=#priority.tags,1,-1 do priority.tags[i] = nil; end
                        for i=#priority,1,-1 do priority[i] = nil; end
                        priority[1] = "0";
                end
        end
-       local priority = stanza:child_with_name("priority");
+       local priority = stanza:get_child("priority");
        if priority and #priority > 0 then
                priority = t_concat(priority);
                if s_find(priority, "^[+-]?[0-9]+$") then
@@ -106,10 +106,8 @@ function handle_normal_presence(origin, stanza)
                                res.presence.attr.to = nil;
                        end
                end
-               if roster.pending then -- resend incoming subscription requests
-                       for jid in pairs(roster.pending) do
-                               origin.send(st.presence({type="subscribe", from=jid})); -- TODO add to attribute? Use original?
-                       end
+               for jid in pairs(roster[false].pending) do -- resend incoming subscription requests
+                       origin.send(st.presence({type="subscribe", from=jid})); -- TODO add to attribute? Use original?
                end
                local request = st.presence({type="subscribe", from=origin.username.."@"..origin.host});
                for jid, item in pairs(roster) do -- resend outgoing subscription requests