diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-06-26 23:36:12 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-06-26 23:36:12 +0500 |
commit | e9438b7d04e3f5b82f7d027050fdd1f7a29ab476 (patch) | |
tree | bc9e1d762084e3517881feea1997e9bdba17f139 /plugins/mod_pep.lua | |
parent | 4a056707a57739093ebad4bd523797435157e07c (diff) | |
download | prosody-e9438b7d04e3f5b82f7d027050fdd1f7a29ab476.tar.gz prosody-e9438b7d04e3f5b82f7d027050fdd1f7a29ab476.zip |
mod_pep: Added function get_caps_hash_from_presence
Diffstat (limited to 'plugins/mod_pep.lua')
-rw-r--r-- | plugins/mod_pep.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua index e4a1767b..95c18eec 100644 --- a/plugins/mod_pep.lua +++ b/plugins/mod_pep.lua @@ -48,6 +48,23 @@ local function publish(session, node, item) end end +local function get_caps_hash_from_presence(stanza, current) + if not stanza.attr.type then + for _, child in pairs(stanza.tags) do + if child.name == "c" and child.attr.xmlns == "http://jabber.org/protocol/caps" then + local attr = child.attr; + if attr.hash then -- new caps + if attr.hash == 'sha-1' and attr.node and attr.ver then return attr.ver, attr.node.."#"..attr.ver; end + else -- legacy caps + if attr.node and attr.ver then return attr.node.."#"..attr.ver.."#"..(attr.ext or ""), attr.node.."#"..attr.ver; end + end + return; -- bad caps format + end + end + return current; -- no caps, could mean caps optimization, so return current + end +end + module:hook("presence/bare", function(event) -- inbound presence to bare JID recieved local origin, stanza = event.origin, event.stanza; |