Software /
code /
prosody
Comparison
plugins/mod_pubsub/mod_pubsub.lua @ 8946:3a095233e178
mod_pubsub: Handle optional item (thanks jonasw)
The ‘item’ argument is optional, so it needs to handle it not being
included, or util.stanza will throw an error in add_child
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 28 Jun 2018 01:46:28 +0200 |
parent | 8815:5974c9da1391 |
child | 8957:21ae6cb20dcf |
comparison
equal
deleted
inserted
replaced
8945:cbeb1a045eb6 | 8946:3a095233e178 |
---|---|
53 local id = new_id(); | 53 local id = new_id(); |
54 local msg_type = node_obj and node_obj.config.message_type or "headline"; | 54 local msg_type = node_obj and node_obj.config.message_type or "headline"; |
55 local message = st.message({ from = module.host, type = msg_type, id = id }) | 55 local message = st.message({ from = module.host, type = msg_type, id = id }) |
56 :tag("event", { xmlns = xmlns_pubsub_event }) | 56 :tag("event", { xmlns = xmlns_pubsub_event }) |
57 :tag(kind, { node = node }) | 57 :tag(kind, { node = node }) |
58 :add_child(item); | 58 |
59 if item then | |
60 message:add_child(item); | |
61 end | |
59 | 62 |
60 -- Compose a sensible textual representation of at least Atom payloads | 63 -- Compose a sensible textual representation of at least Atom payloads |
61 if node_obj and node_obj.config.include_body and item.tags[1] then | 64 if node_obj and item and node_obj.config.include_body and item.tags[1] then |
62 local payload = item.tags[1]; | 65 local payload = item.tags[1]; |
63 if payload.attr.xmlns == "http://www.w3.org/2005/Atom" then | 66 if payload.attr.xmlns == "http://www.w3.org/2005/Atom" then |
64 message:reset(); | 67 message:reset(); |
65 local title = payload:get_child_text("title"); | 68 local title = payload:get_child_text("title"); |
66 local summary = payload:get_child_text("summary"); | 69 local summary = payload:get_child_text("summary"); |