From 8bcf3addc7d3c3bba6f50aba36f8bc1f162791f1 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Wed, 21 Jul 2021 13:58:39 -0400 Subject: [PATCH] Adds announcement group change decryption --- ts/groups.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/ts/groups.ts b/ts/groups.ts index 8a91130ff006..71758bdadc9a 100644 --- a/ts/groups.ts +++ b/ts/groups.ts @@ -3897,7 +3897,7 @@ function extractDiffs({ // announcementsOnly - if (old.announcementsOnly !== current.announcementsOnly) { + if (Boolean(old.announcementsOnly) !== Boolean(current.announcementsOnly)) { details.push({ type: 'announcements-only', announcementsOnly: Boolean(current.announcementsOnly), @@ -4525,6 +4525,11 @@ async function applyGroupChange({ } } + if (actions.modifyAnnouncementsOnly) { + const { announcementsOnly } = actions.modifyAnnouncementsOnly; + result.announcementsOnly = announcementsOnly; + } + if (ourConversationId) { result.left = !members[ourConversationId]; } @@ -4810,6 +4815,9 @@ async function applyGroupState({ result.description = undefined; } + // announcementsOnly + result.announcementsOnly = groupState.announcementsOnly; + return { newAttributes: result, newProfileKeys, @@ -4916,6 +4924,9 @@ type DecryptedGroupChangeActions = { modifyDescription?: { descriptionBytes?: Proto.GroupAttributeBlob; }; + modifyAnnouncementsOnly?: { + announcementsOnly: boolean; + }; } & Pick< Proto.GroupChange.IActions, | 'modifyAttributesAccess' @@ -5433,6 +5444,14 @@ function decryptGroupChange( } } + // modifyAnnouncementsOnly + if (actions.modifyAnnouncementsOnly) { + const { announcementsOnly } = actions.modifyAnnouncementsOnly; + result.modifyAnnouncementsOnly = { + announcementsOnly: Boolean(announcementsOnly), + }; + } + return result; } @@ -5490,6 +5509,7 @@ type DecryptedGroupState = { inviteLinkPassword?: string; descriptionBytes?: Proto.GroupAttributeBlob; avatar?: string; + announcementsOnly?: boolean; }; function decryptGroupState( @@ -5621,6 +5641,10 @@ function decryptGroupState( } } + // announcementsOnly + const { announcementsOnly } = groupState; + result.announcementsOnly = Boolean(announcementsOnly); + result.avatar = dropNull(groupState.avatar); return result;