Skip to content

Commit

Permalink
Specify recipient IDs for simple chat updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sashaweiss-signal authored Sep 10, 2024
1 parent d659c25 commit 314fa13
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 21 deletions.
56 changes: 46 additions & 10 deletions src/main/kotlin/tests/ChatItemSimpleUpdatesTestCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,54 @@ object ChatItemSimpleUpdatesTestCase : TestCase("chat_item_simple_updates") {
frames += StandardFrames.recipientAlice
frames += StandardFrames.chatAlice

frames += Frame(
chatItem = ChatItem(
chatId = StandardFrames.chatAlice.chat!!.id,
authorId = StandardFrames.recipientAlice.recipient!!.id,
dateSent = someNonZeroTimestamp(),
directionless = ChatItem.DirectionlessMessageDetails(),
updateMessage = ChatUpdateMessage(
simpleUpdate = SimpleChatUpdate(
type = someEnum(SimpleChatUpdate.Type::class.java, excluding = SimpleChatUpdate.Type.UNKNOWN)
// Generate timestamps for as many frames as we might want to add depending
// on simpleChatUpdate. (We need to register the max number of generators
// we might eventually use, up-front.)
val dateSentTimestamps = listOf(someNonZeroTimestamp(), someNonZeroTimestamp())

val simpleChatUpdate = someEnum(SimpleChatUpdate.Type::class.java, excluding = SimpleChatUpdate.Type.UNKNOWN)

val selfRecipientId = StandardFrames.recipientSelf.recipient!!.id
val aliceRecipientId = StandardFrames.recipientAlice.recipient!!.id
val releaseNotesRecipientId = StandardFrames.recipientReleaseNotes.recipient!!.id

// Some simple chat updates can originate from the local user or a remote
// user, while some are necessarily from one or the other.
val authorIds: List<Long> = when (simpleChatUpdate) {
// ...and release note donation requests should come from the release
// notes recipient.
SimpleChatUpdate.Type.RELEASE_CHANNEL_DONATION_REQUEST -> listOf(releaseNotesRecipientId)
SimpleChatUpdate.Type.IDENTITY_UPDATE,
SimpleChatUpdate.Type.IDENTITY_VERIFIED,
SimpleChatUpdate.Type.IDENTITY_DEFAULT,
SimpleChatUpdate.Type.JOINED_SIGNAL,
SimpleChatUpdate.Type.CHANGE_NUMBER -> listOf(aliceRecipientId)
SimpleChatUpdate.Type.CHAT_SESSION_REFRESH,
SimpleChatUpdate.Type.REPORTED_SPAM,
SimpleChatUpdate.Type.BLOCKED,
SimpleChatUpdate.Type.UNBLOCKED,
SimpleChatUpdate.Type.MESSAGE_REQUEST_ACCEPTED -> listOf(selfRecipientId)
SimpleChatUpdate.Type.END_SESSION,
SimpleChatUpdate.Type.BAD_DECRYPT,
SimpleChatUpdate.Type.PAYMENTS_ACTIVATED,
SimpleChatUpdate.Type.PAYMENT_ACTIVATION_REQUEST,
SimpleChatUpdate.Type.UNSUPPORTED_PROTOCOL_MESSAGE -> listOf(selfRecipientId, aliceRecipientId)
// Impossible, checked above.
SimpleChatUpdate.Type.UNKNOWN -> listOf()
}

for ((idx, authorId) in authorIds.withIndex()) {
frames += Frame(
chatItem = ChatItem(
chatId = StandardFrames.chatAlice.chat!!.id,
authorId = authorId,
dateSent = dateSentTimestamps[idx],
directionless = ChatItem.DirectionlessMessageDetails(),
updateMessage = ChatUpdateMessage(
simpleUpdate = SimpleChatUpdate(type = simpleChatUpdate)
)
)
)
)
}
}
}
Binary file modified test-cases/chat_item_simple_updates_05.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/chat_item_simple_updates_05.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 2
chatId = 2
dateSent = 1695248715439
directionless = DirectionlessMessageDetails {}
Expand Down
Binary file modified test-cases/chat_item_simple_updates_06.binproto
Binary file not shown.
16 changes: 15 additions & 1 deletion test-cases/chat_item_simple_updates_06.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 1
chatId = 2
dateSent = 1833527071192
directionless = DirectionlessMessageDetails {}
Expand All @@ -124,4 +124,18 @@ Frame {
}
}
}
}

