From fcd0a186e03eebe7a359d9e74e87b7d5a22b6be9 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg <scott@signal.org> Date: Tue, 31 May 2022 09:27:03 -0700 Subject: [PATCH] If group avatar is the same, but URL changed, capture that new URL --- ts/groups.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/ts/groups.ts b/ts/groups.ts index a0d84d918e9..d037a434384 100644 --- a/ts/groups.ts +++ b/ts/groups.ts @@ -5065,21 +5065,27 @@ export async function applyNewAvatar( const data = await decryptGroupAvatar(newAvatar, result.secretParams); const hash = computeHash(data); - if (result.avatar && result.avatar.path && result.avatar.hash !== hash) { - await window.Signal.Migrations.deleteAttachmentData(result.avatar.path); - result.avatar = undefined; - } - - if (!result.avatar) { - const path = await window.Signal.Migrations.writeNewAttachmentData( - data + if (result.avatar?.hash === hash) { + log.info( + `applyNewAvatar/${logId}: Hash is the same, but url was different. Saving new url.` ); result.avatar = { + ...result.avatar, url: newAvatar, - path, - hash, }; + return; } + + if (result.avatar) { + await window.Signal.Migrations.deleteAttachmentData(result.avatar.path); + } + + const path = await window.Signal.Migrations.writeNewAttachmentData(data); + result.avatar = { + url: newAvatar, + path, + hash, + }; } } catch (error) { log.warn(