Mercurial > prosody-hg
comparison plugins/mod_presence.lua @ 1477:e0411d6c9bae
mod_presence: Broadcast presence to resources before contacts
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 05 Jul 2009 12:43:25 +0500 |
| parents | 5d6199a9b4f6 |
| children | eef17ebe3ca1 |
comparison
equal
deleted
inserted
replaced
| 1476:5d6199a9b4f6 | 1477:e0411d6c9bae |
|---|---|
| 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 local roster = origin.roster; | 64 local roster = origin.roster; |
| 65 for jid, item in pairs(roster) do -- broadcast to all interested contacts | |
| 66 if item.subscription == "both" or item.subscription == "from" then | |
| 67 stanza.attr.to = jid; | |
| 68 core_route_stanza(origin, stanza); | |
| 69 end | |
| 70 end | |
| 71 local node, host = origin.username, origin.host; | 65 local node, host = origin.username, origin.host; |
| 72 for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast to all resources | 66 for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast to all resources |
| 73 if res ~= origin and res.presence then -- to resource | 67 if res ~= origin and res.presence then -- to resource |
| 74 stanza.attr.to = res.full_jid; | 68 stanza.attr.to = res.full_jid; |
| 69 core_route_stanza(origin, stanza); | |
| 70 end | |
| 71 end | |
| 72 for jid, item in pairs(roster) do -- broadcast to all interested contacts | |
| 73 if item.subscription == "both" or item.subscription == "from" then | |
| 74 stanza.attr.to = jid; | |
| 75 core_route_stanza(origin, stanza); | 75 core_route_stanza(origin, stanza); |
| 76 end | 76 end |
| 77 end | 77 end |
| 78 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 |
| 79 local probe = st.presence({from = origin.full_jid, type = "probe"}); | 79 local probe = st.presence({from = origin.full_jid, type = "probe"}); |