Frame {
chatItem = ChatItem {
authorId = 4
chatId = 2
dateSent = 1829883016179
directionless = DirectionlessMessageDetails {}
updateMessage = ChatUpdateMessage {
simpleUpdate = SimpleChatUpdate {
type = Type.END_SESSION
}
}
}
}
Binary file modified test-cases/chat_item_simple_updates_07.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/chat_item_simple_updates_07.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 1
chatId = 2
dateSent = 1695248715439
directionless = DirectionlessMessageDetails {}
Expand Down
Binary file modified test-cases/chat_item_simple_updates_08.binproto
Binary file not shown.
16 changes: 15 additions & 1 deletion test-cases/chat_item_simple_updates_08.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 1
chatId = 2
dateSent = 1833527071192
directionless = DirectionlessMessageDetails {}
Expand All @@ -124,4 +124,18 @@ Frame {
}
}
}
}

Frame {
chatItem = ChatItem {
authorId = 4
chatId = 2
dateSent = 1829883016179
directionless = DirectionlessMessageDetails {}
updateMessage = ChatUpdateMessage {
simpleUpdate = SimpleChatUpdate {
type = Type.BAD_DECRYPT
}
}
}
}
Binary file modified test-cases/chat_item_simple_updates_09.binproto
Binary file not shown.
16 changes: 15 additions & 1 deletion test-cases/chat_item_simple_updates_09.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 1
chatId = 2
dateSent = 1695248715439
directionless = DirectionlessMessageDetails {}
Expand All @@ -124,4 +124,18 @@ Frame {
}
}
}
}

Frame {
chatItem = ChatItem {
authorId = 4
chatId = 2
dateSent = 1739546236831
directionless = DirectionlessMessageDetails {}
updateMessage = ChatUpdateMessage {
simpleUpdate = SimpleChatUpdate {
type = Type.PAYMENTS_ACTIVATED
}
}
}
}
Binary file modified test-cases/chat_item_simple_updates_10.binproto
Binary file not shown.
16 changes: 15 additions & 1 deletion test-cases/chat_item_simple_updates_10.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 1
chatId = 2
dateSent = 1833527071192
directionless = DirectionlessMessageDetails {}
Expand All @@ -124,4 +124,18 @@ Frame {
}
}
}
}

Frame {
chatItem = ChatItem {
authorId = 4
chatId = 2
dateSent = 1829883016179
directionless = DirectionlessMessageDetails {}
updateMessage = ChatUpdateMessage {
simpleUpdate = SimpleChatUpdate {
type = Type.PAYMENT_ACTIVATION_REQUEST
}
}
}
}
Binary file modified test-cases/chat_item_simple_updates_11.binproto
Binary file not shown.
16 changes: 15 additions & 1 deletion test-cases/chat_item_simple_updates_11.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 1
chatId = 2
dateSent = 1695248715439
directionless = DirectionlessMessageDetails {}
Expand All @@ -124,4 +124,18 @@ Frame {
}
}
}
}

Frame {
chatItem = ChatItem {
authorId = 4
chatId = 2
dateSent = 1739546236831
directionless = DirectionlessMessageDetails {}
updateMessage = ChatUpdateMessage {
simpleUpdate = SimpleChatUpdate {
type = Type.UNSUPPORTED_PROTOCOL_MESSAGE
}
}
}
}
Binary file modified test-cases/chat_item_simple_updates_12.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/chat_item_simple_updates_12.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 1
chatId = 2
dateSent = 1833527071192
directionless = DirectionlessMessageDetails {}
Expand Down
Binary file modified test-cases/chat_item_simple_updates_13.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/chat_item_simple_updates_13.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 1
chatId = 2
dateSent = 1695248715439
directionless = DirectionlessMessageDetails {}
Expand Down
Binary file modified test-cases/chat_item_simple_updates_14.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/chat_item_simple_updates_14.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 1
chatId = 2
dateSent = 1833527071192
directionless = DirectionlessMessageDetails {}
Expand Down
Binary file modified test-cases/chat_item_simple_updates_15.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/chat_item_simple_updates_15.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Frame {

Frame {
chatItem = ChatItem {
authorId = 4
authorId = 1
chatId = 2
dateSent = 1695248715439
directionless = DirectionlessMessageDetails {}
Expand Down

0 comments on commit 314fa13

Please sign in to comment.