Changeset

11714:d783716103c1

mod_pubsub: Fix inclusion of publisher (fixes #1399)
author Kim Alvefur <zash@zash.se>
date Wed, 01 May 2019 22:33:22 +0200
parents 11713:7623767df468
children 11715:ddd6e21e58bf
files plugins/mod_pubsub/pubsub.lib.lua spec/scansion/pep_nickname.scs spec/scansion/pep_publish_subscribe.scs spec/scansion/pubsub_advanced.scs spec/scansion/pubsub_basic.scs spec/scansion/pubsub_multi_items.scs
diffstat 6 files changed, 20 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pubsub/pubsub.lib.lua	Fri Jul 23 17:13:06 2021 +0200
+++ b/plugins/mod_pubsub/pubsub.lib.lua	Wed May 01 22:33:22 2019 +0200
@@ -607,6 +607,9 @@
 			item.attr.id = id;
 		end
 	end
+	if item then
+		item.attr.publisher = service.config.normalize_jid(stanza.attr.from);
+	end
 	local ok, ret = service:publish(node, stanza.attr.from, id, item, required_config);
 	local reply;
 	if ok then
@@ -795,8 +798,8 @@
 	return true;
 end
 
-local function create_encapsulating_item(id, payload)
-	local item = st.stanza("item", { id = id, xmlns = xmlns_pubsub });
+local function create_encapsulating_item(id, payload, publisher)
+	local item = st.stanza("item", { id = id, publisher = publisher, xmlns = xmlns_pubsub });
 	item:add_child(payload);
 	return item;
 end
--- a/spec/scansion/pep_nickname.scs	Fri Jul 23 17:13:06 2021 +0200
+++ b/spec/scansion/pep_nickname.scs	Wed May 01 22:33:22 2019 +0200
@@ -1,7 +1,7 @@
 # Publishing a nickname in PEP and receiving a notification
 
 [Client] Romeo
-	jid: romeo@localhost/nJi7BeTR
+	jid: romeo@localhost
 	password: password
 
 -----
@@ -20,7 +20,7 @@
 	</iq>
 
 Romeo receives:
-	<iq id="4" to="romeo@localhost/nJi7BeTR" type="result">
+	<iq id="4" type="result">
 	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
 	    <publish node="http://jabber.org/protocol/nick">
 	      <item id="current"/>
@@ -34,12 +34,12 @@
 	</presence>
 
 Romeo receives:
-	<iq id="disco" to="romeo@localhost/nJi7BeTR" from="romeo@localhost" type="get">
+	<iq id="disco" from="romeo@localhost" type="get">
 	  <query xmlns="http://jabber.org/protocol/disco#info" node="http://code.matthewwild.co.uk/clix/#jC32N+FhQoLrZ7nNQtZK3aqR0Fk="/>
 	</iq>
 
 Romeo receives:
-	<presence from="romeo@localhost/nJi7BeTR">
+	<presence>
 	  <c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://code.matthewwild.co.uk/clix/" ver="jC32N+FhQoLrZ7nNQtZK3aqR0Fk="/>
 	</presence>
 
@@ -55,10 +55,10 @@
 	</iq>
 
 Romeo receives:
-	<message type="headline" from="romeo@localhost" to="romeo@localhost/nJi7BeTR">
+	<message type="headline" from="romeo@localhost">
 	  <event xmlns="http://jabber.org/protocol/pubsub#event">
 	    <items node="http://jabber.org/protocol/nick">
-	      <item id="current">
+	      <item id="current" publisher="${Romeo's JID}">
 	        <nickname xmlns="http://jabber.org/protocol/nick"/>
 	      </item>
 	    </items>
--- a/spec/scansion/pep_publish_subscribe.scs	Fri Jul 23 17:13:06 2021 +0200
+++ b/spec/scansion/pep_publish_subscribe.scs	Wed May 01 22:33:22 2019 +0200
@@ -182,7 +182,7 @@
 	<iq type='result' id='fixme'/>
 
 Juliet sends:
-	<iq type='set' id='7'><pubsub xmlns='http://jabber.org/protocol/pubsub'><publish node='http://jabber.org/protocol/tune'><item id='current'><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></publish></pubsub></iq>
+	<iq type='set' id='7'><pubsub xmlns='http://jabber.org/protocol/pubsub'><publish node='http://jabber.org/protocol/tune'><item id='current' publisher="${Juliet's JID}"><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></publish></pubsub></iq>
 
 Juliet receives:
 	<iq type='result' id='7' ><pubsub xmlns='http://jabber.org/protocol/pubsub'><publish node='http://jabber.org/protocol/tune'><item id='current'/></publish></pubsub></iq>
@@ -197,13 +197,13 @@
 	<iq type='result' id='{scansion:any}'/>
 
 Romeo receives:
-	<message type='headline' from='pep-test-tqvqu_pv@localhost'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='http://jabber.org/protocol/tune'><item id='current'><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></items></event></message>
+	<message type='headline' from='pep-test-tqvqu_pv@localhost'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='http://jabber.org/protocol/tune'><item id='current' publisher="${Juliet's JID}"><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></items></event></message>
 
 Romeo sends:
 	<iq type='result' id='disco' to='pep-test-tqvqu_pv@localhost'><query xmlns='http://jabber.org/protocol/disco#info' node='http://code.matthewwild.co.uk/verse/#IfQwbaaDB4LEP5tkGArEaB/3Y+s='><identity type='pc' name='Verse' category='client'/><feature var='http://jabber.org/protocol/tune+notify'/><feature var='http://jabber.org/protocol/disco#info'/><feature var='http://jabber.org/protocol/disco#items'/><feature var='http://jabber.org/protocol/caps'/><feature var='http://jabber.org/protocol/mood+notify'/></query></iq>
 
 Romeo receives:
-	<message type='headline' from='pep-test-tqvqu_pv@localhost'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='http://jabber.org/protocol/tune'><item id='current'><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></items></event></message>
+	<message type='headline' from='pep-test-tqvqu_pv@localhost'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='http://jabber.org/protocol/tune'><item id='current' publisher="${Juliet's JID}"><tune xmlns='http://jabber.org/protocol/tune'><title>Beautiful Cedars</title><artist>The Spinners</artist><source>Not Quite Folk</source><track>4</track></tune></item></items></event></message>
 
 Juliet disconnects
 
--- a/spec/scansion/pubsub_advanced.scs	Fri Jul 23 17:13:06 2021 +0200
+++ b/spec/scansion/pubsub_advanced.scs	Wed May 01 22:33:22 2019 +0200
@@ -129,7 +129,7 @@
 	<message type="headline" from="pubsub.localhost">
 		<event xmlns="http://jabber.org/protocol/pubsub#event">
 			<items node="princely_musings">
-				<item id="current">
+				<item id="current" publisher="${Romeo's JID}">
 					<entry xmlns="http://www.w3.org/2005/Atom">
 						<title>Soliloquy</title>
 						<summary>Lorem ipsum dolor sit amet</summary>
--- a/spec/scansion/pubsub_basic.scs	Fri Jul 23 17:13:06 2021 +0200
+++ b/spec/scansion/pubsub_basic.scs	Wed May 01 22:33:22 2019 +0200
@@ -67,7 +67,7 @@
 	<message type="headline" from="pubsub.localhost">
 		<event xmlns="http://jabber.org/protocol/pubsub#event">
 			<items node="princely_musings">
-				<item id="current">
+				<item id="current" publisher="${Romeo's JID}">
 					<entry xmlns="http://www.w3.org/2005/Atom">
 						<title>Soliloquy</title>
 						<summary>Lorem ipsum dolor sit amet</summary>
--- a/spec/scansion/pubsub_multi_items.scs	Fri Jul 23 17:13:06 2021 +0200
+++ b/spec/scansion/pubsub_multi_items.scs	Wed May 01 22:33:22 2019 +0200
@@ -159,10 +159,10 @@
 	<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":3nvB2E20p1iuM6lOPaP6">
 	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
 	    <items node="e96caf12-264f-4e5a-988e-00ae191771b6">
-	      <item xmlns="http://jabber.org/protocol/pubsub" id="20e9eb9e-8acb-436e-a486-40e80400faf1">
+	      <item publisher="${Alice's JID}" xmlns="http://jabber.org/protocol/pubsub" id="20e9eb9e-8acb-436e-a486-40e80400faf1">
 		<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo>
 	      </item>
-	      <item xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557">
+	      <item publisher="${Alice's JID}" xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557">
 		<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo>
 	      </item>
 	    </items>
@@ -180,10 +180,10 @@
 	<iq xmlns:stream="http://etherx.jabber.org/streams" to="${Alice's full JID}" from="pubsub.localhost" type="result" id=":XQdyK54iyOKiJvUoX9t_">
 	  <pubsub xmlns="http://jabber.org/protocol/pubsub">
 	    <items node="e96caf12-264f-4e5a-988e-00ae191771b6">
-	      <item xmlns="http://jabber.org/protocol/pubsub" id="20e9eb9e-8acb-436e-a486-40e80400faf1">
+	      <item xmlns="http://jabber.org/protocol/pubsub" publisher="${Alice's JID}" id="20e9eb9e-8acb-436e-a486-40e80400faf1">
 		<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">foo</foo>
 	      </item>
-	      <item xmlns="http://jabber.org/protocol/pubsub" id="4b94623d-1127-41c0-ac47-e283fd890557">
+	      <item xmlns="http://jabber.org/protocol/pubsub" publisher="${Alice's JID}" id="4b94623d-1127-41c0-ac47-e283fd890557">
 		<foo xmlns="https://zombofant.net/xmlns/aioxmpp#test">bar</foo>
 	      </item>
 	    </items>