# HG changeset patch # User Waqas Hussain # Date 1246041372 -18000 # Node ID 02e97e71667568927cb1962ff514838390df07e0 # Parent 3bcab7c71edf6795570449cf3fd7086454fac8c3 mod_pep: Added function get_caps_hash_from_presence diff -r 3bcab7c71edf -r 02e97e716675 plugins/mod_pep.lua --- a/plugins/mod_pep.lua Fri Jun 26 21:51:32 2009 +0500 +++ b/plugins/mod_pep.lua Fri Jun 26 23:36:12 2009 +0500 @@ -48,6 +48,23 @@ 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;