Mercurial > prosody-modules
comparison mod_pep_atom_categories/mod_pep_atom_categories.lua @ 4836:5fc306239db3
mod_pep_atom_categories: Add a module to index categories in Atom entries
A new node is created for each category, named category-<the category>, which
contains a list of all node/item tuples having said category as a tag.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 25 Dec 2021 15:35:17 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4835:60b2dbe032c0 | 4836:5fc306239db3 |
---|---|
1 module:depends("pep"); | |
2 | |
3 local st = require"util.stanza"; | |
4 | |
5 local options = { | |
6 access_model = "open", | |
7 max_items = "max", | |
8 }; | |
9 | |
10 module:handle_items("pep-service", function (event) | |
11 local service = event.item.service; | |
12 | |
13 module:hook_object_event(service.events, "item-published", function(event) | |
14 local service = event.service; | |
15 local node = event.node; | |
16 local actor = event.actor; | |
17 local id = event.id; | |
18 local item = event.item; | |
19 | |
20 local entry = item:get_child("entry", "http://www.w3.org/2005/Atom"); | |
21 if entry == nil then | |
22 return; | |
23 end | |
24 | |
25 for category in entry:childtags("category") do | |
26 local term = category.attr.term; | |
27 local payload = st.stanza("item", {xmlns = "http://jabber.org/protocol/pubsub"}) | |
28 :tag("item", {xmlns = "xmpp:linkmauve.fr/x-categories", jid = service.jid, node = node, id = id}); | |
29 service:publish("category-"..term, actor, nil, payload, options); | |
30 end | |
31 end); | |
32 end); |