diff --git a/Signal.xcodeproj/xcshareddata/xcschemes/SignalServiceKit.xcscheme b/Signal.xcodeproj/xcshareddata/xcschemes/SignalServiceKit.xcscheme index f59f3ea89f..c8f473bee4 100644 --- a/Signal.xcodeproj/xcshareddata/xcschemes/SignalServiceKit.xcscheme +++ b/Signal.xcodeproj/xcshareddata/xcschemes/SignalServiceKit.xcscheme @@ -1,7 +1,7 @@ + version = "1.8"> Bool { + guard let serverGuid = decryptedEnvelope.envelope.serverGuid else { + return true + } + return InteractionFinder.existsIncomingMessage( timestamp: decryptedEnvelope.timestamp, sourceAci: decryptedEnvelope.sourceAci, + serverGuid: serverGuid, transaction: tx ) } diff --git a/SignalServiceKit/Storage/Database/Records/InteractionFinder.swift b/SignalServiceKit/Storage/Database/Records/InteractionFinder.swift index 7ec462d1f1..330c316b41 100644 --- a/SignalServiceKit/Storage/Database/Records/InteractionFinder.swift +++ b/SignalServiceKit/Storage/Database/Records/InteractionFinder.swift @@ -48,6 +48,7 @@ public class InteractionFinder: NSObject { public class func existsIncomingMessage( timestamp: UInt64, sourceAci: Aci, + serverGuid: String transaction: SDSAnyReadTransaction ) -> Bool { let sql = """ @@ -55,6 +56,7 @@ public class InteractionFinder: NSObject { SELECT 1 FROM \(InteractionRecord.databaseTableName) WHERE \(interactionColumn: .timestamp) = ? + AND \(interactionColumn: .serverGuid) = ? AND ( \(interactionColumn: .authorUUID) = ? OR ( @@ -67,6 +69,7 @@ public class InteractionFinder: NSObject { let arguments: StatementArguments = [ timestamp, sourceAci.serviceIdUppercaseString, + serverGuid, SignalServiceAddress(sourceAci).phoneNumber ] do {