mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-23 03:05:26 +00:00
Add initial support for backup and restore of message and media to staging.
Co-authored-by: Cody Henthorne <cody@signal.org>
This commit is contained in:
@@ -1008,17 +1008,47 @@ class ImportExportTest {
|
||||
attachmentLocator = FilePointer.AttachmentLocator(
|
||||
cdnKey = "coolCdnKey",
|
||||
cdnNumber = 2,
|
||||
uploadTimestamp = System.currentTimeMillis()
|
||||
uploadTimestamp = System.currentTimeMillis(),
|
||||
key = (1..32).map { it.toByte() }.toByteArray().toByteString(),
|
||||
size = 12345,
|
||||
digest = (1..32).map { it.toByte() }.toByteArray().toByteString()
|
||||
),
|
||||
key = (1..32).map { it.toByte() }.toByteArray().toByteString(),
|
||||
contentType = "image/png",
|
||||
size = 12345,
|
||||
fileName = "very_cool_picture.png",
|
||||
width = 100,
|
||||
height = 200,
|
||||
caption = "Love this cool picture!",
|
||||
incrementalMacChunkSize = 0
|
||||
)
|
||||
),
|
||||
wasDownloaded = true
|
||||
),
|
||||
MessageAttachment(
|
||||
pointer = FilePointer(
|
||||
invalidAttachmentLocator = FilePointer.InvalidAttachmentLocator(),
|
||||
contentType = "image/png",
|
||||
width = 100,
|
||||
height = 200,
|
||||
caption = "Love this cool picture! Too bad u cant download it",
|
||||
incrementalMacChunkSize = 0
|
||||
),
|
||||
wasDownloaded = false
|
||||
),
|
||||
MessageAttachment(
|
||||
pointer = FilePointer(
|
||||
backupLocator = FilePointer.BackupLocator(
|
||||
"digestherebutimlazy",
|
||||
cdnNumber = 3,
|
||||
key = (1..32).map { it.toByte() }.toByteArray().toByteString(),
|
||||
digest = (1..64).map { it.toByte() }.toByteArray().toByteString(),
|
||||
size = 12345
|
||||
),
|
||||
contentType = "image/png",
|
||||
width = 100,
|
||||
height = 200,
|
||||
caption = "Love this cool picture! Too bad u cant download it",
|
||||
incrementalMacChunkSize = 0
|
||||
),
|
||||
wasDownloaded = true
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.signal.core.util.ThreadUtil
|
||||
import org.thoughtcrime.securesms.attachments.Cdn
|
||||
import org.thoughtcrime.securesms.attachments.PointerAttachment
|
||||
import org.thoughtcrime.securesms.conversation.v2.ConversationActivity
|
||||
import org.thoughtcrime.securesms.database.MessageType
|
||||
@@ -15,7 +16,6 @@ import org.thoughtcrime.securesms.mms.IncomingMessage
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMessage
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.releasechannel.ReleaseChannel
|
||||
import org.thoughtcrime.securesms.testing.SignalActivityRule
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemoteId
|
||||
@@ -137,7 +137,7 @@ class ConversationItemPreviewer {
|
||||
|
||||
private fun attachment(): SignalServiceAttachmentPointer {
|
||||
return SignalServiceAttachmentPointer(
|
||||
ReleaseChannel.CDN_NUMBER,
|
||||
Cdn.CDN_3.cdnNumber,
|
||||
SignalServiceAttachmentRemoteId.from(""),
|
||||
"image/webp",
|
||||
null,
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.junit.runner.RunWith
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.update
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
||||
import org.thoughtcrime.securesms.attachments.Cdn
|
||||
import org.thoughtcrime.securesms.attachments.PointerAttachment
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable.TransformProperties
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
@@ -742,7 +743,7 @@ class AttachmentTableTest_deduping {
|
||||
assertArrayEquals(lhsAttachment.remoteDigest, rhsAttachment.remoteDigest)
|
||||
assertArrayEquals(lhsAttachment.incrementalDigest, rhsAttachment.incrementalDigest)
|
||||
assertEquals(lhsAttachment.incrementalMacChunkSize, rhsAttachment.incrementalMacChunkSize)
|
||||
assertEquals(lhsAttachment.cdnNumber, rhsAttachment.cdnNumber)
|
||||
assertEquals(lhsAttachment.cdn.cdnNumber, rhsAttachment.cdn.cdnNumber)
|
||||
}
|
||||
|
||||
fun assertDoesNotHaveRemoteFields(attachmentId: AttachmentId) {
|
||||
@@ -751,7 +752,7 @@ class AttachmentTableTest_deduping {
|
||||
assertNull(databaseAttachment.remoteLocation)
|
||||
assertNull(databaseAttachment.remoteDigest)
|
||||
assertNull(databaseAttachment.remoteKey)
|
||||
assertEquals(0, databaseAttachment.cdnNumber)
|
||||
assertEquals(0, databaseAttachment.cdn.cdnNumber)
|
||||
}
|
||||
|
||||
fun assertSkipTransform(attachmentId: AttachmentId, state: Boolean) {
|
||||
@@ -776,7 +777,7 @@ class AttachmentTableTest_deduping {
|
||||
AttachmentTable.TRANSFER_PROGRESS_DONE,
|
||||
databaseAttachment.size, // size
|
||||
null,
|
||||
3, // cdnNumber
|
||||
Cdn.CDN_3, // cdnNumber
|
||||
location,
|
||||
key,
|
||||
digest,
|
||||
|
||||
Reference in New Issue
Block a user