git » sdk » commit 241512a

Do not use client sortId on channel message ever

author Stephen Paul Weber
2026-09-15 19:38:14 UTC
committer Stephen Paul Weber
2026-09-15 19:38:14 UTC
parent 480acc84a4e7dff00dcbba0e51663a520bb4a76e

Do not use client sortId on channel message ever

borogove/Chat.hx +3 -0
test/TestClient.hx +1 -0

diff --git a/borogove/Chat.hx b/borogove/Chat.hx
index 149ec92..2d65915 100644
--- a/borogove/Chat.hx
+++ b/borogove/Chat.hx
@@ -2261,6 +2261,9 @@ class Channel extends Chat {
 			if (sortId != null && message.type == MessageChannel) {
 				sortId = message.sortId = FractionalIndexing.between(sortId, null, FractionalIndexing.BASE_95_DIGITS);
 			} else {
+				if (message.type == MessageChannel) {
+					throw "Cannot store message before we know sortId";
+				}
 				message.sortId = client.nextSortId();
 			}
 		}
diff --git a/test/TestClient.hx b/test/TestClient.hx
index 9554d15..340caeb 100644
--- a/test/TestClient.hx
+++ b/test/TestClient.hx
@@ -316,6 +316,7 @@ class TestClient extends utest.Test {
 		final serverId = "msg1";
 
 		final chat = new borogove.Chat.Channel(client, client.stream, persistence, chatId);
+		chat.sortId = "a ";
 		client.chats.push(chat);
 
 		final builder = new ChatMessageBuilder();