Delete conversation external files on deletion
This commit is contained in:
parent
2cfbfe477a
commit
f38410976d
2 changed files with 33 additions and 0 deletions
|
@ -123,6 +123,15 @@
|
|||
return this.id === this.ourNumber;
|
||||
},
|
||||
|
||||
async cleanup() {
|
||||
await window.Signal.Types.Conversation.deleteExternalFiles(
|
||||
this.attributes,
|
||||
{
|
||||
deleteAttachmentData,
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
async updateAndMerge(message) {
|
||||
this.updateLastMessage();
|
||||
|
||||
|
|
|
@ -123,7 +123,31 @@ async function migrateConversation(conversation, options = {}) {
|
|||
return upgradeToVersion2(conversation, options);
|
||||
}
|
||||
|
||||
async function deleteExternalFiles(conversation, options = {}) {
|
||||
if (!conversation) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { deleteAttachmentData } = options;
|
||||
if (!isFunction(deleteAttachmentData)) {
|
||||
throw new Error(
|
||||
'Conversation.buildAvatarUpdater: deleteAttachmentData must be a function'
|
||||
);
|
||||
}
|
||||
|
||||
const { avatar, profileAvatar } = conversation;
|
||||
|
||||
if (avatar && avatar.path) {
|
||||
await deleteAttachmentData(avatar.path);
|
||||
}
|
||||
|
||||
if (profileAvatar && profileAvatar.path) {
|
||||
await deleteAttachmentData(profileAvatar.path);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
deleteExternalFiles,
|
||||
migrateConversation,
|
||||
maybeUpdateAvatar,
|
||||
maybeUpdateProfileAvatar,
|
||||
|
|
Loading…
Add table
Reference in a new issue