Tombstone unviewed view-once messages in remote backups

This commit is contained in:
Harry 2025-06-17 15:47:54 -07:00 committed by GitHub
parent 704494d902
commit aec46306bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 4 deletions

View File

@ -185,7 +185,7 @@ class BackupArchiveTSMessageContentsArchiver: BackupArchiveProtoStreamWriter {
return archiveViewOnceMessage(
message,
messageRowId: messageRowId,
context: context.recipientContext
context: context
)
} else if message.isStoryReply && !message.isGroupStoryReply {
return archiveDirectStoryReplyMessage(
@ -792,13 +792,16 @@ class BackupArchiveTSMessageContentsArchiver: BackupArchiveProtoStreamWriter {
private func archiveViewOnceMessage(
_ message: TSMessage,
messageRowId: Int64,
context: BackupArchive.RecipientArchivingContext
context: BackupArchive.ChatArchivingContext
) -> ArchiveInteractionResult<ChatItemType> {
var partialErrors = [ArchiveFrameError]()
var proto = BackupProto_ViewOnceMessage()
if !message.isViewOnceComplete {
if
!context.includedContentFilter.shouldTombstoneViewOnce,
!message.isViewOnceComplete
{
let attachmentResult = attachmentsArchiver.archiveBodyAttachments(
messageId: message.uniqueInteractionId,
messageRowId: messageRowId,
@ -827,7 +830,7 @@ class BackupArchiveTSMessageContentsArchiver: BackupArchiveProtoStreamWriter {
let reactions: [BackupProto_Reaction]
let reactionsResult = reactionArchiver.archiveReactions(
message,
context: context
context: context.recipientContext
)
switch reactionsResult.bubbleUp(ChatItemType.self, partialErrors: &partialErrors) {
case .continue(let values):

View File

@ -34,6 +34,10 @@ extension BackupArchive {
/// "lifetime" was.
let minRemainingTimeUntilExpirationMs: UInt64
/// Unviewed view-once messages should be treated as viewed and
/// tombstoned for this export.
let shouldTombstoneViewOnce: Bool
/// Whether or not the plaintext SVR PIN should be included.
let shouldIncludePin: Bool
}

View File

@ -232,6 +232,14 @@ public class BackupArchiveManagerImpl: BackupArchiveManager {
return .dayInMs
}
}(),
shouldTombstoneViewOnce: {
switch backupPurpose {
case .deviceTransfer:
return false
case .remoteBackup:
return true
}
}(),
shouldIncludePin: true
)
@ -268,6 +276,7 @@ public class BackupArchiveManagerImpl: BackupArchiveManager {
let includedContentFilter = BackupArchive.ArchivingContext.IncludedContentFilter(
minExpirationTimeMs: 0,
minRemainingTimeUntilExpirationMs: 0,
shouldTombstoneViewOnce: false,
shouldIncludePin: true
)