Comparison

plugins/mod_pubsub/mod_pubsub.lua @ 8213:e1272aeef31c

mod_pubsub: Add item persistence using mod_storage_*’s archive store.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 15 Apr 2017 01:21:55 +0100 (2017-04-15)
parent 8210:352d605b1178
child 8218:2c75a5ba58fc
comparison
equal deleted inserted replaced
8212:66173e4b355a 8213:e1272aeef31c
18 local handlers = lib_pubsub.handlers; 18 local handlers = lib_pubsub.handlers;
19 19
20 module:depends("disco"); 20 module:depends("disco");
21 module:add_identity("pubsub", "service", pubsub_disco_name); 21 module:add_identity("pubsub", "service", pubsub_disco_name);
22 module:add_feature("http://jabber.org/protocol/pubsub"); 22 module:add_feature("http://jabber.org/protocol/pubsub");
23
24 local archive = module:open_store("pubsub", "archive");
23 25
24 function handle_pubsub_iq(event) 26 function handle_pubsub_iq(event)
25 local origin, stanza = event.origin, event.stanza; 27 local origin, stanza = event.origin, event.stanza;
26 local pubsub_tag = stanza.tags[1]; 28 local pubsub_tag = stanza.tags[1];
27 local action = pubsub_tag.tags[1]; 29 local action = pubsub_tag.tags[1];
32 local handler = handlers[stanza.attr.type.."_"..action.name]; 34 local handler = handlers[stanza.attr.type.."_"..action.name];
33 if handler then 35 if handler then
34 handler(origin, stanza, action, service); 36 handler(origin, stanza, action, service);
35 return true; 37 return true;
36 end 38 end
39 end
40
41 local function simple_itemstore(config, node)
42 return lib_pubsub.simple_itemstore(archive, config, node, expose_publisher);
37 end 43 end
38 44
39 function simple_broadcast(kind, node, jids, item, actor) 45 function simple_broadcast(kind, node, jids, item, actor)
40 if item then 46 if item then
41 item = st.clone(item); 47 item = st.clone(item);
222 }; 228 };
223 229
224 autocreate_on_publish = autocreate_on_publish; 230 autocreate_on_publish = autocreate_on_publish;
225 autocreate_on_subscribe = autocreate_on_subscribe; 231 autocreate_on_subscribe = autocreate_on_subscribe;
226 232
233 itemstore = simple_itemstore;
227 broadcaster = simple_broadcast; 234 broadcaster = simple_broadcast;
228 get_affiliation = get_affiliation; 235 get_affiliation = get_affiliation;
229 236
230 normalize_jid = jid_bare; 237 normalize_jid = jid_bare;
231 })); 238 }));