diff options
author | Kim Alvefur <zash@zash.se> | 2022-01-24 23:06:45 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2022-01-24 23:06:45 +0100 |
commit | b0e565598a7e6a8934e2440c3ec7692600f89ab8 (patch) | |
tree | dd716a8e882c863b2d637a18c71d8c75c35ac473 /plugins | |
parent | c8ea4743f264edf739acfcaaeec0193c4250cd3d (diff) | |
download | prosody-b0e565598a7e6a8934e2440c3ec7692600f89ab8.tar.gz prosody-b0e565598a7e6a8934e2440c3ec7692600f89ab8.zip |
mod_pubsub: Allow configuring summary templates
Enables generation of summaries for more than Atom without additional
modules.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_pubsub/mod_pubsub.lua | 17 |
1 files changed, 11 insertions, 6 deletions
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); |