mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Store group snapshot attributes in GroupAttributeBlobs.
This commit is contained in:
@@ -430,7 +430,13 @@ class ImportExportTest {
|
|||||||
masterKey = TestRecipientUtils.generateGroupMasterKey().toByteString(),
|
masterKey = TestRecipientUtils.generateGroupMasterKey().toByteString(),
|
||||||
whitelisted = true,
|
whitelisted = true,
|
||||||
hideStory = true,
|
hideStory = true,
|
||||||
storySendMode = Group.StorySendMode.ENABLED
|
storySendMode = Group.StorySendMode.ENABLED,
|
||||||
|
snapshot = Group.GroupSnapshot(
|
||||||
|
title = Group.GroupAttributeBlob(title = "Group Cool"),
|
||||||
|
description = Group.GroupAttributeBlob(descriptionText = "Description"),
|
||||||
|
version = 10,
|
||||||
|
disappearingMessagesTimer = Group.GroupAttributeBlob(disappearingMessagesDuration = 1500000)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
Recipient(
|
Recipient(
|
||||||
@@ -439,7 +445,13 @@ class ImportExportTest {
|
|||||||
masterKey = TestRecipientUtils.generateGroupMasterKey().toByteString(),
|
masterKey = TestRecipientUtils.generateGroupMasterKey().toByteString(),
|
||||||
whitelisted = false,
|
whitelisted = false,
|
||||||
hideStory = false,
|
hideStory = false,
|
||||||
storySendMode = Group.StorySendMode.DEFAULT
|
storySendMode = Group.StorySendMode.DEFAULT,
|
||||||
|
snapshot = Group.GroupSnapshot(
|
||||||
|
title = Group.GroupAttributeBlob(title = "Group Cool"),
|
||||||
|
description = Group.GroupAttributeBlob(descriptionText = "Description"),
|
||||||
|
version = 10,
|
||||||
|
disappearingMessagesTimer = Group.GroupAttributeBlob(disappearingMessagesDuration = 1500000)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -232,7 +232,10 @@ fun RecipientTable.restoreGroupFromBackup(group: Group): RecipientId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val recipientId = writableDatabase.insert(RecipientTable.TABLE_NAME, null, values)
|
val recipientId = writableDatabase.insert(RecipientTable.TABLE_NAME, null, values)
|
||||||
SignalDatabase.groups.create(masterKey, decryptedState)
|
val restoredId = SignalDatabase.groups.create(masterKey, decryptedState)
|
||||||
|
if (restoredId != null) {
|
||||||
|
SignalDatabase.groups.setShowAsStoryState(restoredId, group.storySendMode.toGroupShowAsStoryState())
|
||||||
|
}
|
||||||
|
|
||||||
return RecipientId.from(recipientId)
|
return RecipientId.from(recipientId)
|
||||||
}
|
}
|
||||||
@@ -286,16 +289,16 @@ private fun DecryptedGroup.toSnapshot(): Group.GroupSnapshot? {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return Group.GroupSnapshot(
|
return Group.GroupSnapshot(
|
||||||
title = title,
|
title = Group.GroupAttributeBlob(title = title),
|
||||||
avatar = avatar,
|
avatarUrl = avatar,
|
||||||
disappearingMessagesTimer = disappearingMessagesTimer?.duration ?: 0,
|
disappearingMessagesTimer = Group.GroupAttributeBlob(disappearingMessagesDuration = disappearingMessagesTimer?.duration ?: 0),
|
||||||
accessControl = accessControl?.toSnapshot(),
|
accessControl = accessControl?.toSnapshot(),
|
||||||
version = revision,
|
version = revision,
|
||||||
members = members.map { it.toSnapshot() },
|
members = members.map { it.toSnapshot() },
|
||||||
membersPendingProfileKey = pendingMembers.map { it.toSnapshot() },
|
membersPendingProfileKey = pendingMembers.map { it.toSnapshot() },
|
||||||
membersPendingAdminApproval = requestingMembers.map { it.toSnapshot() },
|
membersPendingAdminApproval = requestingMembers.map { it.toSnapshot() },
|
||||||
inviteLinkPassword = inviteLinkPassword,
|
inviteLinkPassword = inviteLinkPassword,
|
||||||
description = description,
|
description = Group.GroupAttributeBlob(descriptionText = description),
|
||||||
announcements_only = isAnnouncementGroup == EnabledState.ENABLED,
|
announcements_only = isAnnouncementGroup == EnabledState.ENABLED,
|
||||||
members_banned = bannedMembers.map { it.toSnapshot() }
|
members_banned = bannedMembers.map { it.toSnapshot() }
|
||||||
)
|
)
|
||||||
@@ -362,16 +365,16 @@ private fun DecryptedBannedMember.toSnapshot(): Group.MemberBanned {
|
|||||||
|
|
||||||
private fun Group.GroupSnapshot.toDecryptedGroup(operations: GroupsV2Operations.GroupOperations): DecryptedGroup {
|
private fun Group.GroupSnapshot.toDecryptedGroup(operations: GroupsV2Operations.GroupOperations): DecryptedGroup {
|
||||||
return DecryptedGroup(
|
return DecryptedGroup(
|
||||||
title = title,
|
title = title?.title ?: "",
|
||||||
avatar = avatar,
|
avatar = avatarUrl,
|
||||||
disappearingMessagesTimer = DecryptedTimer(duration = disappearingMessagesTimer),
|
disappearingMessagesTimer = DecryptedTimer(duration = disappearingMessagesTimer?.disappearingMessagesDuration ?: 0),
|
||||||
accessControl = accessControl?.toLocal(),
|
accessControl = accessControl?.toLocal(),
|
||||||
revision = version,
|
revision = version,
|
||||||
members = members.map { member -> member.toLocal() },
|
members = members.map { member -> member.toLocal() },
|
||||||
pendingMembers = membersPendingProfileKey.map { pending -> pending.toLocal(operations) },
|
pendingMembers = membersPendingProfileKey.map { pending -> pending.toLocal(operations) },
|
||||||
requestingMembers = membersPendingAdminApproval.map { requesting -> requesting.toLocal() },
|
requestingMembers = membersPendingAdminApproval.map { requesting -> requesting.toLocal() },
|
||||||
inviteLinkPassword = inviteLinkPassword,
|
inviteLinkPassword = inviteLinkPassword,
|
||||||
description = description,
|
description = description?.descriptionText ?: "",
|
||||||
isAnnouncementGroup = if (announcements_only) EnabledState.ENABLED else EnabledState.DISABLED,
|
isAnnouncementGroup = if (announcements_only) EnabledState.ENABLED else EnabledState.DISABLED,
|
||||||
bannedMembers = members_banned.map { it.toLocal() }
|
bannedMembers = members_banned.map { it.toLocal() }
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -142,10 +142,10 @@ message Group {
|
|||||||
// For documentation, defer to Groups.proto. The only name change is Group -> GroupSnapshot to avoid the naming conflict.
|
// For documentation, defer to Groups.proto. The only name change is Group -> GroupSnapshot to avoid the naming conflict.
|
||||||
message GroupSnapshot {
|
message GroupSnapshot {
|
||||||
bytes publicKey = 1;
|
bytes publicKey = 1;
|
||||||
string title = 2;
|
GroupAttributeBlob title = 2;
|
||||||
string description = 11;
|
GroupAttributeBlob description = 11;
|
||||||
string avatar = 3;
|
string avatarUrl = 3;
|
||||||
uint32 disappearingMessagesTimer = 4;
|
GroupAttributeBlob disappearingMessagesTimer = 4;
|
||||||
AccessControl accessControl = 5;
|
AccessControl accessControl = 5;
|
||||||
uint32 version = 6;
|
uint32 version = 6;
|
||||||
repeated Member members = 7;
|
repeated Member members = 7;
|
||||||
@@ -156,6 +156,15 @@ message Group {
|
|||||||
repeated MemberBanned members_banned = 13;
|
repeated MemberBanned members_banned = 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GroupAttributeBlob {
|
||||||
|
oneof content {
|
||||||
|
string title = 1;
|
||||||
|
bytes avatar = 2;
|
||||||
|
uint32 disappearingMessagesDuration = 3;
|
||||||
|
string descriptionText = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
message Member {
|
message Member {
|
||||||
enum Role {
|
enum Role {
|
||||||
UNKNOWN = 0;
|
UNKNOWN = 0;
|
||||||
@@ -179,7 +188,7 @@ message Group {
|
|||||||
message MemberPendingAdminApproval {
|
message MemberPendingAdminApproval {
|
||||||
bytes userId = 1;
|
bytes userId = 1;
|
||||||
bytes profileKey = 2;
|
bytes profileKey = 2;
|
||||||
bytes presentation = 3;
|
reserved /*presentation*/ 3; // The field is deprecated in the context of static group state
|
||||||
uint64 timestamp = 4;
|
uint64 timestamp = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user