git » sdk » commit b57dfae

Assert that DirectChat id is made of bare JIDs

author Stephen Paul Weber
2026-11-10 03:45:58 UTC
committer Stephen Paul Weber
2026-11-10 04:08:46 UTC
parent 60b22f362a73010ed4fb2a13730a46b13e00658f

Assert that DirectChat id is made of bare JIDs

borogove/Client.hx +3 -0

diff --git a/borogove/Client.hx b/borogove/Client.hx
index bfd8ab8..03fd90c 100644
--- a/borogove/Client.hx
+++ b/borogove/Client.hx
@@ -1691,6 +1691,9 @@ class Client extends EventEmitter {
 
 	@:allow(borogove)
 	private function getDirectChat(chatId:String, triggerIfNew:Bool = true):DirectChat {
+		final bareChatId = chatId.split("\n").map(part -> JID.parse(part).asBare().asString()).join("\n");
+		if (bareChatId != chatId) throw 'Malformed chatId: $chatId';
+
 		for (chat in chats) {
 			if (Std.isOfType(chat, DirectChat) && chat.chatId == chatId) {
 				return Std.downcast(chat, DirectChat);