# HG changeset patch # User Kim Alvefur # Date 1534422741 -7200 # Node ID 82fad995a149c378c8930b76de79d16be901752b # Parent f226b7b5486bfab943f6c011ae60de71c3c1c5de util.pubsub: Pass "retract" as the type of such broadcasts This moves some XEP-0060 awkwardness out of util.pubsub and into mod_pubsub A retraction is broadcast in an container, whereas most other kinds of broadcasts are in a container with a name matching the 'kind' attribute. diff -r f226b7b5486b -r 82fad995a149 plugins/mod_pep.lua --- a/plugins/mod_pep.lua Thu Aug 16 06:05:11 2018 +0200 +++ b/plugins/mod_pep.lua Thu Aug 16 14:32:21 2018 +0200 @@ -124,6 +124,9 @@ local function get_broadcaster(username) local user_bare = jid_join(username, host); local function simple_broadcast(kind, node, jids, item) + if kind == "retract" then + kind = "items"; -- XEP-0060 signals retraction in an container + end local message = st.message({ from = user_bare, type = "headline" }) :tag("event", { xmlns = xmlns_pubsub_event }) :tag(kind, { node = node }); diff -r f226b7b5486b -r 82fad995a149 plugins/mod_pubsub/mod_pubsub.lua --- a/plugins/mod_pubsub/mod_pubsub.lua Thu Aug 16 06:05:11 2018 +0200 +++ b/plugins/mod_pubsub/mod_pubsub.lua Thu Aug 16 14:32:21 2018 +0200 @@ -47,6 +47,10 @@ end function simple_broadcast(kind, node, jids, item, actor, node_obj) + if kind == "retract" then + kind = "items"; -- XEP-0060 signals retraction in an container + end + if item then item = st.clone(item); item.attr.xmlns = nil; -- Clear the pubsub namespace diff -r f226b7b5486b -r 82fad995a149 util/pubsub.lua --- a/util/pubsub.lua Thu Aug 16 06:05:11 2018 +0200 +++ b/util/pubsub.lua Thu Aug 16 14:32:21 2018 +0200 @@ -523,7 +523,7 @@ end self.events.fire_event("item-retracted", { node = node, actor = actor, id = id }); if retract then - self.config.broadcaster("items", node, node_obj.subscribers, retract, actor, node_obj, self); + self.config.broadcaster("retract", node, node_obj.subscribers, retract, actor, node_obj, self); end return true end