Comparison

plugins/mod_pubsub/mod_pubsub.lua @ 8811:f2d35eee69c9

mod_pubsub: Set an id attribute on outgoing event messages https://xmpp.org/extensions/xep-0060.html#impl-bounce > a pubsub service SHOULD ensure that the <message/> stanza for each > event notification it generates possesses an 'id' attribute with a > value
author Kim Alvefur <zash@zash.se>
date Mon, 21 May 2018 00:24:50 +0200
parent 8808:40a7135eb6ac
child 8814:07197f29e2b8
comparison
equal deleted inserted replaced
8810:9f8a746f99c1 8811:f2d35eee69c9
1 local pubsub = require "util.pubsub"; 1 local pubsub = require "util.pubsub";
2 local st = require "util.stanza"; 2 local st = require "util.stanza";
3 local jid_bare = require "util.jid".bare; 3 local jid_bare = require "util.jid".bare;
4 local usermanager = require "core.usermanager"; 4 local usermanager = require "core.usermanager";
5 local new_id = require "util.id".medium;
5 6
6 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; 7 local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
7 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event"; 8 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event";
8 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; 9 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner";
9 10
46 item.attr.xmlns = nil; -- Clear the pubsub namespace 47 item.attr.xmlns = nil; -- Clear the pubsub namespace
47 if expose_publisher and actor then 48 if expose_publisher and actor then
48 item.attr.publisher = actor 49 item.attr.publisher = actor
49 end 50 end
50 end 51 end
51 local message = st.message({ from = module.host, type = "headline" }) 52
53 local id = new_id();
54 local message = st.message({ from = module.host, type = "headline", id = id })
52 :tag("event", { xmlns = xmlns_pubsub_event }) 55 :tag("event", { xmlns = xmlns_pubsub_event })
53 :tag(kind, { node = node }) 56 :tag(kind, { node = node })
54 :add_child(item); 57 :add_child(item);
55 module:broadcast(jids, message, pairs); 58 module:broadcast(jids, message, pairs);
56 end 59 end