git » sdk » commit ec79596

Versions are in order of newest to oldest

author Stephen Paul Weber
2025-10-17 02:38:09 UTC
committer Stephen Paul Weber
2025-10-17 02:38:09 UTC
parent b4d815ef46bcf3d05a95ce8035bb5f8087b3bf2d

Versions are in order of newest to oldest

So oldest should have the ID. And in practise this code usually runs
with only one item.

Check IDB and Sqlite, both sort versions by reverse timestamp. Newest first.

borogove/ChatMessage.hx +1 -1

diff --git a/borogove/ChatMessage.hx b/borogove/ChatMessage.hx
index f496667..946cc7f 100644
--- a/borogove/ChatMessage.hx
+++ b/borogove/ChatMessage.hx
@@ -450,7 +450,7 @@ class ChatMessage {
 		if (to != null) attrs.set("to", to.asString());
 		if (localId != null) attrs.set("id", localId);
 		var stanza = new Stanza("message", attrs);
-		if (versions.length > 0 && versions[0].localId != null) stanza.tag("replace", { xmlns: "urn:xmpp:message-correct:0", id: versions[0].localId }).up();
+		if (versions.length > 0 && versions[versions.length-1].localId != null) stanza.tag("replace", { xmlns: "urn:xmpp:message-correct:0", id: versions[versions.length-1].localId }).up();
 		if (threadId != null) stanza.textTag("thread", threadId);
 		if (recipients.length > 1) {
 			final addresses = stanza.tag("addresses", { xmlns: "http://jabber.org/protocol/address" });