update expiresInSeconds filter to be safe for negative value

pull/941/head
Ryan Zhao 11 months ago
parent 0eeb4fcd1a
commit e4beb5c794

@ -56,7 +56,7 @@ public extension DisappearingMessagesJob {
// If there is another expiring message then update the job to run 1 second after it's meant to expire
let nextExpirationTimestampMs: Double? = try? Interaction
.filter(Interaction.Columns.expiresStartedAtMs != nil)
.filter(Interaction.Columns.expiresInSeconds > 0)
.filter(Interaction.Columns.expiresInSeconds != 0)
.select(Interaction.Columns.expiresStartedAtMs + (Interaction.Columns.expiresInSeconds * 1000))
.order((Interaction.Columns.expiresStartedAtMs + (Interaction.Columns.expiresInSeconds * 1000)).asc)
.asRequest(of: Double.self)
@ -88,7 +88,7 @@ public extension DisappearingMessagesJob {
.filter(
Interaction.Columns.threadId == threadId &&
Interaction.Columns.timestampMs <= lastReadTimestampMs &&
Interaction.Columns.expiresInSeconds > 0 &&
Interaction.Columns.expiresInSeconds != 0 &&
Interaction.Columns.expiresStartedAtMs == nil
)
.select(
@ -129,7 +129,7 @@ public extension DisappearingMessagesJob {
let interactionExpirationInfosByExpiresInSeconds: [TimeInterval: [ExpirationInfo]] = (try? Interaction
.filter(interactionIds.contains(Interaction.Columns.id))
.filter(
Interaction.Columns.expiresInSeconds > 0 &&
Interaction.Columns.expiresInSeconds != 0 &&
Interaction.Columns.expiresStartedAtMs == nil
)
.select(
@ -146,7 +146,7 @@ public extension DisappearingMessagesJob {
let changeCount: Int? = try? Interaction
.filter(interactionIds.contains(Interaction.Columns.id))
.filter(
Interaction.Columns.expiresInSeconds > 0 &&
Interaction.Columns.expiresInSeconds != 0 &&
Interaction.Columns.expiresStartedAtMs == nil
)
.updateAll(

@ -296,7 +296,7 @@ public enum GarbageCollectionJob: JobExecutor {
/// Remove interactions which should be disappearing after read but never be read within 14 days
if finalTypesToCollect.contains(.expiredUnreadDisappearingMessages) {
_ = try Interaction
.filter(Interaction.Columns.expiresInSeconds > 0)
.filter(Interaction.Columns.expiresInSeconds != 0)
.filter(Interaction.Columns.expiresStartedAtMs == nil)
.filter(Interaction.Columns.timestampMs < (timestampNow - fourteenDaysInSeconds) * 1000)
.deleteAll(db)

Loading…
Cancel
Save