Mercurial > prosody-hg
comparison plugins/mod_presence.lua @ 6291:7a604381d6fc
mod_presence: Move presence/initial event to correct place so it actually fires
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 03 Jul 2014 11:54:50 +0200 |
| parents | 8dc01fa767e0 |
| children | 76699a0ae4c4 |
comparison
equal
deleted
inserted
replaced
| 6289:a29cc79295e6 | 6291:7a604381d6fc |
|---|---|
| 88 stanza.attr.to = jid; | 88 stanza.attr.to = jid; |
| 89 core_post_stanza(origin, stanza, true); | 89 core_post_stanza(origin, stanza, true); |
| 90 end | 90 end |
| 91 end | 91 end |
| 92 if stanza.attr.type == nil and not origin.presence then -- initial presence | 92 if stanza.attr.type == nil and not origin.presence then -- initial presence |
| 93 module:fire_event("presence/initial", { origin = origin, stanza = stanza } ); | |
| 93 origin.presence = stanza; -- FIXME repeated later | 94 origin.presence = stanza; -- FIXME repeated later |
| 94 local probe = st.presence({from = origin.full_jid, type = "probe"}); | 95 local probe = st.presence({from = origin.full_jid, type = "probe"}); |
| 95 for jid, item in pairs(roster) do -- probe all contacts we are subscribed to | 96 for jid, item in pairs(roster) do -- probe all contacts we are subscribed to |
| 96 if item.subscription == "both" or item.subscription == "to" then | 97 if item.subscription == "both" or item.subscription == "to" then |
| 97 probe.attr.to = jid; | 98 probe.attr.to = jid; |
| 135 core_post_stanza(origin, stanza, true); | 136 core_post_stanza(origin, stanza, true); |
| 136 end | 137 end |
| 137 origin.directed = nil; | 138 origin.directed = nil; |
| 138 end | 139 end |
| 139 else | 140 else |
| 140 if not origin.presence then | |
| 141 module:fire_event("presence/initial", { origin = origin, stanza = stanza } ); | |
| 142 end | |
| 143 origin.presence = stanza; | 141 origin.presence = stanza; |
| 144 stanza:tag("delay", { xmlns = "urn:xmpp:delay", from = host, stamp = datetime.datetime() }):up(); | 142 stanza:tag("delay", { xmlns = "urn:xmpp:delay", from = host, stamp = datetime.datetime() }):up(); |
| 145 if origin.priority ~= priority then | 143 if origin.priority ~= priority then |
| 146 origin.priority = priority; | 144 origin.priority = priority; |
| 147 recalc_resource_map(user); | 145 recalc_resource_map(user); |
