mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Remove legacy attachment fields from Backup.proto
This commit is contained in:
committed by
Cody Henthorne
parent
5aeca1deb1
commit
92e1f68c6d
@@ -45,7 +45,7 @@ object CallLinkArchiveImporter {
|
||||
roomId = CallLinkRoomId.fromCallLinkRootKey(rootKey),
|
||||
credentials = CallLinkCredentials(
|
||||
callLink.rootKey.toByteArray(),
|
||||
callLink.epoch.nullIfEmpty()?.toByteArray(),
|
||||
callLink.epoch?.nullIfEmpty()?.toByteArray(),
|
||||
callLink.adminKey?.toByteArray()
|
||||
),
|
||||
state = SignalCallLinkState(
|
||||
|
||||
@@ -8,7 +8,6 @@ package org.thoughtcrime.securesms.backup.v2.util
|
||||
import okio.ByteString
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.Hex
|
||||
import org.signal.core.util.isNotNullOrBlank
|
||||
import org.signal.core.util.nullIfBlank
|
||||
import org.signal.core.util.orNull
|
||||
@@ -138,39 +137,11 @@ fun DatabaseAttachment.toRemoteFilePointer(contentTypeOverride: String? = null):
|
||||
builder.height = this.height.takeIf { it > 0 }
|
||||
builder.caption = this.caption
|
||||
builder.blurHash = this.blurHash?.hash
|
||||
|
||||
builder.setLegacyLocators(this)
|
||||
builder.locatorInfo = this.toLocatorInfo()
|
||||
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
fun FilePointer.Builder.setLegacyLocators(attachment: DatabaseAttachment) {
|
||||
if (attachment.remoteKey.isNullOrBlank() || attachment.remoteDigest == null || attachment.size == 0L) {
|
||||
this.invalidAttachmentLocator = FilePointer.InvalidAttachmentLocator()
|
||||
return
|
||||
}
|
||||
|
||||
if (attachment.transferState == AttachmentTable.TRANSFER_PROGRESS_PERMANENT_FAILURE && attachment.archiveTransferState != AttachmentTable.ArchiveTransferState.FINISHED) {
|
||||
this.invalidAttachmentLocator = FilePointer.InvalidAttachmentLocator()
|
||||
return
|
||||
}
|
||||
|
||||
if (attachment.remoteLocation.isNullOrBlank()) {
|
||||
this.invalidAttachmentLocator = FilePointer.InvalidAttachmentLocator()
|
||||
return
|
||||
}
|
||||
|
||||
this.attachmentLocator = FilePointer.AttachmentLocator(
|
||||
cdnKey = attachment.remoteLocation,
|
||||
cdnNumber = attachment.cdn.cdnNumber,
|
||||
uploadTimestamp = attachment.uploadTimestamp.takeIf { it > 0 }?.clampToValidBackupRange(),
|
||||
key = Base64.decode(attachment.remoteKey).toByteString(),
|
||||
size = attachment.size.toInt(),
|
||||
digest = attachment.remoteDigest.toByteString()
|
||||
)
|
||||
}
|
||||
|
||||
fun DatabaseAttachment.toLocatorInfo(): FilePointer.LocatorInfo {
|
||||
val attachmentType = this.toRemoteAttachmentType()
|
||||
|
||||
@@ -203,9 +174,6 @@ fun DatabaseAttachment.toLocatorInfo(): FilePointer.LocatorInfo {
|
||||
AttachmentType.INVALID -> Unit
|
||||
}
|
||||
|
||||
locatorBuilder.legacyDigest = this.remoteDigest?.toByteString() ?: ByteString.EMPTY
|
||||
locatorBuilder.legacyMediaName = Hex.toStringCondensed(this.remoteDigest ?: byteArrayOf())
|
||||
|
||||
return locatorBuilder.build()
|
||||
}
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ message CallLink {
|
||||
string name = 3;
|
||||
Restrictions restrictions = 4;
|
||||
uint64 expirationMs = 5;
|
||||
bytes epoch = 6; // May be absent/empty for older links
|
||||
optional bytes epoch = 6; // May be absent/empty for older links
|
||||
}
|
||||
|
||||
message AdHocCall {
|
||||
@@ -693,73 +693,12 @@ message MessageAttachment {
|
||||
}
|
||||
|
||||
message FilePointer {
|
||||
// References attachments in the backup (media) storage tier.
|
||||
// DEPRECATED; use LocatorInfo instead if available.
|
||||
message BackupLocator {
|
||||
string mediaName = 1;
|
||||
// If present, the cdn number of the succesful upload.
|
||||
// If empty/0, may still have been uploaded, and clients
|
||||
// can discover the cdn number via the list endpoint.
|
||||
optional uint32 cdnNumber = 2;
|
||||
bytes key = 3;
|
||||
bytes digest = 4;
|
||||
uint32 size = 5;
|
||||
|
||||
// Fallback in case backup tier upload failed.
|
||||
optional string transitCdnKey = 6;
|
||||
optional uint32 transitCdnNumber = 7;
|
||||
}
|
||||
|
||||
// References attachments in the transit storage tier.
|
||||
// May be downloaded or not when the backup is generated;
|
||||
// primarily for free-tier users who cannot copy the
|
||||
// attachments to the backup (media) storage tier.
|
||||
// DEPRECATED; use LocatorInfo instead if available.
|
||||
message AttachmentLocator {
|
||||
string cdnKey = 1;
|
||||
uint32 cdnNumber = 2;
|
||||
optional uint64 uploadTimestamp = 3;
|
||||
bytes key = 4;
|
||||
bytes digest = 5;
|
||||
uint32 size = 6;
|
||||
}
|
||||
|
||||
// References attachments that are invalid in such a way where download
|
||||
// cannot be attempted. Could range from missing digests to missing
|
||||
// CDN keys or anything else that makes download attempts impossible.
|
||||
// This serves as a 'tombstone' so that the UX can show that an attachment
|
||||
// did exist, but for whatever reason it's not retrievable.
|
||||
// DEPRECATED; use LocatorInfo instead if available.
|
||||
message InvalidAttachmentLocator {
|
||||
}
|
||||
|
||||
// References attachments in a local encrypted backup.
|
||||
// Importers should first attempt to read the file from the local backup,
|
||||
// and on failure fallback to backup and transit cdn if possible.
|
||||
// DEPRECATED; use LocatorInfo instead if available.
|
||||
message LocalLocator {
|
||||
string mediaName = 1;
|
||||
// Separate key used to encrypt this file for the local backup.
|
||||
// Generally required. Missing field indicates attachment was not
|
||||
// available locally when the backup was generated, but remote
|
||||
// backup or transit info was available.
|
||||
optional bytes localKey = 2;
|
||||
bytes remoteKey = 3;
|
||||
bytes remoteDigest = 4;
|
||||
uint32 size = 5;
|
||||
optional uint32 backupCdnNumber = 6;
|
||||
optional string transitCdnKey = 7;
|
||||
optional uint32 transitCdnNumber = 8;
|
||||
}
|
||||
|
||||
message LocatorInfo {
|
||||
// Must be non-empty if transitCdnKey or plaintextHash are set/nonempty.
|
||||
// Otherwise must be empty.
|
||||
bytes key = 1;
|
||||
|
||||
// From the sender of the attachment (incl. ourselves)
|
||||
// Will be reserved once all clients start reading integrityCheck
|
||||
bytes legacyDigest = 2;
|
||||
reserved /*legacyDigest*/ 2;
|
||||
|
||||
oneof integrityCheck {
|
||||
// Set if file was at one point downloaded and its plaintextHash was calculated
|
||||
@@ -787,11 +726,7 @@ message FilePointer {
|
||||
// has not rotated since last upload; even if currently free tier.
|
||||
optional uint32 mediaTierCdnNumber = 7;
|
||||
|
||||
// Nonempty any time the attachment was downloaded and its
|
||||
// digest validated, whether free tier or paid subscription.
|
||||
// Will be reserved once all clients start reading integrityCheck,
|
||||
// when mediaName will be derived from the plaintextHash and encryption key
|
||||
string legacyMediaName = 8;
|
||||
reserved /*legacyMediaName*/ 8;
|
||||
|
||||
// Separate key used to encrypt this file for the local backup.
|
||||
// Generally required for local backups.
|
||||
@@ -801,14 +736,10 @@ message FilePointer {
|
||||
optional bytes localKey = 9;
|
||||
}
|
||||
|
||||
// If unset, importers should consider it to be an InvalidAttachmentLocator without throwing an error.
|
||||
// DEPRECATED; use locatorInfo instead.
|
||||
oneof locator {
|
||||
BackupLocator backupLocator = 1;
|
||||
AttachmentLocator attachmentLocator = 2;
|
||||
InvalidAttachmentLocator invalidAttachmentLocator = 3;
|
||||
LocalLocator localLocator = 12;
|
||||
}
|
||||
reserved /*backupLocator*/ 1;
|
||||
reserved /*attachmentLocator*/ 2;
|
||||
reserved /*invalidAttachmentLocator*/ 3;
|
||||
reserved /*localLocator*/ 12;
|
||||
|
||||
optional string contentType = 4;
|
||||
optional bytes incrementalMac = 5;
|
||||
|
||||
Reference in New Issue
Block a user