Software /
code /
prosody
Comparison
plugins/mod_pep.lua @ 1429:51cfb152cb38
mod_pep: Ignore presence subscriptions when extractng hash information
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 26 Jun 2009 23:42:59 +0500 |
parent | 1428:02e97e716675 |
child | 1430:39169cf8d36f |
comparison
equal
deleted
inserted
replaced
1428:02e97e716675 | 1429:51cfb152cb38 |
---|---|
47 end | 47 end |
48 end | 48 end |
49 end | 49 end |
50 | 50 |
51 local function get_caps_hash_from_presence(stanza, current) | 51 local function get_caps_hash_from_presence(stanza, current) |
52 if not stanza.attr.type then | 52 local t = stanza.attr.type; |
53 if not t then | |
53 for _, child in pairs(stanza.tags) do | 54 for _, child in pairs(stanza.tags) do |
54 if child.name == "c" and child.attr.xmlns == "http://jabber.org/protocol/caps" then | 55 if child.name == "c" and child.attr.xmlns == "http://jabber.org/protocol/caps" then |
55 local attr = child.attr; | 56 local attr = child.attr; |
56 if attr.hash then -- new caps | 57 if attr.hash then -- new caps |
57 if attr.hash == 'sha-1' and attr.node and attr.ver then return attr.ver, attr.node.."#"..attr.ver; end | 58 if attr.hash == 'sha-1' and attr.node and attr.ver then return attr.ver, attr.node.."#"..attr.ver; end |
59 if attr.node and attr.ver then return attr.node.."#"..attr.ver.."#"..(attr.ext or ""), attr.node.."#"..attr.ver; end | 60 if attr.node and attr.ver then return attr.node.."#"..attr.ver.."#"..(attr.ext or ""), attr.node.."#"..attr.ver; end |
60 end | 61 end |
61 return; -- bad caps format | 62 return; -- bad caps format |
62 end | 63 end |
63 end | 64 end |
64 return current; -- no caps, could mean caps optimization, so return current | 65 elseif t == "unavailable" or t == "error" then |
66 return; | |
65 end | 67 end |
68 return current; -- no caps, could mean caps optimization, so return current | |
66 end | 69 end |
67 | 70 |
68 module:hook("presence/bare", function(event) | 71 module:hook("presence/bare", function(event) |
69 -- inbound presence to bare JID recieved | 72 -- inbound presence to bare JID recieved |
70 local origin, stanza = event.origin, event.stanza; | 73 local origin, stanza = event.origin, event.stanza; |