|
|
@ -90,42 +90,44 @@ public extension DisappearingMessagesJob {
|
|
|
|
// If there were no changes then none of the provided `interactionIds` are expiring messages
|
|
|
|
// If there were no changes then none of the provided `interactionIds` are expiring messages
|
|
|
|
guard (changeCount ?? 0) > 0 else { return nil }
|
|
|
|
guard (changeCount ?? 0) > 0 else { return nil }
|
|
|
|
|
|
|
|
|
|
|
|
interactionsByExpiresInSeconds?.forEach { expiresInSeconds, interactions in
|
|
|
|
if DisappearingMessagesConfiguration.isNewConfigurationEnabled {
|
|
|
|
let serverHashes = interactions.compactMap { $0.serverHash }
|
|
|
|
interactionsByExpiresInSeconds?.forEach { expiresInSeconds, interactions in
|
|
|
|
guard let expiresInSeconds = expiresInSeconds, !serverHashes.isEmpty else { return }
|
|
|
|
let serverHashes = interactions.compactMap { $0.serverHash }
|
|
|
|
|
|
|
|
guard let expiresInSeconds = expiresInSeconds, !serverHashes.isEmpty else { return }
|
|
|
|
let expirationTimestamp: Int64 = Int64(ceil(startedAtMs + expiresInSeconds * 1000))
|
|
|
|
|
|
|
|
let userPublicKey: String = getUserHexEncodedPublicKey(db)
|
|
|
|
let expirationTimestamp: Int64 = Int64(ceil(startedAtMs + expiresInSeconds * 1000))
|
|
|
|
let threadId: String = interactions[0].threadId
|
|
|
|
let userPublicKey: String = getUserHexEncodedPublicKey(db)
|
|
|
|
|
|
|
|
let threadId: String = interactions[0].threadId
|
|
|
|
// Send SyncExpiriesMessage
|
|
|
|
|
|
|
|
let syncTarget: String = interactions[0].authorId
|
|
|
|
// Send SyncExpiriesMessage
|
|
|
|
let syncExpiries: [SyncedExpiriesMessage.SyncedExpiry] = serverHashes.map { serverHash in
|
|
|
|
let syncTarget: String = interactions[0].authorId
|
|
|
|
return SyncedExpiriesMessage.SyncedExpiry(
|
|
|
|
let syncExpiries: [SyncedExpiriesMessage.SyncedExpiry] = serverHashes.map { serverHash in
|
|
|
|
serverHash: serverHash,
|
|
|
|
return SyncedExpiriesMessage.SyncedExpiry(
|
|
|
|
expirationTimestamp: expirationTimestamp)
|
|
|
|
serverHash: serverHash,
|
|
|
|
}
|
|
|
|
expirationTimestamp: expirationTimestamp)
|
|
|
|
|
|
|
|
}
|
|
|
|
let syncExpiriesMessage = SyncedExpiriesMessage(
|
|
|
|
|
|
|
|
conversationExpiries: [syncTarget: syncExpiries]
|
|
|
|
let syncExpiriesMessage = SyncedExpiriesMessage(
|
|
|
|
)
|
|
|
|
conversationExpiries: [syncTarget: syncExpiries]
|
|
|
|
|
|
|
|
|
|
|
|
MessageSender
|
|
|
|
|
|
|
|
.send(
|
|
|
|
|
|
|
|
db,
|
|
|
|
|
|
|
|
message: syncExpiriesMessage,
|
|
|
|
|
|
|
|
threadId: threadId,
|
|
|
|
|
|
|
|
interactionId: nil,
|
|
|
|
|
|
|
|
to: .contact(publicKey: userPublicKey)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Update the ttls
|
|
|
|
MessageSender
|
|
|
|
SnodeAPI.updateExpiry(
|
|
|
|
.send(
|
|
|
|
publicKey: userPublicKey,
|
|
|
|
db,
|
|
|
|
updatedExpiryMs: expirationTimestamp,
|
|
|
|
message: syncExpiriesMessage,
|
|
|
|
serverHashes: serverHashes
|
|
|
|
threadId: threadId,
|
|
|
|
)
|
|
|
|
interactionId: nil,
|
|
|
|
.retainUntilComplete()
|
|
|
|
to: .contact(publicKey: userPublicKey)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update the ttls
|
|
|
|
|
|
|
|
SnodeAPI.updateExpiry(
|
|
|
|
|
|
|
|
publicKey: userPublicKey,
|
|
|
|
|
|
|
|
updatedExpiryMs: expirationTimestamp,
|
|
|
|
|
|
|
|
serverHashes: serverHashes
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.retainUntilComplete()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return updateNextRunIfNeeded(db)
|
|
|
|
return updateNextRunIfNeeded(db)
|
|
|
|