aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_pubsub/mod_pubsub.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-07-14 21:34:22 +0200
committerKim Alvefur <zash@zash.se>2018-07-14 21:34:22 +0200
commit1919588f28f6c669193043df6c1c6f1e80f8f707 (patch)
treef1adfe89cf982acdaddd647bc5fb32e5cf8e0934 /plugins/mod_pubsub/mod_pubsub.lua
parentd931d6bfb3ab8d5102de8f7983ff26dd6caec980 (diff)
downloadprosody-1919588f28f6c669193043df6c1c6f1e80f8f707.tar.gz
prosody-1919588f28f6c669193043df6c1c6f1e80f8f707.zip
mod_pubsub: Make generation of notification body into an event to allow extensibility
Diffstat (limited to 'plugins/mod_pubsub/mod_pubsub.lua')
-rw-r--r--plugins/mod_pubsub/mod_pubsub.lua28
1 files changed, 17 insertions, 11 deletions
diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua
index 4aa3af89..5b01d1d1 100644
--- a/plugins/mod_pubsub/mod_pubsub.lua
+++ b/plugins/mod_pubsub/mod_pubsub.lua
@@ -55,17 +55,9 @@ function simple_broadcast(kind, node, jids, item, actor, node_obj)
-- Compose a sensible textual representation of at least Atom payloads
if item and item.tags[1] then
local payload = item.tags[1];
- if payload.attr.xmlns == "http://www.w3.org/2005/Atom" then
- local title = payload:get_child_text("title");
- summary = payload:get_child_text("summary");
- if not summary and title then
- local author = payload:find("author/name#");
- summary = title;
- if author then
- summary = author .. " posted " .. summary;
- end
- end
- end
+ summary = module:fire_event("pubsub-summary/"..payload.attr.xmlns, {
+ kind = kind, node = node, jids = jids, actor = actor, item = item, payload = payload,
+ });
end
for jid, options in pairs(jids) do
@@ -82,6 +74,20 @@ function is_item_stanza(item)
return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item";
end
+module:hook("pubsub-summary/http://www.w3.org/2005/Atom", function (event)
+ local payload = event.item;
+ local title = payload:get_child_text("title");
+ local summary = payload:get_child_text("summary");
+ if not summary and title then
+ local author = payload:find("author/name#");
+ summary = title;
+ if author then
+ summary = author .. " posted " .. summary;
+ end
+ end
+ return summary;
+end);
+
module:hook("iq/host/"..xmlns_pubsub..":pubsub", handle_pubsub_iq);
module:hook("iq/host/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq);