diff --git a/SignalServiceKit/src/Loki/API/Open Groups/LokiPublicChatPoller.swift b/SignalServiceKit/src/Loki/API/Open Groups/LokiPublicChatPoller.swift index 974eb814b..f7cb017c1 100644 --- a/SignalServiceKit/src/Loki/API/Open Groups/LokiPublicChatPoller.swift +++ b/SignalServiceKit/src/Loki/API/Open Groups/LokiPublicChatPoller.swift @@ -150,6 +150,7 @@ public final class LokiPublicChatPoller : NSObject { if !wasSentByCurrentUser { content.setDataMessage(try! dataMessage.build()) } else { + SyncMessagesProtocol.addForceSyncMessageTimestamp(message.timestamp, from: senderHexEncodedPublicKey) let syncMessageSentBuilder = SSKProtoSyncMessageSent.builder() syncMessageSentBuilder.setMessage(try! dataMessage.build()) syncMessageSentBuilder.setDestination(userHexEncodedPublicKey) diff --git a/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift index 5574c8463..868c0774d 100644 --- a/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift +++ b/SignalServiceKit/src/Loki/Protocol/Sync Messages/SyncMessagesProtocol.swift @@ -96,6 +96,15 @@ public final class SyncMessagesProtocol : NSObject { let hexEncodedPublicKey = envelope.source! return LokiDatabaseUtilities.isUserLinkedDevice(hexEncodedPublicKey, transaction: transaction) } + + @objc(addForceSyncMessageTimestamp:from:) + public static func addForceSyncMessageTimestamp(_ timestamp: UInt64, from hexEncodedPublicKey: String) { + var timestamps: Set = syncMessageTimestamps[hexEncodedPublicKey] ?? [] + if timestamps.contains(timestamp) { + timestamps.remove(timestamp) + } + syncMessageTimestamps[hexEncodedPublicKey] = timestamps + } // TODO: We should probably look at why sync messages are being duplicated rather than doing this @objc(isDuplicateSyncMessage:fromHexEncodedPublicKey:)