git » sdk » commit 5833681

Workaround for https://github.com/HaxeFoundation/haxe/issues/11666

author Stephen Paul Weber
2026-05-26 20:37:29 UTC
committer Stephen Paul Weber
2026-05-26 20:37:29 UTC
parent 5b91e960dd40e9207f48a975a92b14ee4057db47

Workaround for https://github.com/HaxeFoundation/haxe/issues/11666

borogove/Chat.hx +4 -4
borogove/Client.hx +3 -3
test/TestChat.hx +18 -0

diff --git a/borogove/Chat.hx b/borogove/Chat.hx
index 4bbcb9a..c10f255 100644
--- a/borogove/Chat.hx
+++ b/borogove/Chat.hx
@@ -699,7 +699,7 @@ abstract class Chat extends EventEmitter {
 	}
 
 	@:allow(borogove)
-	abstract private function setPresence(resource:String, presence:Presence, noStore:Bool = false):Void;
+	abstract private function setPresence(resource:String, presence:Presence, noStore:Bool):Void;
 
 	@:allow(borogove)
 	abstract private function getCaps():KeyValueIterator<Null<String>, Caps>;
@@ -1066,7 +1066,7 @@ class DirectChat extends Chat {
 	}
 
 	@:allow(borogove)
-	private function setPresence(resource:String, presence:Presence, noStore = false) {
+	private function setPresence(resource:String, presence:Presence, noStore:Bool) {
 		// We only store presence for 1:1
 		if (_fullCounterparts.length > 1) return;
 
@@ -1629,14 +1629,14 @@ class Channel extends Chat {
 	}
 
 	@:allow(borogove)
-	private function setPresence(resource:String, presence:Presence, noStore = false) {
+	private function setPresence(resource:String, presence:Presence, noStore:Bool) {
 		final oneTen = presence?.mucUser?.statusCodes?.find((status) -> status == "110");
 		final member = buildMember(resource, presence);
 		if (presence.mucUser != null && oneTen == null && member.isSelf) {
 			// ejabberd sends presence updates for self without 110
 			final mucUser: Stanza = presence.mucUser;
 			mucUser.tag("status", { code: "110" }).up();
-			setPresence(resource, presence);
+			setPresence(resource, presence, noStore);
 			return;
 		}
 		final occupantId = (presence : Stanza).getChild("occupant-id", "urn:xmpp:occupant-id:0")?.attr?.get("id");
diff --git a/borogove/Client.hx b/borogove/Client.hx
index 3b5eada..a602b0b 100644
--- a/borogove/Client.hx
+++ b/borogove/Client.hx
@@ -357,10 +357,10 @@ class Client extends EventEmitter {
 				}
 
 				if (presence.ver == null) {
-					chat.setPresence(JID.parse(stanza.attr.get("from")).resource, stanza);
+					chat.setPresence(JID.parse(stanza.attr.get("from")).resource, stanza, false);
 				} else {
 					final handleCaps = (caps) -> {
-						chat.setPresence(JID.parse(stanza.attr.get("from")).resource, stanza);
+						chat.setPresence(JID.parse(stanza.attr.get("from")).resource, stanza, false);
 						return chat;
 					};
 
@@ -426,7 +426,7 @@ class Client extends EventEmitter {
 					trace("Presence for unknown JID: " + stanza.attr.get("from"));
 					return EventUnhandled;
 				}
-				chat.setPresence(JID.parse(stanza.attr.get("from")).resource, stanza);
+				chat.setPresence(JID.parse(stanza.attr.get("from")).resource, stanza, false);
 				this.trigger("chats/update", [chat]);
 			}
 
diff --git a/test/TestChat.hx b/test/TestChat.hx
index b197536..1e3882b 100644
--- a/test/TestChat.hx
+++ b/test/TestChat.hx
@@ -309,6 +309,24 @@ class TestChat extends utest.Test {
 		Assert.isFalse(channel.syncing(), "Should NOT be syncing after join failure");
 	}
 
+	public function testJoinSuccess() {
+		final persistence = new Dummy();
+		final client = new Client("test@example.com", persistence);
+		final caps = new borogove.Caps("", [new Identity("conference", "text", "Channel")], ["http://jabber.org/protocol/muc"], []);
+		final availableChat = new AvailableChat("channel@example.com", "Channel", "", caps);
+		final channel = cast(client.startChat(availableChat), Channel);
+
+		Assert.isNull(channel.self);
+
+		final joinedStanza = new Stanza("presence", { xmlns: "jabber:client", from: "channel@example.com/test", to: "test@example.com" })
+			.tag("x", { xmlns: "http://jabber.org/protocol/muc#user" }).tag("status", { code: "110" }).up()
+			.up();
+
+		client.stream.onStanza(joinedStanza);
+
+		Assert.notNull(channel.self);
+	}
+
 	public function testSyncFailure(async: Async) {
 		final persistence = new Dummy();
 		final client = new Client("test@example.com", persistence);