From b0e565598a7e6a8934e2440c3ec7692600f89ab8 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 24 Jan 2022 23:06:45 +0100 Subject: mod_pubsub: Allow configuring summary templates Enables generation of summaries for more than Atom without additional modules. --- plugins/mod_pubsub/mod_pubsub.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'plugins') diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index b4e72238..db615035 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -135,12 +135,17 @@ function is_item_stanza(item) 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 template = "{summary|or{{author/name|and{{author/name} posted }}{title}}}"; - local summary = xtemplate.render(template, payload, tostring); - return summary; -end, -1); +local summary_templates = module:get_option("pubsub_summary_templates", { + ["http://www.w3.org/2005/Atom"] = "{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; + return xtemplate.render(template, payload, tostring); + end, -1); +end + module:hook("iq/host/"..xmlns_pubsub..":pubsub", handle_pubsub_iq); module:hook("iq/host/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq); -- cgit v1.2.3