Skip to content

Commit

Permalink
Tweaks to SMS and Quote messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sashaweiss-signal authored Oct 23, 2024
1 parent 5f510da commit f894061
Show file tree
Hide file tree
Showing 40 changed files with 343 additions and 202 deletions.
19 changes: 10 additions & 9 deletions src/main/kotlin/tests/ChatItemStandardMessageSmsTestCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tests

import PermutationScope
import TestCase
import asList
import org.thoughtcrime.securesms.backup.v2.proto.*

/**
Expand Down Expand Up @@ -37,14 +36,16 @@ object ChatItemStandardMessageSmsTestCase : TestCase("chat_item_standard_message
text = Text(
body = someNonEmptyString()
),
attachments = Generators.permutation<MessageAttachment> {
frames += MessageAttachment(
pointer = some(Generators.smsAttachmentFilePointer()),
flag = MessageAttachment.Flag.NONE,
wasDownloaded = someBoolean(),
clientUuid = null
)
}.asList(0, 1, 5).let { some(it) }
attachments = Generators.lists(listOf(0, 1, 4)) {
Generators.permutation<MessageAttachment> {
frames += MessageAttachment(
pointer = some(Generators.smsAttachmentFilePointer()),
flag = MessageAttachment.Flag.NONE,
wasDownloaded = someBoolean(),
clientUuid = null
)
}
}.let { some(it) }
)
)
)
Expand Down
43 changes: 25 additions & 18 deletions src/main/kotlin/tests/ChatItemStandardMessageWithQuoteTestCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,27 @@ object ChatItemStandardMessageWithQuoteTestCase : TestCase("chat_item_standard_m

checkNotNull(targetMessage.chatItem)

val quoteThumbnailGenerator: Generator<MessageAttachment> = Generators.quoteFilePointer().map { pointer ->
MessageAttachment(
pointer = pointer,
flag = MessageAttachment.Flag.NONE,
wasDownloaded = someBoolean(),
clientUuid = some(Generators.uuids().nullable())?.toByteArray()?.toByteString()
val quoteThumbnail: MessageAttachment = some(
Generators.quoteFilePointer().map { pointer ->
MessageAttachment(
pointer = pointer,
flag = MessageAttachment.Flag.NONE,
wasDownloaded = someBoolean()
)
}
)

val quoteAttachmentContentType: String? = targetMessage.chatItem.stickerMessage?.sticker?.data_?.contentType
?: targetMessage.chatItem.standardMessage?.attachments?.firstOrNull()?.pointer?.contentType

val quoteAttachment: Quote.QuotedAttachment? = if (quoteAttachmentContentType != null) {
Quote.QuotedAttachment(
contentType = quoteAttachmentContentType,
fileName = quoteThumbnail.pointer?.fileName,
thumbnail = quoteThumbnail
)
} else {
null
}

frames += Frame(
Expand All @@ -114,18 +128,11 @@ object ChatItemStandardMessageWithQuoteTestCase : TestCase("chat_item_standard_m
} else {
Quote.Type.NORMAL
},
attachments = quoteThumbnailGenerator
.map { thumbnail ->
val targetContentType = targetMessage.chatItem.stickerMessage?.sticker?.data_?.contentType
?: targetMessage.chatItem.standardMessage?.attachments?.firstOrNull()?.pointer?.contentType
Quote.QuotedAttachment(
contentType = targetContentType,
fileName = thumbnail.pointer?.fileName,
thumbnail = thumbnail.takeUnless { targetContentType == null }
)
}
.map { listOf(it).filter { q -> q.thumbnail != null } }
.let { some(it) }
attachments = if (quoteAttachment != null) {
listOf(quoteAttachment)
} else {
listOf()
}
),
reactions = some(Generators.reactions(2, StandardFrames.recipientSelf.recipient!!, StandardFrames.recipientAlice.recipient))
)
Expand Down
Binary file modified test-cases/chat_item_standard_message_sms_02.binproto
Binary file not shown.
45 changes: 13 additions & 32 deletions test-cases/chat_item_standard_message_sms_02.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ Frame {
sms = true
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
digest = <8a72bebb4db939e0342ae035ddbe7fe4>
key = <d9345fdc5ab1cf72b00738e125ef7370>
mediaName = "8a72bebb4db939e0342ae035ddbe7fe4"
size = 891929939
}
contentType = "image/jpeg"
}
wasDownloaded = true
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
Expand Down Expand Up @@ -180,38 +193,6 @@ Frame {
height = 3329
width = 257
}
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
digest = <8a72bebb4db939e0342ae035ddbe7fe4>
key = <d9345fdc5ab1cf72b00738e125ef7370>
mediaName = "8a72bebb4db939e0342ae035ddbe7fe4"
size = 891929939
}
contentType = "application/pdf"
fileName = "zWWFqaczw"
}
wasDownloaded = true
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
cdnNumber = 2
digest = <6dc1e0cd18b0df35d2dda82a4ffea322>
key = <0a038863ebb03fed8486f4196b6e656c>
mediaName = "6dc1e0cd18b0df35d2dda82a4ffea322"
size = 1267987916
transitCdnKey = "ySkLQGERtwS"
}
blurHash = "LdIOX?NE9Y4T~pRPRjE1X9f5jrt6"
contentType = "image/jpeg"
fileName = "dzHLOokMZPmj"
height = 3188
width = 2674
}
}
]
text = Text {
Expand Down
Binary file modified test-cases/chat_item_standard_message_sms_05.binproto
Binary file not shown.
45 changes: 13 additions & 32 deletions test-cases/chat_item_standard_message_sms_05.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ Frame {
sms = true
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
digest = <8a72bebb4db939e0342ae035ddbe7fe4>
key = <d9345fdc5ab1cf72b00738e125ef7370>
mediaName = "8a72bebb4db939e0342ae035ddbe7fe4"
size = 891929939
}
contentType = "image/jpeg"
}
wasDownloaded = true
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
Expand Down Expand Up @@ -182,38 +195,6 @@ Frame {
height = 3329
width = 257
}
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
digest = <8a72bebb4db939e0342ae035ddbe7fe4>
key = <d9345fdc5ab1cf72b00738e125ef7370>
mediaName = "8a72bebb4db939e0342ae035ddbe7fe4"
size = 891929939
}
contentType = "application/pdf"
fileName = "zWWFqaczw"
}
wasDownloaded = true
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
cdnNumber = 2
digest = <6dc1e0cd18b0df35d2dda82a4ffea322>
key = <0a038863ebb03fed8486f4196b6e656c>
mediaName = "6dc1e0cd18b0df35d2dda82a4ffea322"
size = 1267987916
transitCdnKey = "ySkLQGERtwS"
}
blurHash = "LdIOX?NE9Y4T~pRPRjE1X9f5jrt6"
contentType = "image/jpeg"
fileName = "dzHLOokMZPmj"
height = 3188
width = 2674
}
}
]
text = Text {
Expand Down
Binary file modified test-cases/chat_item_standard_message_sms_08.binproto
Binary file not shown.
45 changes: 13 additions & 32 deletions test-cases/chat_item_standard_message_sms_08.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ Frame {
sms = true
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
digest = <8a72bebb4db939e0342ae035ddbe7fe4>
key = <d9345fdc5ab1cf72b00738e125ef7370>
mediaName = "8a72bebb4db939e0342ae035ddbe7fe4"
size = 891929939
}
contentType = "image/jpeg"
}
wasDownloaded = true
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
Expand Down Expand Up @@ -180,38 +193,6 @@ Frame {
height = 3329
width = 257
}
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
digest = <8a72bebb4db939e0342ae035ddbe7fe4>
key = <d9345fdc5ab1cf72b00738e125ef7370>
mediaName = "8a72bebb4db939e0342ae035ddbe7fe4"
size = 891929939
}
contentType = "application/pdf"
fileName = "zWWFqaczw"
}
wasDownloaded = true
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
cdnNumber = 2
digest = <6dc1e0cd18b0df35d2dda82a4ffea322>
key = <0a038863ebb03fed8486f4196b6e656c>
mediaName = "6dc1e0cd18b0df35d2dda82a4ffea322"
size = 1267987916
transitCdnKey = "ySkLQGERtwS"
}
blurHash = "LdIOX?NE9Y4T~pRPRjE1X9f5jrt6"
contentType = "image/jpeg"
fileName = "dzHLOokMZPmj"
height = 3188
width = 2674
}
}
]
text = Text {
Expand Down
Binary file modified test-cases/chat_item_standard_message_sms_11.binproto
Binary file not shown.
45 changes: 13 additions & 32 deletions test-cases/chat_item_standard_message_sms_11.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ Frame {
sms = true
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
digest = <8a72bebb4db939e0342ae035ddbe7fe4>
key = <d9345fdc5ab1cf72b00738e125ef7370>
mediaName = "8a72bebb4db939e0342ae035ddbe7fe4"
size = 891929939
}
contentType = "image/jpeg"
}
wasDownloaded = true
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
Expand Down Expand Up @@ -180,38 +193,6 @@ Frame {
height = 3329
width = 257
}
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
digest = <8a72bebb4db939e0342ae035ddbe7fe4>
key = <d9345fdc5ab1cf72b00738e125ef7370>
mediaName = "8a72bebb4db939e0342ae035ddbe7fe4"
size = 891929939
}
contentType = "application/pdf"
fileName = "zWWFqaczw"
}
wasDownloaded = true
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
cdnNumber = 2
digest = <6dc1e0cd18b0df35d2dda82a4ffea322>
key = <0a038863ebb03fed8486f4196b6e656c>
mediaName = "6dc1e0cd18b0df35d2dda82a4ffea322"
size = 1267987916
transitCdnKey = "ySkLQGERtwS"
}
blurHash = "LdIOX?NE9Y4T~pRPRjE1X9f5jrt6"
contentType = "image/jpeg"
fileName = "dzHLOokMZPmj"
height = 3188
width = 2674
}
}
]
text = Text {
Expand Down
Binary file modified test-cases/chat_item_standard_message_sms_14.binproto
Binary file not shown.
45 changes: 13 additions & 32 deletions test-cases/chat_item_standard_message_sms_14.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ Frame {
sms = true
standardMessage = StandardMessage {
attachments = [
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
digest = <8a72bebb4db939e0342ae035ddbe7fe4>
key = <d9345fdc5ab1cf72b00738e125ef7370>
mediaName = "8a72bebb4db939e0342ae035ddbe7fe4"
size = 891929939
}
contentType = "image/jpeg"
}
wasDownloaded = true
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
Expand Down Expand Up @@ -182,38 +195,6 @@ Frame {
height = 3329
width = 257
}
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
digest = <8a72bebb4db939e0342ae035ddbe7fe4>
key = <d9345fdc5ab1cf72b00738e125ef7370>
mediaName = "8a72bebb4db939e0342ae035ddbe7fe4"
size = 891929939
}
contentType = "application/pdf"
fileName = "zWWFqaczw"
}
wasDownloaded = true
},
MessageAttachment {
flag = Flag.NONE
pointer = FilePointer {
backupLocator = BackupLocator {
cdnNumber = 2
digest = <6dc1e0cd18b0df35d2dda82a4ffea322>
key = <0a038863ebb03fed8486f4196b6e656c>
mediaName = "6dc1e0cd18b0df35d2dda82a4ffea322"
size = 1267987916
transitCdnKey = "ySkLQGERtwS"
}
blurHash = "LdIOX?NE9Y4T~pRPRjE1X9f5jrt6"
contentType = "image/jpeg"
fileName = "dzHLOokMZPmj"
height = 3188
width = 2674
}
}
]
text = Text {
Expand Down
Binary file modified test-cases/chat_item_standard_message_with_quote_01.binproto
Binary file not shown.
Loading

0 comments on commit f894061

Please sign in to comment.