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

View file

@ -10,6 +10,7 @@ import {
Followings, Followings,
UserProfiles, UserProfiles,
UserPublickeys, UserPublickeys,
DriveFiles,
} from "@/models/index.js"; } from "@/models/index.js";
import type { IRemoteUser, CacheableUser } from "@/models/entities/user.js"; import type { IRemoteUser, CacheableUser } from "@/models/entities/user.js";
import { User } from "@/models/entities/user.js"; import { User } from "@/models/entities/user.js";
@ -561,10 +562,14 @@ export async function updatePerson(
} as Partial<User>; } as Partial<User>;
if (avatar) { if (avatar) {
if (user?.avatarId)
await DriveFiles.update(user.avatarId, {usageHint: null});
updates.avatarId = avatar.id; updates.avatarId = avatar.id;
} }
if (banner) { if (banner) {
if (user?.bannerId)
await DriveFiles.update(user.bannerId, {usageHint: null});
updates.bannerId = banner.id; updates.bannerId = banner.id;
} }