If group avatar is the same, but URL changed, capture that new URL
This commit is contained in:
parent
6f2b01d98b
commit
fcd0a186e0
1 changed files with 16 additions and 10 deletions
26
ts/groups.ts
26
ts/groups.ts
|
@ -5065,21 +5065,27 @@ export async function applyNewAvatar(
|
||||||
const data = await decryptGroupAvatar(newAvatar, result.secretParams);
|
const data = await decryptGroupAvatar(newAvatar, result.secretParams);
|
||||||
const hash = computeHash(data);
|
const hash = computeHash(data);
|
||||||
|
|
||||||
if (result.avatar && result.avatar.path && result.avatar.hash !== hash) {
|
if (result.avatar?.hash === hash) {
|
||||||
await window.Signal.Migrations.deleteAttachmentData(result.avatar.path);
|
log.info(
|
||||||
result.avatar = undefined;
|
`applyNewAvatar/${logId}: Hash is the same, but url was different. Saving new url.`
|
||||||
}
|
|
||||||
|
|
||||||
if (!result.avatar) {
|
|
||||||
const path = await window.Signal.Migrations.writeNewAttachmentData(
|
|
||||||
data
|
|
||||||
);
|
);
|
||||||
result.avatar = {
|
result.avatar = {
|
||||||
|
...result.avatar,
|
||||||
url: newAvatar,
|
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) {
|
} catch (error) {
|
||||||
log.warn(
|
log.warn(
|
||||||
|
|
Loading…
Add table
Reference in a new issue