Skip to content

Commit

Permalink
My Story and Group recipient updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sashaweiss-signal authored Sep 18, 2024
1 parent 17c5ea9 commit 362d845
Show file tree
Hide file tree
Showing 609 changed files with 688 additions and 402 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/StandardFrames.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object StandardFrames {
distributionList = DistributionListItem(
distributionId = MY_STORY_UUID,
distributionList = DistributionList(
name = "My Story",
name = "",
privacyMode = DistributionList.PrivacyMode.ALL
)
)
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/tests/RecipientDistributionListTestCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ object RecipientDistributionListTestCase : TestCase("recipient_distribution_list
val memberRecipientIds = some(memberRecipientIdGenerator)

frames += DistributionList(
name = someNonEmptyString(),
// Empty name specifically for My Story, which has a localized name
// built into clients.
name = "",
allowReplies = someBoolean(),
memberRecipientIds = if (privacyMode == DistributionList.PrivacyMode.ALL) {
emptyList()
Expand Down
144 changes: 78 additions & 66 deletions src/main/kotlin/tests/RecipientGroupsTestCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import TestCase
import asList
import map
import okio.ByteString.Companion.toByteString
import org.thoughtcrime.securesms.backup.v2.proto.Contact
import org.thoughtcrime.securesms.backup.v2.proto.Frame
import org.thoughtcrime.securesms.backup.v2.proto.Group
import org.thoughtcrime.securesms.backup.v2.proto.Recipient
import org.thoughtcrime.securesms.backup.v2.proto.*

/**
* Every reasonable permutation of Recipient.Group
Expand All @@ -26,77 +23,92 @@ object RecipientGroupsTestCase : TestCase("recipient_groups") {
frames += StandardFrames.recipientEve
frames += StandardFrames.recipientFrank

val groupRecipientId = 10L

val snapshot: Group.GroupSnapshot = somePermutation {
frames += Group.GroupSnapshot(
title = Group.GroupAttributeBlob(
title = someNonEmptyString()
),
description = someNullablePermutation {
frames += Group.GroupAttributeBlob(
descriptionText = someNonEmptyString()
)
},
avatarUrl = someUrl(),
disappearingMessagesTimer = someNullablePermutation {
frames += Group.GroupAttributeBlob(
disappearingMessagesDuration = somePositiveInt()
)
},
accessControl = Group.AccessControl(
attributes = someEnum(Group.AccessControl.AccessRequired::class.java, Group.AccessControl.AccessRequired.UNKNOWN, Group.AccessControl.AccessRequired.ANY, Group.AccessControl.AccessRequired.UNSATISFIABLE),
members = someEnum(Group.AccessControl.AccessRequired::class.java, Group.AccessControl.AccessRequired.UNKNOWN, Group.AccessControl.AccessRequired.ANY, Group.AccessControl.AccessRequired.UNSATISFIABLE),
addFromInviteLink = someEnum(Group.AccessControl.AccessRequired::class.java, Group.AccessControl.AccessRequired.UNKNOWN, Group.AccessControl.AccessRequired.ANY, Group.AccessControl.AccessRequired.MEMBER)
),
version = somePositiveInt(),
members = Generators.permutation<Group.Member> {
val userGenerator: Generator<Contact> = Generators.list(StandardFrames.recipientAlice.recipient!!.contact!!, StandardFrames.recipientBob.recipient!!.contact!!, StandardFrames.recipientCarol.recipient!!.contact!!)
val user = some(userGenerator)
frames += Group.Member(
userId = user.aci!!,
role = someEnum(Group.Member.Role::class.java, excluding = Group.Member.Role.UNKNOWN)
)
}.asList(1, 2, 3).map { members ->
members + Group.Member(
userId = StandardFrames.SELF_ACI.toByteString(),
role = Group.Member.Role.DEFAULT
)
}.let { some(it) },
membersPendingProfileKey = Generators.permutation<Group.MemberPendingProfileKey> {
frames += Group.MemberPendingProfileKey(
member = Group.Member(
userId = StandardFrames.recipientDan.recipient!!.contact!!.aci!!,
role = Group.Member.Role.DEFAULT
),
addedByUserId = StandardFrames.recipientAlice.recipient!!.contact!!.aci!!
)
}.asList(0, 1).let { some(it) },
membersPendingAdminApproval = Generators.permutation<Group.MemberPendingAdminApproval> {
frames += Group.MemberPendingAdminApproval(
userId = StandardFrames.recipientEve.recipient!!.contact!!.aci!!
)
}.asList(0, 1).let { some(it) },
members_banned = Generators.permutation<Group.MemberBanned> {
frames += Group.MemberBanned(
userId = StandardFrames.recipientFrank.recipient!!.contact!!.aci!!,
timestamp = someIncrementingTimestamp()
)
}.asList(0, 1).let { some(it) },
inviteLinkPassword = someBytes(32).toByteString(),
announcements_only = someBoolean()
)
}

frames += Frame(
recipient = Recipient(
id = 10,
id = groupRecipientId,
group = Group(
masterKey = someBytes(32).toByteString(),
whitelisted = someBoolean(),
hideStory = someBoolean(),
storySendMode = someEnum(Group.StorySendMode::class.java),
snapshot = somePermutation {
frames += Group.GroupSnapshot(
title = Group.GroupAttributeBlob(
title = someNonEmptyString()
),
description = someNullablePermutation {
frames += Group.GroupAttributeBlob(
descriptionText = someNonEmptyString()
)
},
avatarUrl = someUrl(),
disappearingMessagesTimer = somePermutation {
frames += Group.GroupAttributeBlob(
disappearingMessagesDuration = somePositiveInt()
)
},
accessControl = Group.AccessControl(
attributes = someEnum(Group.AccessControl.AccessRequired::class.java, Group.AccessControl.AccessRequired.UNKNOWN, Group.AccessControl.AccessRequired.ANY, Group.AccessControl.AccessRequired.UNSATISFIABLE),
members = someEnum(Group.AccessControl.AccessRequired::class.java, Group.AccessControl.AccessRequired.UNKNOWN, Group.AccessControl.AccessRequired.ANY, Group.AccessControl.AccessRequired.UNSATISFIABLE),
addFromInviteLink = someEnum(Group.AccessControl.AccessRequired::class.java, Group.AccessControl.AccessRequired.UNKNOWN, Group.AccessControl.AccessRequired.ANY, Group.AccessControl.AccessRequired.MEMBER)
),
version = somePositiveInt(),
members = Generators.permutation<Group.Member> {
val userGenerator: Generator<Contact> = Generators.list(StandardFrames.recipientAlice.recipient!!.contact!!, StandardFrames.recipientBob.recipient!!.contact!!, StandardFrames.recipientCarol.recipient!!.contact!!)
val user = some(userGenerator)
frames += Group.Member(
userId = user.aci!!,
role = someEnum(Group.Member.Role::class.java, excluding = Group.Member.Role.UNKNOWN)
)
}.asList(1, 2, 3).map { members ->
members + Group.Member(
userId = StandardFrames.SELF_ACI.toByteString(),
role = Group.Member.Role.DEFAULT
)
}.let { some(it) },
membersPendingProfileKey = Generators.permutation<Group.MemberPendingProfileKey> {
frames += Group.MemberPendingProfileKey(
member = Group.Member(
userId = StandardFrames.recipientDan.recipient!!.contact!!.aci!!,
role = Group.Member.Role.DEFAULT
),
addedByUserId = StandardFrames.recipientAlice.recipient!!.contact!!.aci!!,
timestamp = someIncrementingTimestamp()
)
}.asList(0, 1).let { some(it) },
membersPendingAdminApproval = Generators.permutation<Group.MemberPendingAdminApproval> {
frames += Group.MemberPendingAdminApproval(
userId = StandardFrames.recipientEve.recipient!!.contact!!.aci!!,
timestamp = someIncrementingTimestamp()
)
}.asList(0, 1).let { some(it) },
members_banned = Generators.permutation<Group.MemberBanned> {
frames += Group.MemberBanned(
userId = StandardFrames.recipientFrank.recipient!!.contact!!.aci!!,
timestamp = someIncrementingTimestamp()
)
}.asList(0, 1).let { some(it) },
inviteLinkPassword = someBytes(32).toByteString(),
announcements_only = someBoolean()
)
}
snapshot = snapshot
)
)
)

frames += Frame(
chat = Chat(
id = 1,
recipientId = groupRecipientId,
expirationTimerMs = if (snapshot.disappearingMessagesTimer != null) {
snapshot.disappearingMessagesTimer!!.disappearingMessagesDuration!!.toLong() * 1000
} else {
0
},
expireTimerVersion = 1
)
)
}
}
Binary file modified test-cases/account_data_00.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_00.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_01.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_01.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_02.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_02.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_03.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_03.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_04.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_04.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_05.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_05.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_06.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_06.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_07.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_07.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_08.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_08.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_09.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_09.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_10.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_10.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_11.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_11.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_12.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_12.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_13.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_13.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_14.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_14.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_15.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_15.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_16.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_16.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_17.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_17.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_18.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_18.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_19.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_19.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_20.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_20.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_21.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_21.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_22.binproto
Binary file not shown.
2 changes: 1 addition & 1 deletion test-cases/account_data_22.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Frame {
distributionList = DistributionListItem {
distributionId = <00000000000000000000000000000000>
distributionList = DistributionList {
name = "My Story"
name = ""
privacyMode = PrivacyMode.ALL
}
}
Expand Down
Binary file modified test-cases/account_data_23.binproto
Binary file not shown.
Loading

0 comments on commit 362d845

Please sign in to comment.