Software / code / prosody
Comparison
plugins/mod_pubsub/mod_pubsub.lua @ 9039:0124e5ec1556
mod_pubsub: Move include_body option into subscription options
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 14 Jul 2018 19:34:10 +0200 |
| parent | 8980:4d2738b99b07 |
| child | 9043:9d77b6588bdf |
comparison
equal
deleted
inserted
replaced
| 9038:fd053fcaf9bc | 9039:0124e5ec1556 |
|---|---|
| 49 | 49 |
| 50 if item then | 50 if item then |
| 51 message:add_child(item); | 51 message:add_child(item); |
| 52 end | 52 end |
| 53 | 53 |
| 54 local summary; | |
| 54 -- Compose a sensible textual representation of at least Atom payloads | 55 -- Compose a sensible textual representation of at least Atom payloads |
| 55 if node_obj and item and node_obj.config.include_body and item.tags[1] then | 56 if item and item.tags[1] then |
| 56 local payload = item.tags[1]; | 57 local payload = item.tags[1]; |
| 57 if payload.attr.xmlns == "http://www.w3.org/2005/Atom" then | 58 if payload.attr.xmlns == "http://www.w3.org/2005/Atom" then |
| 58 message:reset(); | 59 message:reset(); |
| 59 local title = payload:get_child_text("title"); | 60 local title = payload:get_child_text("title"); |
| 60 local summary = payload:get_child_text("summary"); | 61 summary = payload:get_child_text("summary"); |
| 61 if not summary and title then | 62 if not summary and title then |
| 62 local author = payload:find("author/name#"); | 63 local author = payload:find("author/name#"); |
| 63 summary = title; | 64 summary = title; |
| 64 if author then | 65 if author then |
| 65 summary = author .. " posted " .. summary; | 66 summary = author .. " posted " .. summary; |
| 66 end | 67 end |
| 67 end | 68 end |
| 68 if summary then | |
| 69 message:body(summary); | |
| 70 end | |
| 71 end | 69 end |
| 72 end | 70 end |
| 73 | 71 |
| 74 module:broadcast(jids, message, pairs); | 72 for jid, options in pairs(jids) do |
| 73 local new_stanza = st.clone(message); | |
| 74 if type(options) == "table" and options["pubsub#include_body"] then | |
| 75 new_stanza:body(summary); | |
| 76 end | |
| 77 new_stanza.attr.to = jid; | |
| 78 module:send(new_stanza); | |
| 79 end | |
| 75 end | 80 end |
| 76 | 81 |
| 77 function is_item_stanza(item) | 82 function is_item_stanza(item) |
| 78 return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item"; | 83 return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item"; |
| 79 end | 84 end |