From 4fecbc0bbf5c912f3b8383d2e396cf7282b9c1a4 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 5 Jul 2009 12:43:25 +0500 Subject: mod_presence: Broadcast presence to resources before contacts --- plugins/mod_presence.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index 68bcb632..9ae068c2 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -62,12 +62,6 @@ end function handle_normal_presence(origin, stanza, core_route_stanza) local roster = origin.roster; - 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); - end - end local node, host = origin.username, origin.host; for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast to all resources if res ~= origin and res.presence then -- to resource @@ -75,6 +69,12 @@ function handle_normal_presence(origin, stanza, core_route_stanza) core_route_stanza(origin, stanza); end end + 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); + end + 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(roster) do -- probe all contacts we are subscribed to -- cgit v1.2.3