Software /
code /
prosody
Comparison
plugins/mod_pep_plus.lua @ 8215:835bb32c36b4
mod_pep_plus: Add item persistency.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 15 Apr 2017 09:35:33 +0100 |
parent | 8214:da8bc600902a |
child | 8218:2c75a5ba58fc |
comparison
equal
deleted
inserted
replaced
8214:da8bc600902a | 8215:835bb32c36b4 |
---|---|
17 | 17 |
18 local services = {}; | 18 local services = {}; |
19 local recipients = {}; | 19 local recipients = {}; |
20 local hash_map = {}; | 20 local hash_map = {}; |
21 | 21 |
22 local archive = module:open_store("pubsub", "archive"); | |
23 | |
22 function module.save() | 24 function module.save() |
23 return { services = services }; | 25 return { services = services }; |
24 end | 26 end |
25 | 27 |
26 function module.restore(data) | 28 function module.restore(data) |
30 local function subscription_presence(user_bare, recipient) | 32 local function subscription_presence(user_bare, recipient) |
31 local recipient_bare = jid_bare(recipient); | 33 local recipient_bare = jid_bare(recipient); |
32 if (recipient_bare == user_bare) then return true; end | 34 if (recipient_bare == user_bare) then return true; end |
33 local username, host = jid_split(user_bare); | 35 local username, host = jid_split(user_bare); |
34 return is_contact_subscribed(username, host, recipient_bare); | 36 return is_contact_subscribed(username, host, recipient_bare); |
37 end | |
38 | |
39 local function simple_itemstore(config, node) | |
40 return lib_pubsub.simple_itemstore(archive, config, node, false); | |
35 end | 41 end |
36 | 42 |
37 local function get_broadcaster(name) | 43 local function get_broadcaster(name) |
38 local function simple_broadcast(kind, node, jids, item) | 44 local function simple_broadcast(kind, node, jids, item) |
39 if item then | 45 if item then |
158 }; | 164 }; |
159 | 165 |
160 autocreate_on_publish = true; | 166 autocreate_on_publish = true; |
161 autocreate_on_subscribe = true; | 167 autocreate_on_subscribe = true; |
162 | 168 |
169 itemstore = simple_itemstore; | |
163 broadcaster = get_broadcaster(name); | 170 broadcaster = get_broadcaster(name); |
164 get_affiliation = function (jid) | 171 get_affiliation = function (jid) |
165 if jid_bare(jid) == name then | 172 if jid_bare(jid) == name then |
166 return "owner"; | 173 return "owner"; |
167 elseif subscription_presence(name, jid) then | 174 elseif subscription_presence(name, jid) then |