From 913de651dbb4413728599a1c7df3a646098c750c Mon Sep 17 00:00:00 2001 From: yumeko Date: Fri, 19 Apr 2024 07:25:42 +0300 Subject: [PATCH] When updating (remote) user avatar/banner, clear usageHint for the previous drivefile, if any --- packages/backend/src/remote/activitypub/models/person.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/backend/src/remote/activitypub/models/person.ts b/packages/backend/src/remote/activitypub/models/person.ts index 64a4c7f5c5..5460a0234b 100644 --- a/packages/backend/src/remote/activitypub/models/person.ts +++ b/packages/backend/src/remote/activitypub/models/person.ts @@ -10,6 +10,7 @@ import { Followings, UserProfiles, UserPublickeys, + DriveFiles, } from "@/models/index.js"; import type { IRemoteUser, CacheableUser } from "@/models/entities/user.js"; import { User } from "@/models/entities/user.js"; @@ -561,10 +562,14 @@ export async function updatePerson( } as Partial; if (avatar) { + if (user?.avatarId) + await DriveFiles.update(user.avatarId, {usageHint: null}); updates.avatarId = avatar.id; } if (banner) { + if (user?.bannerId) + await DriveFiles.update(user.bannerId, {usageHint: null}); updates.bannerId = banner.id; }