Software /
code /
prosody
Comparison
plugins/mod_presence.lua @ 1474:6947761fd531
mod_presence: Simplified roster iteration
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 05 Jul 2009 12:17:22 +0500 |
parent | 1473:d2211cbb822f |
child | 1475:16c8b1a8f6a7 |
comparison
equal
deleted
inserted
replaced
1473:d2211cbb822f | 1474:6947761fd531 |
---|---|
60 if #user.top_resources == 0 then user.top_resources = nil; end | 60 if #user.top_resources == 0 then user.top_resources = nil; end |
61 end | 61 end |
62 | 62 |
63 function handle_normal_presence(origin, stanza, core_route_stanza) | 63 function handle_normal_presence(origin, stanza, core_route_stanza) |
64 if origin.roster then | 64 if origin.roster then |
65 for jid in pairs(origin.roster) do -- broadcast to all interested contacts | 65 for jid, item in pairs(origin.roster) do -- broadcast to all interested contacts |
66 local subscription = origin.roster[jid].subscription; | 66 if item.subscription == "both" or item.subscription == "from" then |
67 if subscription == "both" or subscription == "from" then | |
68 stanza.attr.to = jid; | 67 stanza.attr.to = jid; |
69 core_route_stanza(origin, stanza); | 68 core_route_stanza(origin, stanza); |
70 end | 69 end |
71 end | 70 end |
72 local node, host = origin.username, origin.host; | 71 local node, host = origin.username, origin.host; |
76 core_route_stanza(origin, stanza); | 75 core_route_stanza(origin, stanza); |
77 end | 76 end |
78 end | 77 end |
79 if stanza.attr.type == nil and not origin.presence then -- initial presence | 78 if stanza.attr.type == nil and not origin.presence then -- initial presence |
80 local probe = st.presence({from = origin.full_jid, type = "probe"}); | 79 local probe = st.presence({from = origin.full_jid, type = "probe"}); |
81 for jid in pairs(origin.roster) do -- probe all contacts we are subscribed to | 80 for jid, item in pairs(origin.roster) do -- probe all contacts we are subscribed to |
82 local subscription = origin.roster[jid].subscription; | 81 if item.subscription == "both" or item.subscription == "to" then |
83 if subscription == "both" or subscription == "to" then | |
84 probe.attr.to = jid; | 82 probe.attr.to = jid; |
85 core_route_stanza(origin, probe); | 83 core_route_stanza(origin, probe); |
86 end | 84 end |
87 end | 85 end |
88 for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast from all available resources | 86 for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast from all available resources |