Software /
code /
prosody
Changeset
13339:c94989c557cd
mod_pubsub: Provide some node properties in summary template #1809
Gives some access to node details which are otherwise hard to determine
if you only see the plain text summary, since it is shared based on the
pubsub#type setting (or payload xmlns).
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 22 Nov 2023 22:35:44 +0100 |
parents | 13338:470ab6b55e93 |
children | 13340:92b7ccc76c3a |
files | plugins/mod_pubsub/mod_pubsub.lua |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_pubsub/mod_pubsub.lua Tue Nov 21 22:18:42 2023 +0100 +++ b/plugins/mod_pubsub/mod_pubsub.lua Wed Nov 22 22:35:44 2023 +0100 @@ -139,12 +139,22 @@ -- Compose a textual representation of Atom payloads local summary_templates = module:get_option("pubsub_summary_templates", { - ["http://www.w3.org/2005/Atom"] = "{summary|or{{author/name|and{{author/name} posted }}{title}}}"; + ["http://www.w3.org/2005/Atom"] = "{@pubsub:title|and{*{@pubsub:title}*\n\n}}{summary|or{{author/name|and{{author/name} posted }}{title}}}"; }) for pubsub_type, template in pairs(summary_templates) do module:hook("pubsub-summary/"..pubsub_type, function (event) local payload = event.payload; + + local got_config, node_config = service:get_node_config(event.node, true); + if got_config then + payload = st.clone(payload); + payload.attr["xmlns:pubsub"] = xmlns_pubsub; + payload.attr["pubsub:node"] = event.node; + payload.attr["pubsub:title"] = node_config.title; + payload.attr["pubsub:description"] = node_config.description; + end + return xtemplate.render(template, payload, tostring); end, -1); end