Software /
code /
prosody
Comparison
plugins/mod_pubsub/pubsub.lib.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 | 8400:518b56d806bd |
child | 8815:5974c9da1391 |
comparison
equal
deleted
inserted
replaced
8813:2c55fccb0c0c | 8814:07197f29e2b8 |
---|---|
50 { | 50 { |
51 type = "boolean"; | 51 type = "boolean"; |
52 name = "pubsub#persist_items"; | 52 name = "pubsub#persist_items"; |
53 label = "Persist items to storage"; | 53 label = "Persist items to storage"; |
54 }; | 54 }; |
55 { | |
56 type = "list-single"; | |
57 name = "pubsub#notification_type"; | |
58 label = "Specify the delivery style for notifications"; | |
59 options = { | |
60 { label = "Messages of type normal", value = "normal" }, | |
61 { label = "Messages of type headline", value = "headline", default = true }, | |
62 }; | |
55 }; | 63 }; |
56 | 64 |
57 local service_method_feature_map = { | 65 local service_method_feature_map = { |
58 add_subscription = { "subscribe" }; | 66 add_subscription = { "subscribe" }; |
59 create = { "create-nodes", "instant-nodes", "item-ids", "create-and-configure" }; | 67 create = { "create-nodes", "instant-nodes", "item-ids", "create-and-configure" }; |
185 return true; | 193 return true; |
186 end | 194 end |
187 config = { | 195 config = { |
188 ["max_items"] = tonumber(form_data["pubsub#max_items"]); | 196 ["max_items"] = tonumber(form_data["pubsub#max_items"]); |
189 ["persist_items"] = form_data["pubsub#persist_items"]; | 197 ["persist_items"] = form_data["pubsub#persist_items"]; |
198 ["notification_type"] = form_data["pubsub#notification_type"]; | |
190 }; | 199 }; |
191 end | 200 end |
192 if node then | 201 if node then |
193 ok, ret = service:create(node, stanza.attr.from, config); | 202 ok, ret = service:create(node, stanza.attr.from, config); |
194 if ok then | 203 if ok then |
371 end | 380 end |
372 | 381 |
373 local node_config = node_obj.config; | 382 local node_config = node_obj.config; |
374 local pubsub_form_data = { | 383 local pubsub_form_data = { |
375 ["pubsub#max_items"] = tostring(node_config["max_items"]); | 384 ["pubsub#max_items"] = tostring(node_config["max_items"]); |
376 ["pubsub#persist_items"] = node_config["persist_items"] | 385 ["pubsub#persist_items"] = node_config["persist_items"]; |
386 ["pubsub#notification_type"] = node_config["notification_type"]; | |
377 } | 387 } |
378 local reply = st.reply(stanza) | 388 local reply = st.reply(stanza) |
379 :tag("pubsub", { xmlns = xmlns_pubsub_owner }) | 389 :tag("pubsub", { xmlns = xmlns_pubsub_owner }) |
380 :tag("configure", { node = node }) | 390 :tag("configure", { node = node }) |
381 :add_child(node_config_form:form(pubsub_form_data)); | 391 :add_child(node_config_form:form(pubsub_form_data)); |