diff options
author | Waqas Hussain <waqas20@gmail.com> | 2010-06-02 01:54:17 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2010-06-02 01:54:17 +0500 |
commit | b72412126e1df14c79a6aff417c6acc8751f489c (patch) | |
tree | 08da37210ab7fb2531dec6df7d5dc938f68c2c22 /plugins/mod_pep.lua | |
parent | cf668f574f3952ee59d5cefbbd91b4a1d8304f42 (diff) | |
download | prosody-b72412126e1df14c79a6aff417c6acc8751f489c.tar.gz prosody-b72412126e1df14c79a6aff417c6acc8751f489c.zip |
mod_pep: Corrected and optimized handling of non-available presence stanzas.
Diffstat (limited to 'plugins/mod_pep.lua')
-rw-r--r-- | plugins/mod_pep.lua | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua index bc20fc77..31546dff 100644 --- a/plugins/mod_pep.lua +++ b/plugins/mod_pep.lua @@ -117,27 +117,32 @@ module:hook("presence/bare", function(event) -- inbound presence to bare JID recieved local origin, stanza = event.origin, event.stanza; local user = stanza.attr.to or (origin.username..'@'..origin.host); + local t = stanza.attr.type; - if not stanza.attr.to or subscription_presence(user, stanza.attr.from) then - local recipient = stanza.attr.from; - local current = recipients[user] and recipients[user][recipient]; - local hash = get_caps_hash_from_presence(stanza, current); - if current == hash then return; end - if not hash then - if recipients[user] then recipients[user][recipient] = nil; end - else - recipients[user] = recipients[user] or {}; - if hash_map[hash] then - recipients[user][recipient] = hash_map[hash]; - publish_all(user, recipient, origin); + if not t then -- available presence + if not stanza.attr.to or subscription_presence(user, stanza.attr.from) then + local recipient = stanza.attr.from; + local current = recipients[user] and recipients[user][recipient]; + local hash = get_caps_hash_from_presence(stanza, current); + if current == hash then return; end + if not hash then + if recipients[user] then recipients[user][recipient] = nil; end else - recipients[user][recipient] = hash; - origin.send( - st.stanza("iq", {from=stanza.attr.to, to=stanza.attr.from, id="disco", type="get"}) - :query("http://jabber.org/protocol/disco#info") - ); + recipients[user] = recipients[user] or {}; + if hash_map[hash] then + recipients[user][recipient] = hash_map[hash]; + publish_all(user, recipient, origin); + else + recipients[user][recipient] = hash; + origin.send( + st.stanza("iq", {from=stanza.attr.to, to=stanza.attr.from, id="disco", type="get"}) + :query("http://jabber.org/protocol/disco#info") + ); + end end end + elseif t == "unavailable" then + if recipients[user] then recipients[user][stanza.attr.from] = nil; end end end, 10); |