Software /
code /
prosody
Comparison
plugins/mod_pubsub/mod_pubsub.lua @ 10434:8f709577fe8e
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 23 Nov 2019 23:12:01 +0100 |
parent | 10070:d7cae7187943 |
child | 10673:1a23a58ac84e |
comparison
equal
deleted
inserted
replaced
10433:7777f25d5266 | 10434:8f709577fe8e |
---|---|
73 | 73 |
74 local id = new_id(); | 74 local id = new_id(); |
75 local msg_type = node_obj and node_obj.config.message_type or "headline"; | 75 local msg_type = node_obj and node_obj.config.message_type or "headline"; |
76 local message = st.message({ from = module.host, type = msg_type, id = id }) | 76 local message = st.message({ from = module.host, type = msg_type, id = id }) |
77 :tag("event", { xmlns = xmlns_pubsub_event }) | 77 :tag("event", { xmlns = xmlns_pubsub_event }) |
78 :tag(kind, { node = node }) | 78 :tag(kind, { node = node }); |
79 | 79 |
80 if item then | 80 if item then |
81 message:add_child(item); | 81 message:add_child(item); |
82 end | 82 end |
83 | 83 |
84 local summary; | 84 local summary; |
85 -- Compose a sensible textual representation of at least Atom payloads | |
86 if item and item.tags[1] then | 85 if item and item.tags[1] then |
87 local payload = item.tags[1]; | 86 local payload = item.tags[1]; |
88 summary = module:fire_event("pubsub-summary/"..payload.attr.xmlns, { | 87 summary = module:fire_event("pubsub-summary/"..payload.attr.xmlns, { |
89 kind = kind, node = node, jids = jids, actor = actor, item = item, payload = payload, | 88 kind = kind, node = node, jids = jids, actor = actor, item = item, payload = payload, |
90 }); | 89 }); |
99 module:send(new_stanza); | 98 module:send(new_stanza); |
100 end | 99 end |
101 end | 100 end |
102 | 101 |
103 local max_max_items = module:get_option_number("pubsub_max_items", 256); | 102 local max_max_items = module:get_option_number("pubsub_max_items", 256); |
104 function check_node_config(node, actor, new_config) -- luacheck: ignore 212/actor 212/node | 103 function check_node_config(node, actor, new_config) -- luacheck: ignore 212/node 212/actor |
105 if (new_config["max_items"] or 1) > max_max_items then | 104 if (new_config["max_items"] or 1) > max_max_items then |
106 return false; | 105 return false; |
107 end | 106 end |
108 if new_config["access_model"] ~= "whitelist" and new_config["access_model"] ~= "open" then | 107 if new_config["access_model"] ~= "whitelist" |
108 and new_config["access_model"] ~= "open" then | |
109 return false; | 109 return false; |
110 end | 110 end |
111 return true; | 111 return true; |
112 end | 112 end |
113 | 113 |
114 function is_item_stanza(item) | 114 function is_item_stanza(item) |
115 return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item"; | 115 return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item"; |
116 end | 116 end |
117 | 117 |
118 -- Compose a textual representation of Atom payloads | |
118 module:hook("pubsub-summary/http://www.w3.org/2005/Atom", function (event) | 119 module:hook("pubsub-summary/http://www.w3.org/2005/Atom", function (event) |
119 local payload = event.payload; | 120 local payload = event.payload; |
120 local title = payload:get_child_text("title"); | 121 local title = payload:get_child_text("title"); |
121 local summary = payload:get_child_text("summary"); | 122 local summary = payload:get_child_text("summary"); |
122 if not summary and title then | 123 if not summary and title then |