Mercurial > prosody-hg
comparison plugins/mod_pep.lua @ 1428:02e97e716675
mod_pep: Added function get_caps_hash_from_presence
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Fri, 26 Jun 2009 23:36:12 +0500 |
| parents | 8187f72b7425 |
| children | 51cfb152cb38 |
comparison
equal
deleted
inserted
replaced
| 1427:3bcab7c71edf | 1428:02e97e716675 |
|---|---|
| 43 for jid, item in pairs(session.roster) do | 43 for jid, item in pairs(session.roster) do |
| 44 if jid and jid ~= "pending" and (item.subscription == 'from' or item.subscription == 'both') then | 44 if jid and jid ~= "pending" and (item.subscription == 'from' or item.subscription == 'both') then |
| 45 stanza.attr.to = jid; | 45 stanza.attr.to = jid; |
| 46 core_route_stanza(session, stanza); | 46 core_route_stanza(session, stanza); |
| 47 end | 47 end |
| 48 end | |
| 49 end | |
| 50 | |
| 51 local function get_caps_hash_from_presence(stanza, current) | |
| 52 if not stanza.attr.type then | |
| 53 for _, child in pairs(stanza.tags) do | |
| 54 if child.name == "c" and child.attr.xmlns == "http://jabber.org/protocol/caps" then | |
| 55 local attr = child.attr; | |
| 56 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 else -- legacy caps | |
| 59 if attr.node and attr.ver then return attr.node.."#"..attr.ver.."#"..(attr.ext or ""), attr.node.."#"..attr.ver; end | |
| 60 end | |
| 61 return; -- bad caps format | |
| 62 end | |
| 63 end | |
| 64 return current; -- no caps, could mean caps optimization, so return current | |
| 48 end | 65 end |
| 49 end | 66 end |
| 50 | 67 |
| 51 module:hook("presence/bare", function(event) | 68 module:hook("presence/bare", function(event) |
| 52 -- inbound presence to bare JID recieved | 69 -- inbound presence to bare JID recieved |
