Mercurial > prosody-hg
comparison plugins/mod_pep.lua @ 1487:66f18c18befa
Merge with main branch.
| author | Tobias Markmann <tm@ayena.de> |
|---|---|
| date | Sun, 05 Jul 2009 19:05:25 +0200 |
| parents | 51f0202b0868 |
| children | 569d58d21612 |
comparison
equal
deleted
inserted
replaced
| 1486:3e04efa8af7e | 1487:66f18c18befa |
|---|---|
| 52 end | 52 end |
| 53 local function publish_all(user, recipient, session) | 53 local function publish_all(user, recipient, session) |
| 54 local d = data[user]; | 54 local d = data[user]; |
| 55 local notify = recipients[user] and recipients[user][recipient]; | 55 local notify = recipients[user] and recipients[user][recipient]; |
| 56 if d and notify then | 56 if d and notify then |
| 57 for node, message in pairs(notify) do | 57 for node in pairs(notify) do |
| 58 if d[node] then | 58 local message = d[node]; |
| 59 if message then | |
| 59 message.attr.to = recipient; | 60 message.attr.to = recipient; |
| 60 session.send(message); | 61 session.send(message); |
| 61 end | 62 end |
| 62 end | 63 end |
| 63 end | 64 end |
| 99 if recipients[user] then recipients[user][recipient] = nil; end | 100 if recipients[user] then recipients[user][recipient] = nil; end |
| 100 else | 101 else |
| 101 recipients[user] = recipients[user] or {}; | 102 recipients[user] = recipients[user] or {}; |
| 102 if hash_map[hash] then | 103 if hash_map[hash] then |
| 103 recipients[user][recipient] = hash_map[hash]; | 104 recipients[user][recipient] = hash_map[hash]; |
| 104 publish_all(user, recipient); | 105 publish_all(user, recipient, origin); |
| 105 else | 106 else |
| 106 recipients[user][recipient] = hash; | 107 recipients[user][recipient] = hash; |
| 107 origin.send( | 108 origin.send( |
| 108 st.stanza("iq", {from=stanza.attr.to, to=stanza.attr.from, id="disco", type="get"}) | 109 st.stanza("iq", {from=stanza.attr.to, to=stanza.attr.from, id="disco", type="get"}) |
| 109 :query("http://jabber.org/protocol/disco#info") | 110 :query("http://jabber.org/protocol/disco#info") |
| 190 ver = calculate_hash(disco.tags); -- calculate hash | 191 ver = calculate_hash(disco.tags); -- calculate hash |
| 191 end | 192 end |
| 192 local notify = {}; | 193 local notify = {}; |
| 193 for _, feature in pairs(disco.tags) do | 194 for _, feature in pairs(disco.tags) do |
| 194 if feature.name == "feature" and feature.attr.var then | 195 if feature.name == "feature" and feature.attr.var then |
| 195 local nfeature = feature.attr.var:match("^(.*)+notify$"); | 196 local nfeature = feature.attr.var:match("^(.*)%+notify$"); |
| 196 if nfeature then notify[nfeature] = true; end | 197 if nfeature then notify[nfeature] = true; end |
| 197 end | 198 end |
| 198 end | 199 end |
| 199 hash_map[ver] = notify; -- update hash map | 200 hash_map[ver] = notify; -- update hash map |
| 200 recipients[user][contact] = notify; -- set recipient's data to calculated data | 201 recipients[user][contact] = notify; -- set recipient's data to calculated data |
