aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_pubsub/mod_pubsub.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-05-21 00:44:37 +0200
committerKim Alvefur <zash@zash.se>2018-05-21 00:44:37 +0200
commit542e4301f6073f045444a3163eb320bf1c70b582 (patch)
tree2fc817112ea5198217f23ed8667d4c728e57e853 /plugins/mod_pubsub/mod_pubsub.lua
parentb993873f730e543de912343090211cb6cb52424b (diff)
downloadprosody-542e4301f6073f045444a3163eb320bf1c70b582.tar.gz
prosody-542e4301f6073f045444a3163eb320bf1c70b582.zip
mod_pubsub: Add support for generation of a plain text <body> from Atom payloads
See https://xmpp.org/extensions/xep-0060.html#impl-body
Diffstat (limited to 'plugins/mod_pubsub/mod_pubsub.lua')
-rw-r--r--plugins/mod_pubsub/mod_pubsub.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua
index 74995a2b..707f2f8e 100644
--- a/plugins/mod_pubsub/mod_pubsub.lua
+++ b/plugins/mod_pubsub/mod_pubsub.lua
@@ -57,6 +57,26 @@ function simple_broadcast(kind, node, jids, item, actor, node_obj)
:tag(kind, { node = node })
:add_child(item);
+ -- Compose a sensible textual representation of at least Atom payloads
+ if node_obj and node_obj.config.include_body and item.tags[1] then
+ local payload = item.tags[1];
+ if payload.attr.xmlns == "http://www.w3.org/2005/Atom" then
+ message:reset();
+ 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
+ if summary then
+ message:body(summary);
+ end
+ end
+ end
+
module:broadcast(jids, message, pairs);
end