prevent a "always nsfw" user from unmarking their media

This commit is contained in:
dakkar 2024-03-29 19:03:52 +00:00
parent da8b248898
commit a7d19d0c36

View file

@ -632,7 +632,8 @@ export class DriveService {
@bindThis @bindThis
public async updateFile(file: MiDriveFile, values: Partial<MiDriveFile>, updater: MiUser) { public async updateFile(file: MiDriveFile, values: Partial<MiDriveFile>, updater: MiUser) {
const alwaysMarkNsfw = (await this.roleService.getUserPolicies(file.userId)).alwaysMarkNsfw; const profile = await this.userProfilesRepository.findOneBy({ userId: file.userId });
const alwaysMarkNsfw = (await this.roleService.getUserPolicies(file.userId)).alwaysMarkNsfw || (profile !== null && profile!.alwaysMarkNsfw);
if (values.name != null && !this.driveFileEntityService.validateFileName(values.name)) { if (values.name != null && !this.driveFileEntityService.validateFileName(values.name)) {
throw new DriveService.InvalidFileNameError(); throw new DriveService.InvalidFileNameError();