merge: delete old emoji file when replaced - fixes #608 (!589)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/589

Closes #608

Approved-by: fEmber <acomputerdog@gmail.com>
Approved-by: Marie <marie@kaifa.ch>
This commit is contained in:
dakkar 2024-08-06 10:39:41 +00:00
commit d899eb30b1
1 changed files with 7 additions and 0 deletions

View File

@ -142,6 +142,13 @@ export class CustomEmojiService implements OnApplicationShutdown {
this.localEmojisCache.refresh();
if (data.driveFile != null) {
const file = await this.driveFilesRepository.findOneBy({ url: emoji.originalUrl, userHost: emoji.host ? emoji.host : IsNull() });
if (file && file.id != data.driveFile.id) {
await this.driveService.deleteFile(file, false, moderator ? moderator : undefined);
}
}
const packed = await this.emojiEntityService.packDetailed(emoji.id);
if (emoji.name === data.name) {