diff options
author | Kim Alvefur <zash@zash.se> | 2022-01-24 23:04:38 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2022-01-24 23:04:38 +0100 |
commit | c8ea4743f264edf739acfcaaeec0193c4250cd3d (patch) | |
tree | 2680e7e895a0bfb13ac755f1a02ba52cac423157 /plugins/mod_pubsub | |
parent | 7e65b1deef086d12cff6a129857a8ba335b4eccf (diff) | |
download | prosody-c8ea4743f264edf739acfcaaeec0193c4250cd3d.tar.gz prosody-c8ea4743f264edf739acfcaaeec0193c4250cd3d.zip |
mod_pubsub: Use the util.xtemplate to render Atom summary
Diffstat (limited to 'plugins/mod_pubsub')
-rw-r--r-- | plugins/mod_pubsub/mod_pubsub.lua | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index f096fd8b..b4e72238 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -4,6 +4,7 @@ local jid_bare = require "util.jid".bare; local usermanager = require "core.usermanager"; local new_id = require "util.id".medium; local storagemanager = require "core.storagemanager"; +local xtemplate = require "util.xtemplate"; local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event"; @@ -136,15 +137,8 @@ end -- Compose a textual representation of Atom payloads module:hook("pubsub-summary/http://www.w3.org/2005/Atom", function (event) local payload = event.payload; - 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 + local template = "{summary|or{{author/name|and{{author/name} posted }}{title}}}"; + local summary = xtemplate.render(template, payload, tostring); return summary; end, -1); |