Changeset

11429:ef623d719894

mod_pubsub: Include <pubsub> with unsubscribe reply XEP-0060 6.2.2 This is a MAY but it makes it nice and symmetric with the subscription response. Reduces the need to remember which node you unsubscribed from. Explicit > implicit etc.
author Kim Alvefur <zash@zash.se>
date Mon, 15 Mar 2021 19:04:08 +0100
parents 11428:d91def9fcfdd
children 11430:56a282ecdcf1
files plugins/mod_pubsub/pubsub.lib.lua spec/scansion/pubsub_advanced.scs
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pubsub/pubsub.lib.lua	Sat Mar 06 18:26:50 2021 +0100
+++ b/plugins/mod_pubsub/pubsub.lib.lua	Mon Mar 15 19:04:08 2021 +0100
@@ -517,7 +517,13 @@
 	local ok, ret = service:remove_subscription(node, stanza.attr.from, jid);
 	local reply;
 	if ok then
-		reply = st.reply(stanza);
+		reply = st.reply(stanza)
+			:tag("pubsub", { xmlns = xmlns_pubsub })
+				:tag("subscription", {
+					node = node,
+					jid = jid,
+					subscription = "none"
+				}):up();
 	else
 		reply = pubsub_error_reply(stanza, ret);
 	end
--- a/spec/scansion/pubsub_advanced.scs	Sat Mar 06 18:26:50 2021 +0100
+++ b/spec/scansion/pubsub_advanced.scs	Mon Mar 15 19:04:08 2021 +0100
@@ -150,7 +150,11 @@
 	</iq>
 
 Juliet receives:
-	<iq type="result" id='unsub1'/>
+	<iq type="result" id='unsub1'>
+		<pubsub xmlns='http://jabber.org/protocol/pubsub'>
+			<subscription jid="${Juliet's full JID}" node='princely_musings' subscription='none'/>
+		</pubsub>
+	</iq>
 
 Balthasar sends:
 	<iq type="set" to="pubsub.localhost" id='del1'>