Software /
code /
prosody
Comparison
plugins/mod_pubsub/mod_pubsub.lua @ 8814:07197f29e2b8
mod_pubsub: Make the 'type' attribute on broadcast messages configurable
This adds support for the pubsub#notification_type field in the node
config form.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 21 May 2018 00:35:45 +0200 |
parent | 8811:f2d35eee69c9 |
child | 8815:5974c9da1391 |
comparison
equal
deleted
inserted
replaced
8813:2c55fccb0c0c | 8814:07197f29e2b8 |
---|---|
39 else | 39 else |
40 create_simple_itemstore = nil; | 40 create_simple_itemstore = nil; |
41 end | 41 end |
42 | 42 |
43 | 43 |
44 function simple_broadcast(kind, node, jids, item, actor) | 44 function simple_broadcast(kind, node, jids, item, actor, node_obj) |
45 if item then | 45 if item then |
46 item = st.clone(item); | 46 item = st.clone(item); |
47 item.attr.xmlns = nil; -- Clear the pubsub namespace | 47 item.attr.xmlns = nil; -- Clear the pubsub namespace |
48 if expose_publisher and actor then | 48 if expose_publisher and actor then |
49 item.attr.publisher = actor | 49 item.attr.publisher = actor |
50 end | 50 end |
51 end | 51 end |
52 | 52 |
53 local id = new_id(); | 53 local id = new_id(); |
54 local message = st.message({ from = module.host, type = "headline", id = id }) | 54 local msg_type = node_obj and node_obj.config.message_type or "headline"; |
55 local message = st.message({ from = module.host, type = msg_type, id = id }) | |
55 :tag("event", { xmlns = xmlns_pubsub_event }) | 56 :tag("event", { xmlns = xmlns_pubsub_event }) |
56 :tag(kind, { node = node }) | 57 :tag(kind, { node = node }) |
57 :add_child(item); | 58 :add_child(item); |
59 | |
58 module:broadcast(jids, message, pairs); | 60 module:broadcast(jids, message, pairs); |
59 end | 61 end |
60 | 62 |
61 function is_item_stanza(item) | 63 function is_item_stanza(item) |
62 return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item"; | 64 return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item"; |