diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-06-28 21:49:31 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-06-28 21:49:31 +0500 |
commit | 1192a5719e5805cf65245323c3436568e6e8ff74 (patch) | |
tree | 2418328a31911f21ade274057e24613fdcf55909 /plugins/mod_pep.lua | |
parent | e0b4f8cb2133898d410a0f376f2a918b05fe5afb (diff) | |
download | prosody-1192a5719e5805cf65245323c3436568e6e8ff74.tar.gz prosody-1192a5719e5805cf65245323c3436568e6e8ff74.zip |
mod_pep: Use cached caps
Diffstat (limited to 'plugins/mod_pep.lua')
-rw-r--r-- | plugins/mod_pep.lua | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua index 3d0b6ad8..78098423 100644 --- a/plugins/mod_pep.lua +++ b/plugins/mod_pep.lua @@ -48,6 +48,18 @@ local function publish(session, node, item) end end end +local function publish_all(user, recipient, session) + local d = data[user]; + local notify = recipients[user] and recipients[user][recipient]; + if d and notify then + for node, message in pairs(notify) do + if d[node] then + message.attr.to = recipient; + session.send(message); + end + end + end +end local function get_caps_hash_from_presence(stanza, current) local t = stanza.attr.type; @@ -85,11 +97,16 @@ module:hook("presence/bare", function(event) if recipients[user] then recipients[user][recipient] = nil; end else recipients[user] = recipients[user] or {}; - 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") - ); + if hash_map[hash] then + recipients[user][recipient] = hash_map[hash]; + publish_all(user, recipient); + 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 end, 10); @@ -180,15 +197,7 @@ module:hook("iq/bare/disco", function(event) hash_map[ver] = notify; -- update hash map recipients[user][contact] = notify; -- set recipient's data to calculated data -- send messages to recipient - local d = data[user]; - if d then - for node, message in pairs(notify) do - if d[node] then - message.attr.to = stanza.attr.from; - session.send(message); - end - end - end + publish_all(user, contact, session); end end end); |