Mercurial > prosody-hg
comparison plugins/mod_pubsub/mod_pubsub.lua @ 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 | 50324f66ca2a |
| children | e9ab660b9c5f |
comparison
equal
deleted
inserted
replaced
| 13338:470ab6b55e93 | 13339:c94989c557cd |
|---|---|
| 137 return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item" and #item.tags == 1; | 137 return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item" and #item.tags == 1; |
| 138 end | 138 end |
| 139 | 139 |
| 140 -- Compose a textual representation of Atom payloads | 140 -- Compose a textual representation of Atom payloads |
| 141 local summary_templates = module:get_option("pubsub_summary_templates", { | 141 local summary_templates = module:get_option("pubsub_summary_templates", { |
| 142 ["http://www.w3.org/2005/Atom"] = "{summary|or{{author/name|and{{author/name} posted }}{title}}}"; | 142 ["http://www.w3.org/2005/Atom"] = "{@pubsub:title|and{*{@pubsub:title}*\n\n}}{summary|or{{author/name|and{{author/name} posted }}{title}}}"; |
| 143 }) | 143 }) |
| 144 | 144 |
| 145 for pubsub_type, template in pairs(summary_templates) do | 145 for pubsub_type, template in pairs(summary_templates) do |
| 146 module:hook("pubsub-summary/"..pubsub_type, function (event) | 146 module:hook("pubsub-summary/"..pubsub_type, function (event) |
| 147 local payload = event.payload; | 147 local payload = event.payload; |
| 148 | |
| 149 local got_config, node_config = service:get_node_config(event.node, true); | |
| 150 if got_config then | |
| 151 payload = st.clone(payload); | |
| 152 payload.attr["xmlns:pubsub"] = xmlns_pubsub; | |
| 153 payload.attr["pubsub:node"] = event.node; | |
| 154 payload.attr["pubsub:title"] = node_config.title; | |
| 155 payload.attr["pubsub:description"] = node_config.description; | |
| 156 end | |
| 157 | |
| 148 return xtemplate.render(template, payload, tostring); | 158 return xtemplate.render(template, payload, tostring); |
| 149 end, -1); | 159 end, -1); |
| 150 end | 160 end |
| 151 | 161 |
| 152 | 162 |
