--- a/plugins/mod_presence.lua Sun Jul 05 12:40:18 2009 +0500
+++ b/plugins/mod_presence.lua Sun Jul 05 12:43:25 2009 +0500
@@ -62,12 +62,6 @@
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 @@
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