# HG changeset patch # User Kim Alvefur # Date 1643062005 -3600 # Node ID 33a93d0a9a4537756d3c3b0976ce3659ba7b6ab4 # Parent 82cf9d3ffeeef7985727004b2b04b63adf54b049 mod_pubsub: Allow configuring summary templates Enables generation of summaries for more than Atom without additional modules. diff -r 82cf9d3ffeee -r 33a93d0a9a45 plugins/mod_pubsub/mod_pubsub.lua --- a/plugins/mod_pubsub/mod_pubsub.lua Mon Jan 24 23:04:38 2022 +0100 +++ b/plugins/mod_pubsub/mod_pubsub.lua Mon Jan 24 23:06:45 2022 +0100 @@ -135,12 +135,17 @@ 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);