# HG changeset patch # User Waqas Hussain # Date 1246778715 -18000 # Node ID 16c8b1a8f6a7aa1b509085cbe6617cf632d4944e # Parent 6947761fd531a0c39eac4256fba9dac925aeb782 mod_presence: Changed handle_normal_presence to use a local roster rather than origin's roster diff -r 6947761fd531 -r 16c8b1a8f6a7 plugins/mod_presence.lua --- a/plugins/mod_presence.lua Sun Jul 05 12:17:22 2009 +0500 +++ b/plugins/mod_presence.lua Sun Jul 05 12:25:15 2009 +0500 @@ -61,8 +61,9 @@ end function handle_normal_presence(origin, stanza, core_route_stanza) - if origin.roster then - for jid, item in pairs(origin.roster) do -- broadcast to all interested contacts + local roster = origin.roster; + if roster then + for jid, item in pairs(roster) do -- broadcast to all interested contacts if item.subscription == "both" or item.subscription == "from" then stanza.attr.to = jid; core_route_stanza(origin, stanza); @@ -77,7 +78,7 @@ end if stanza.attr.type == nil and not origin.presence then -- initial presence local probe = st.presence({from = origin.full_jid, type = "probe"}); - for jid, item in pairs(origin.roster) do -- probe all contacts we are subscribed to + for jid, item in pairs(roster) do -- probe all contacts we are subscribed to if item.subscription == "both" or item.subscription == "to" then probe.attr.to = jid; core_route_stanza(origin, probe); @@ -90,13 +91,13 @@ res.presence.attr.to = nil; end end - if origin.roster.pending then -- resend incoming subscription requests - for jid in pairs(origin.roster.pending) do + 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 end local request = st.presence({type="subscribe", from=origin.username.."@"..origin.host}); - for jid, item in pairs(origin.roster) do -- resend outgoing subscription requests + for jid, item in pairs(roster) do -- resend outgoing subscription requests if item.ask then request.attr.to = jid; core_route_stanza(origin, request);