git » sdk » commit 480acc8

Publish options is not child of publish

author Eric Roberts
2026-09-15 17:31:52 UTC
committer Stephen Paul Weber
2026-09-15 17:40:28 UTC
parent 22114cb104341f27e148a350fa2c0a78e833b650

Publish options is not child of publish

https://xmpp.org/extensions/xep-0060.html#publisher-publish-options

borogove/Client.hx +4 -1
test/TestClient.hx +19 -0

diff --git a/borogove/Client.hx b/borogove/Client.hx
index d58868b..2889827 100644
--- a/borogove/Client.hx
+++ b/borogove/Client.hx
@@ -2047,7 +2047,10 @@ class Client extends EventEmitter {
 	@:allow(borogove)
 	private function publishWithOptions(stanza:Stanza, options:Stanza) {
 		final clone = stanza.clone();
-		clone.findChild("{http://jabber.org/protocol/pubsub}pubsub/publish").tag("publish-options").addChild(options);
+		clone
+			.findChild("{http://jabber.org/protocol/pubsub}pubsub")
+			.tag("publish-options")
+			.addChild(options);
 		stream.sendIq(
 			clone,
 			(response) -> {
diff --git a/test/TestClient.hx b/test/TestClient.hx
index 13e575f..9554d15 100644
--- a/test/TestClient.hx
+++ b/test/TestClient.hx
@@ -46,6 +46,25 @@ class TestClient extends utest.Test {
 		client.setStatus(new Status("😊", "feeling good"));
 	}
 
+	public function testPublishWithOptions(async: Async) {
+		final client = new Client("test@example.com", new Dummy());
+		final stanza = new Stanza("iq", { type: "set" })
+			.tag("pubsub", { xmlns: "http://jabber.org/protocol/pubsub" })
+			.tag("publish", { node: "test-node" })
+			.tag("item");
+		final options = new Stanza("x", { xmlns: "jabber:x:data", type: "submit" });
+
+		client.stream.on("sendStanza", (sent: Stanza) -> {
+			final pubsub = sent.getChild("pubsub", "http://jabber.org/protocol/pubsub");
+			Assert.notNull(pubsub.getChild("publish"));
+			Assert.notNull(pubsub.getChild("publish-options"));
+			async.done();
+			return EventHandled;
+		});
+
+		client.publishWithOptions(stanza, options);
+	}
+
 	public function testReceiveStatusUpdate(async: Async) {
 		final persistence = new Dummy();
 		final client = new Client("test@example.com", persistence);