Mercurial > prosody-hg
comparison plugins/mod_pep_plus.lua @ 8895:d00ea07de9a0
mod_pep_plus: Prevent nil from being added as a child on item deletion.
| author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
|---|---|
| date | Fri, 08 Jun 2018 23:03:34 +0200 |
| parents | d6373a378b73 |
| children | 9194431b6447 |
comparison
equal
deleted
inserted
replaced
| 8894:7273fb6af831 | 8895:d00ea07de9a0 |
|---|---|
| 61 end | 61 end |
| 62 | 62 |
| 63 local function get_broadcaster(username) | 63 local function get_broadcaster(username) |
| 64 local user_bare = jid_join(username, host); | 64 local user_bare = jid_join(username, host); |
| 65 local function simple_broadcast(kind, node, jids, item) | 65 local function simple_broadcast(kind, node, jids, item) |
| 66 local message = st.message({ from = user_bare, type = "headline" }) | |
| 67 :tag("event", { xmlns = xmlns_pubsub_event }) | |
| 68 :tag(kind, { node = node }); | |
| 66 if item then | 69 if item then |
| 67 item = st.clone(item); | 70 item = st.clone(item); |
| 68 item.attr.xmlns = nil; -- Clear the pubsub namespace | 71 item.attr.xmlns = nil; -- Clear the pubsub namespace |
| 69 end | 72 message:add_child(item); |
| 70 local message = st.message({ from = user_bare, type = "headline" }) | 73 end |
| 71 :tag("event", { xmlns = xmlns_pubsub_event }) | |
| 72 :tag(kind, { node = node }) | |
| 73 :add_child(item); | |
| 74 for jid in pairs(jids) do | 74 for jid in pairs(jids) do |
| 75 module:log("debug", "Sending notification to %s from %s: %s", jid, user_bare, tostring(item)); | 75 module:log("debug", "Sending notification to %s from %s: %s", jid, user_bare, tostring(item)); |
| 76 message.attr.to = jid; | 76 message.attr.to = jid; |
| 77 module:send(message); | 77 module:send(message); |
| 78 end | 78 end |
