git » sdk » commit fe3a711

If direction needs to switch, switch recipients/replyTo also

author Stephen Paul Weber
2025-03-24 16:23:23 UTC
committer Stephen Paul Weber
2025-03-24 16:23:23 UTC
parent 63e94f2f77b42a274e5d60e29b2899f1240ec2d7

If direction needs to switch, switch recipients/replyTo also

snikket/persistence/Sqlite.hx +6 -1

diff --git a/snikket/persistence/Sqlite.hx b/snikket/persistence/Sqlite.hx
index fd66811..f0685d2 100644
--- a/snikket/persistence/Sqlite.hx
+++ b/snikket/persistence/Sqlite.hx
@@ -774,11 +774,16 @@ class Sqlite implements Persistence implements KeyValueStore {
 		return { iterator: () -> rows }.map(row -> ChatMessage.fromStanza(Stanza.parse(row.stanza), accountJid, (builder, _) -> {
 			builder.syncPoint = row.sync_point;
 			builder.timestamp = row.timestamp;
-			builder.direction = row.direction;
 			builder.type = row.type;
 			builder.senderId = row.sender_id;
 			builder.serverId = row.mam_id;
 			builder.serverIdBy = row.mam_by;
+			if (builder.direction != row.direction) {
+				builder.direction = row.direction;
+				final replyTo = builder.replyTo;
+				builder.replyTo = builder.recipients;
+				builder.recipients = replyTo;
+			}
 			if (row.stanza_id != null) builder.localId = row.stanza_id;
 			if (row.versions != null) {
 				final versionTimes: DynamicAccess<String> = Json.parse(row.version_times);