Skip to content

Commit

Permalink
Update body and quote attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
sashaweiss-signal authored Sep 16, 2024
1 parent db4744b commit 9ed93dd
Show file tree
Hide file tree
Showing 34 changed files with 89 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package tests

import Generators
import PermutationScope
import TestCase
import asList
import nullable
import okio.ByteString.Companion.toByteString
import org.thoughtcrime.securesms.backup.v2.proto.*
import toByteArray

/**
* Incoming/outgoing messages with standard attachments (i.e. no flags, meaning no voice notes, etc.).
Expand Down Expand Up @@ -43,7 +47,8 @@ object ChatItemStandardMessageStandardAttachmentsTestCase : TestCase("chat_item_
frames += MessageAttachment(
pointer = some(Generators.filePointer()),
flag = MessageAttachment.Flag.NONE,
wasDownloaded = someBoolean()
wasDownloaded = someBoolean(),
clientUuid = some(Generators.uuids().nullable())?.toByteArray()?.toByteString()
)
}.asList(1, 3, 5).let { some(it) },
reactions = some(Generators.reactions(2, StandardFrames.recipientSelf.recipient!!, StandardFrames.recipientAlice.recipient))
Expand Down
30 changes: 20 additions & 10 deletions src/main/kotlin/tests/ChatItemStandardMessageWithQuoteTestCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ object ChatItemStandardMessageWithQuoteTestCase : TestCase("chat_item_standard_m
emoji = "👍",
data_ = FilePointer(
contentType = "image/webp",
// If we update to have a sticker with a valid attachment, the quote
// below should be updated to include a valid thumbnail attachment.
invalidAttachmentLocator = FilePointer.InvalidAttachmentLocator()
)
)
Expand Down Expand Up @@ -97,27 +99,35 @@ object ChatItemStandardMessageWithQuoteTestCase : TestCase("chat_item_standard_m
quote = Quote(
targetSentTimestamp = targetDateSent,
authorId = StandardFrames.recipientAlice.recipient.id,
text = if (targetMessage.chatItem?.standardMessage?.text?.body != null) {
text = if (targetMessage.chatItem!!.standardMessage != null) {
Text(
body = targetMessage.chatItem.standardMessage.text.body,
bodyRanges = if (targetMessage.chatItem?.standardMessage?.text?.bodyRanges != null) {
targetMessage.chatItem.standardMessage.text.bodyRanges
} else {
emptyList()
}
body = targetMessage.chatItem.standardMessage!!.text!!.body,
bodyRanges = targetMessage.chatItem.standardMessage!!.text!!.bodyRanges
)
} else if (targetMessage.chatItem?.contactMessage != null) {
var name = targetMessage.chatItem.contactMessage.contact[0].name
} else if (targetMessage.chatItem!!.contactMessage != null) {
val name = targetMessage.chatItem.contactMessage!!.contact[0].name
Text(
body = "${name!!.givenName} ${name!!.familyName}"
)
} else {
null
},
type = if (targetMessage.chatItem?.giftBadge != null) {
type = if (targetMessage.chatItem!!.giftBadge != null) {
Quote.Type.GIFTBADGE
} else {
Quote.Type.NORMAL
},
attachments = if (targetMessage.chatItem!!.stickerMessage != null) {
// The sole sticker message test case has an invalid attachment,
// so we wouldn't have a proper thumbnail attachment here.
listOf(
Quote.QuotedAttachment(
contentType = "image/png",
fileName = null
)
)
} else {
emptyList()
}
),
reactions = some(Generators.reactions(2, StandardFrames.recipientSelf.recipient!!, StandardFrames.recipientAlice.recipient))
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Frame {
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand Down Expand Up @@ -166,6 +167,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand All @@ -188,7 +190,7 @@ Frame {
Reaction {
authorId = 1
emoji = "💀"
sentTimestamp = 1744320599093
sentTimestamp = 1829195743901
sortOrder = 1
}
]
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
attachmentLocator = AttachmentLocator {
Expand Down Expand Up @@ -182,6 +183,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
blurHash = "LfLh6Voa9NIW?wNF-ooL-;WAX8oy"
Expand Down Expand Up @@ -211,13 +213,13 @@ Frame {
Reaction {
authorId = 4
emoji = "👍"
sentTimestamp = 1744320599094
sentTimestamp = 1829195743902
sortOrder = 2
},
Reaction {
authorId = 1
emoji = "👎"
sentTimestamp = 1744320599095
sentTimestamp = 1829195743903
}
]
text = Text {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Frame {
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand Down Expand Up @@ -187,8 +188,8 @@ Frame {
Reaction {
authorId = 4
emoji = "👍🏾"
sentTimestamp = 1744320599096
sortOrder = 1812737042662
sentTimestamp = 1829195743904
sortOrder = 1813883921501
}
]
text = Text {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Frame {
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
attachmentLocator = AttachmentLocator {
Expand Down Expand Up @@ -169,6 +170,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
blurHash = "LfLh6Voa9NIW?wNF-ooL-;WAX8oy"
Expand All @@ -194,6 +196,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand All @@ -219,13 +222,13 @@ Frame {
Reaction {
authorId = 1
emoji = "👩‍💻"
sentTimestamp = 1744320599097
sortOrder = 1877653162635
sentTimestamp = 1829195743905
sortOrder = 1816975231491
},
Reaction {
authorId = 1
emoji = "💀"
sentTimestamp = 1744320599093
sentTimestamp = 1829195743901
sortOrder = 1
}
]
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Frame {
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand Down Expand Up @@ -164,6 +165,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
attachmentLocator = AttachmentLocator {
Expand All @@ -189,7 +191,7 @@ Frame {
Reaction {
authorId = 4
emoji = "👍"
sentTimestamp = 1744320599094
sentTimestamp = 1829195743902
sortOrder = 2
}
]
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
blurHash = "LfLh6Voa9NIW?wNF-ooL-;WAX8oy"
Expand All @@ -171,6 +172,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand Down Expand Up @@ -217,13 +219,13 @@ Frame {
Reaction {
authorId = 1
emoji = "👎"
sentTimestamp = 1744320599095
sentTimestamp = 1829195743903
},
Reaction {
authorId = 4
emoji = "👍🏾"
sentTimestamp = 1744320599096
sortOrder = 1812737042662
sentTimestamp = 1829195743904
sortOrder = 1813883921501
}
]
text = Text {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Frame {
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
attachmentLocator = AttachmentLocator {
Expand Down Expand Up @@ -187,8 +188,8 @@ Frame {
Reaction {
authorId = 1
emoji = "👩‍💻"
sentTimestamp = 1744320599097
sortOrder = 1877653162635
sentTimestamp = 1829195743905
sortOrder = 1816975231491
}
]
text = Text {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Frame {
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
blurHash = "LfLh6Voa9NIW?wNF-ooL-;WAX8oy"
Expand All @@ -153,6 +154,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand Down Expand Up @@ -195,6 +197,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand All @@ -217,13 +220,13 @@ Frame {
Reaction {
authorId = 1
emoji = "💀"
sentTimestamp = 1744320599093
sentTimestamp = 1829195743901
sortOrder = 1
},
Reaction {
authorId = 4
emoji = "👍"
sentTimestamp = 1744320599094
sentTimestamp = 1829195743902
sortOrder = 2
}
]
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Frame {
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
attachmentLocator = AttachmentLocator {
Expand Down Expand Up @@ -170,6 +171,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
blurHash = "LfLh6Voa9NIW?wNF-ooL-;WAX8oy"
Expand All @@ -186,7 +188,7 @@ Frame {
Reaction {
authorId = 1
emoji = "👎"
sentTimestamp = 1744320599095
sentTimestamp = 1829195743903
}
]
text = Text {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand Down Expand Up @@ -185,6 +186,7 @@ Frame {
wasDownloaded = true
},
MessageAttachment {
clientUuid = <21db7ced72034e348ab2da6e3d8fecb1>
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
Expand Down Expand Up @@ -222,14 +224,14 @@ Frame {
Reaction {
authorId = 4
emoji = "👍🏾"
sentTimestamp = 1744320599096
sortOrder = 1812737042662
sentTimestamp = 1829195743904
sortOrder = 1813883921501
},
Reaction {
authorId = 1
emoji = "👩‍💻"
sentTimestamp = 1744320599097
sortOrder = 1877653162635
sentTimestamp = 1829195743905
sortOrder = 1816975231491
}
]
text = Text {
Expand Down
Binary file modified test-cases/chat_item_standard_message_with_quote_02.binproto
Binary file not shown.
Loading

0 comments on commit 9ed93dd

Please sign in to comment.