changeset 14117:354427afb638

mod_pubsub: Provide iteminfo method to enable retract-own-items functionality
author Matthew Wild <mwild1@gmail.com>
date Tue, 31 Mar 2026 14:15:00 +0100
parents c8458864dcea
children 221f3378e7f4
files plugins/mod_pubsub/mod_pubsub.lua spec/scansion/pubsub_retract_own.scs
diffstat 2 files changed, 160 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pubsub/mod_pubsub.lua	Tue Mar 31 14:13:32 2026 +0100
+++ b/plugins/mod_pubsub/mod_pubsub.lua	Tue Mar 31 14:15:00 2026 +0100
@@ -141,6 +141,12 @@
 	return st.is_stanza(item) and item.attr.xmlns == xmlns_pubsub and item.name == "item" and #item.tags == 1;
 end
 
+function get_item_metadata(item)
+	return {
+		publisher = item.attr.publisher;
+	};
+end
+
 -- Compose a textual representation of Atom payloads
 local summary_templates = module:get_option("pubsub_summary_templates", {
 	["http://www.w3.org/2005/Atom"] = "{@pubsub:title|and{*{@pubsub:title}*\n\n}}{summary|or{{author/name|and{{author/name} posted }}{title}}}";
@@ -231,6 +237,7 @@
 	service.config.itemstore = create_simple_itemstore;
 	service.config.broadcaster = simple_broadcast;
 	service.config.itemcheck = is_item_stanza;
+	service.config.iteminfo = get_item_metadata;
 	service.config.check_node_config = check_node_config;
 	service.config.get_affiliation = get_affiliation;
 
@@ -262,6 +269,7 @@
 		itemstore = create_simple_itemstore;
 		broadcaster = simple_broadcast;
 		itemcheck = is_item_stanza;
+		iteminfo = get_item_metadata;
 		check_node_config = check_node_config;
 		metadata_subset = {
 			"title";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spec/scansion/pubsub_retract_own.scs	Tue Mar 31 14:15:00 2026 +0100
@@ -0,0 +1,152 @@
+# Pubsub: Support for retracting own items on third-party node
+
+[Client] Romeo
+	jid: admin@localhost
+	password: password
+
+// admin@localhost is assumed to have node creation privileges
+
+[Client] Juliet
+	jid: juliet@localhost
+	password: password
+
+[Client] Mercutio
+	jid: mercutio@localhost
+	password: password
+
+---------
+
+Romeo connects
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost" id='create1'>
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<create node="romeos_rambles/comments"/>
+			<configure>
+				<x xmlns="jabber:x:data" type="submit">
+					<field var="FORM_TYPE" type="hidden">
+						<value>http://jabber.org/protocol/pubsub#node_config</value>
+					</field>
+					<field var="pubsub#publish_model">
+						<value>subscribers</value>
+					</field>
+				</x>
+			</configure>
+		</pubsub>
+	</iq>
+
+Romeo receives:
+	<iq type="result" id='create1'/>
+
+Juliet connects
+
+Juliet sends:
+	<iq type="set" to="pubsub.localhost" id='jpub1'>
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<publish node="romeos_rambles/comments">
+				<item id="current">
+					<entry xmlns="http://www.w3.org/2005/Atom">
+						<title>Should fail, no permission</title>
+						<summary>Not yet a subscriber</summary>
+					</entry>
+				</item>
+			</publish>
+		</pubsub>
+	</iq>
+
+Juliet receives:
+	<iq type="error" from="pubsub.localhost" id="jpub1">
+		<error type="auth">
+			<forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+		</error>
+	</iq>
+
+Juliet sends:
+	<iq type="set" to="pubsub.localhost" id='sub1'>
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<subscribe node="romeos_rambles/comments" jid="${Juliet's full JID}"/>
+		</pubsub>
+	</iq>
+
+Juliet receives:
+	<iq type="result" id='sub1'/>
+
+Juliet sends:
+	<iq type="set" to="pubsub.localhost" id='jpub2'>
+		<pubsub xmlns="http://jabber.org/protocol/pubsub">
+			<publish node="romeos_rambles/comments">
+				<item id="bedd9e0e-923f-465b-9e2e-139fc6ccc7e7">
+					<entry xmlns="http://www.w3.org/2005/Atom">
+						<title>Thoughts from Juliet</title>
+						<summary>O sweet sir, thy tender speech doth pierce my soul</summary>
+					</entry>
+				</item>
+			</publish>
+		</pubsub>
+	</iq>
+
+Juliet receives:
+	<message from='pubsub.localhost' type='headline'>
+	  <event xmlns='http://jabber.org/protocol/pubsub#event'>
+	    <items node='romeos_rambles/comments' xmlns='http://jabber.org/protocol/pubsub#event'>
+	      <item id='bedd9e0e-923f-465b-9e2e-139fc6ccc7e7' publisher="${Juliet's JID}" xmlns='http://jabber.org/protocol/pubsub#event'>
+	        <entry xmlns='http://www.w3.org/2005/Atom'>
+	          <title xmlns='http://www.w3.org/2005/Atom'>
+	          Thoughts from Juliet
+	          </title>
+	          <summary xmlns='http://www.w3.org/2005/Atom'>
+	          O sweet sir, thy tender speech doth pierce my soul
+	          </summary>
+	        </entry>
+	      </item>
+	    </items>
+	  </event>
+	</message>
+
+Juliet receives:
+	<iq type="result" from="pubsub.localhost" id="jpub2"/>
+
+Mercutio connects
+
+Mercutio sends:
+	<iq type='set' to='pubsub.localhost' id='retract1'>
+		<pubsub xmlns='http://jabber.org/protocol/pubsub'>
+			<retract node='romeos_rambles/comments'>
+				<item id='bedd9e0e-923f-465b-9e2e-139fc6ccc7e7'/>
+			</retract>
+		</pubsub>
+	</iq>
+
+Mercutio receives:
+	<iq type="error" from="pubsub.localhost" id="retract1">
+		<error type="auth">
+			<forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
+		</error>
+	</iq>
+
+
+Juliet sends:
+	<iq type='set' to='pubsub.localhost' id='retract2'>
+		<pubsub xmlns='http://jabber.org/protocol/pubsub'>
+			<retract node='romeos_rambles/comments'>
+				<item id='bedd9e0e-923f-465b-9e2e-139fc6ccc7e7'/>
+			</retract>
+		</pubsub>
+	</iq>
+
+Juliet receives:
+	<iq type="result" from="pubsub.localhost" id="retract2"/>
+
+Romeo sends:
+	<iq type="set" to="pubsub.localhost" id='del1'>
+		<pubsub xmlns="http://jabber.org/protocol/pubsub#owner">
+			<delete node="romeos_rambles/comments"/>
+		</pubsub>
+	</iq>
+
+Romeo receives:
+	<iq type="result" id='del1'/>
+
+Romeo disconnects
+
+// vim: syntax=xml: