git » sdk » commit e7c0b53

Helper to check if one message can replace another

author Stephen Paul Weber
2026-03-15 19:44:58 UTC
committer Stephen Paul Weber
2026-03-15 19:51:31 UTC
parent 170a880765c17d5b858066d4e3606e83117a9e0f

Helper to check if one message can replace another

Because they are either the exact same message, or one is an
edit/replacement of the other

borogove/ChatMessage.hx +10 -0

diff --git a/borogove/ChatMessage.hx b/borogove/ChatMessage.hx
index 659ca69..67eff35 100644
--- a/borogove/ChatMessage.hx
+++ b/borogove/ChatMessage.hx
@@ -444,6 +444,16 @@ class ChatMessage {
 		return (!isIncoming() ? from?.asBare()?.asString() : to?.asBare()?.asString()) ?? throw "from or to is null";
 	}
 
+	/**
+		Is this message the same as or a replacement for some other one?
+	**/
+	public function canReplace(other: ChatMessage) {
+		return
+			(other.serverId != null && serverId == other.serverId && serverIdBy == other.serverIdBy) ||
+			(localId == other.localId &&
+				((!isIncoming() && !other.isIncoming()) || (senderId == other.senderId && versions.length > 0)));
+	}
+
 	/**
 		Is this an incoming message?
 	**/