diff options
-rw-r--r-- | plugins/mod_pubsub/mod_pubsub.lua | 17 | ||||
-rw-r--r-- | plugins/mod_pubsub/pubsub.lib.lua | 15 |
2 files changed, 17 insertions, 15 deletions
diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index c97e9d98..829846c4 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -51,13 +51,14 @@ function simple_broadcast(kind, node, jids, item, actor, node_obj) message:add_child(item); end + local summary; -- Compose a sensible textual representation of at least Atom payloads - if node_obj and item and node_obj.config.include_body and item.tags[1] then + if item and item.tags[1] then local payload = item.tags[1]; if payload.attr.xmlns == "http://www.w3.org/2005/Atom" then message:reset(); local title = payload:get_child_text("title"); - local summary = payload:get_child_text("summary"); + summary = payload:get_child_text("summary"); if not summary and title then local author = payload:find("author/name#"); summary = title; @@ -65,13 +66,17 @@ function simple_broadcast(kind, node, jids, item, actor, node_obj) summary = author .. " posted " .. summary; end end - if summary then - message:body(summary); - end end end - module:broadcast(jids, message, pairs); + for jid, options in pairs(jids) do + local new_stanza = st.clone(message); + if type(options) == "table" and options["pubsub#include_body"] then + new_stanza:body(summary); + end + new_stanza.attr.to = jid; + module:send(new_stanza); + end end function is_item_stanza(item) diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index ebb8727d..5cabdf00 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -46,7 +46,6 @@ local function config_to_xep0060(node_config) ["pubsub#max_items"] = tostring(node_config["max_items"]); ["pubsub#persist_items"] = node_config["persist_items"]; ["pubsub#notification_type"] = node_config["notification_type"]; - ["pubsub#include_body"] = node_config["include_body"]; } end @@ -57,7 +56,6 @@ local function config_from_xep0060(config) ["max_items"] = tonumber(config["pubsub#max_items"]); ["persist_items"] = config["pubsub#persist_items"]; ["notification_type"] = config["pubsub#notification_type"]; - ["include_body"] = config["pubsub#include_body"]; } end @@ -88,11 +86,6 @@ local node_config_form = dataform { label = "Persist items to storage"; }; { - type = "boolean"; - name = "pubsub#include_body"; - label = "Receive message body in addition to payload?"; - }; - { type = "list-single"; name = "pubsub#notification_type"; label = "Specify the delivery style for notifications"; @@ -108,8 +101,12 @@ local options_form = dataform { type = "hidden"; name = "FORM_TYPE"; value = "http://jabber.org/protocol/pubsub#subscribe_options"; - } - -- No options yet. File a feature request ;) + }; + { + type = "boolean"; + name = "pubsub#include_body"; + label = "Receive message body in addition to payload?"; + }; }; local node_metadata_form = dataform { |