From a4fedaf75d1c5a0f0d9cf10abbfbdec90f04e46a Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 13 Jul 2020 09:07:52 +1000 Subject: [PATCH] fix empty avatar being undefined rather than '' building ClosedGroupUpdate message via ts makes it have an avatar content with fields empty if we pass '' as avatar. we wamt no avatar field at all --- js/background.js | 4 ++-- .../content/data/group/ClosedGroupUpdateMessage.ts | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/js/background.js b/js/background.js index 20ec8003f..f1a80de6f 100644 --- a/js/background.js +++ b/js/background.js @@ -700,7 +700,7 @@ return; } - const nullAvatar = ''; + const nullAvatar = undefined; if (avatar) { // would get to download this file on each client in the group // and reference the local file @@ -831,7 +831,7 @@ recipients: allMembers, active: true, expireTimer: 0, - avatar: '', + avatar: undefined, }, confirm: () => {}, }; diff --git a/ts/session/messages/outgoing/content/data/group/ClosedGroupUpdateMessage.ts b/ts/session/messages/outgoing/content/data/group/ClosedGroupUpdateMessage.ts index 612f69eee..0664a0516 100644 --- a/ts/session/messages/outgoing/content/data/group/ClosedGroupUpdateMessage.ts +++ b/ts/session/messages/outgoing/content/data/group/ClosedGroupUpdateMessage.ts @@ -43,6 +43,13 @@ export abstract class ClosedGroupUpdateMessage extends ClosedGroupMessage { throw new Error('admins has not the correct type'); } + if ( + params.avatar !== undefined && + !(params.avatar instanceof SignalService.AttachmentPointer) + ) { + throw new Error('avatar has not the correct type'); + } + this.name = params.name; this.members = params.members; this.admins = params.admins;