resolve a race condition of expireTimerUpdate and configUpdate

pull/941/head
Ryan Zhao 1 year ago
parent d80ac97217
commit a7db4485df

@ -164,7 +164,7 @@ extension MessageReceiver {
guard guard
let localLastChangeTimestampMs = localConfig.lastChangeTimestampMs, let localLastChangeTimestampMs = localConfig.lastChangeTimestampMs,
protoLastChangeTimestampMs > localLastChangeTimestampMs protoLastChangeTimestampMs >= localLastChangeTimestampMs
else { return } else { return }
let durationSeconds: TimeInterval = (proto.hasExpirationTimer ? TimeInterval(proto.expirationTimer) : 0) let durationSeconds: TimeInterval = (proto.hasExpirationTimer ? TimeInterval(proto.expirationTimer) : 0)
@ -180,13 +180,9 @@ extension MessageReceiver {
lastChangeTimestampMs: protoLastChangeTimestampMs lastChangeTimestampMs: protoLastChangeTimestampMs
) )
if localConfig != remoteConfig {
_ = try remoteConfig.save(db) _ = try remoteConfig.save(db)
_ = try Interaction
.filter(Interaction.Columns.threadId == threadId)
.filter(Interaction.Columns.variant == Interaction.Variant.infoDisappearingMessagesUpdate)
.deleteAll(db)
// Contacts & legacy closed groups need to update the SessionUtil // Contacts & legacy closed groups need to update the SessionUtil
switch threadVariant { switch threadVariant {
case .contact: case .contact:
@ -207,6 +203,12 @@ extension MessageReceiver {
default: break default: break
} }
}
_ = try Interaction
.filter(Interaction.Columns.threadId == threadId)
.filter(Interaction.Columns.variant == Interaction.Variant.infoDisappearingMessagesUpdate)
.deleteAll(db)
_ = try Interaction( _ = try Interaction(
serverHash: message.serverHash, serverHash: message.serverHash,

Loading…
Cancel
Save