When updating (remote) user avatar/banner, clear usageHint for the previous drivefile, if any

This commit is contained in:
yumeko 2024-04-19 07:25:42 +03:00
parent 4aeb0d95cc
commit 913de651db
No known key found for this signature in database
GPG Key ID: 31A48AD2758B1B53
1 changed files with 5 additions and 0 deletions

View File

@ -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<User>;
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;
}