If group avatar is the same, but URL changed, capture that new URL

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal 2022-05-31 13:35:18 -07:00 committed by GitHub
parent 3cc89eb6db
commit 65f909dfd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 10 deletions

View File

@ -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(