Software /
code /
prosody
Comparison
plugins/mod_pep_plus.lua @ 8306:202b9951b037
mod_pep_plus: Keep track of nodes, and restore them when later
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 08 Oct 2017 23:59:13 +0200 |
parent | 8305:ec605946e597 |
child | 8307:94860b5733d3 |
comparison
equal
deleted
inserted
replaced
8305:ec605946e597 | 8306:202b9951b037 |
---|---|
20 local recipients = {}; | 20 local recipients = {}; |
21 local hash_map = {}; | 21 local hash_map = {}; |
22 | 22 |
23 local host = module.host; | 23 local host = module.host; |
24 | 24 |
25 local known_nodes_map = module:open_store("pep", "map"); | |
26 local known_nodes = module:open_store("pep"); | |
27 | |
25 function module.save() | 28 function module.save() |
26 return { services = services }; | 29 return { services = services }; |
27 end | 30 end |
28 | 31 |
29 function module.restore(data) | 32 function module.restore(data) |
38 end | 41 end |
39 | 42 |
40 local function simple_itemstore(username) | 43 local function simple_itemstore(username) |
41 return function (config, node) | 44 return function (config, node) |
42 module:log("debug", "new simple_itemstore(%q, %q)", username, node); | 45 module:log("debug", "new simple_itemstore(%q, %q)", username, node); |
46 known_nodes_map:set(username, node, true); | |
43 local archive = module:open_store("pep_"..node, "archive"); | 47 local archive = module:open_store("pep_"..node, "archive"); |
44 return lib_pubsub.simple_itemstore(archive, config, username, node, false); | 48 return lib_pubsub.simple_itemstore(archive, config, username, node, false); |
45 end | 49 end |
46 end | 50 end |
47 | 51 |
184 end | 188 end |
185 end; | 189 end; |
186 | 190 |
187 normalize_jid = jid_bare; | 191 normalize_jid = jid_bare; |
188 }); | 192 }); |
193 local nodes, err = known_nodes:get(username); | |
194 if nodes then | |
195 module:log("debug", "Restoring nodes for user %s", username); | |
196 for node in pairs(nodes) do | |
197 module:log("debug", "Restoring node %q", node); | |
198 service:create(node, true); | |
199 end | |
200 elseif err then | |
201 module:log("error", "Could not restore nodes for %s: %s", username, err); | |
202 else | |
203 module:log("debug", "No known nodes"); | |
204 end | |
189 services[username] = service; | 205 services[username] = service; |
190 module:add_item("pep-service", { service = service, jid = user_bare }); | 206 module:add_item("pep-service", { service = service, jid = user_bare }); |
191 return service; | 207 return service; |
192 end | 208 end |
193 | 209 |