From da8b248898701f55dfe8e4eaa896857ecb3b0a22 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 29 Mar 2024 18:40:21 +0000 Subject: [PATCH 1/2] set the correct "marked an NSFW" when loading admin-user --- packages/frontend/src/pages/admin-user.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/frontend/src/pages/admin-user.vue b/packages/frontend/src/pages/admin-user.vue index 3beaf5d08..52272e736 100644 --- a/packages/frontend/src/pages/admin-user.vue +++ b/packages/frontend/src/pages/admin-user.vue @@ -265,6 +265,7 @@ function createFetcher() { moderator.value = info.value.isModerator; silenced.value = info.value.isSilenced; approved.value = info.value.approved; + markedAsNSFW.value = info.value.alwaysMarkNsfw; suspended.value = info.value.isSuspended; moderationNote.value = info.value.moderationNote; From a7d19d0c367c497cf2a3c9fd02e11d68b1fc689c Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 29 Mar 2024 19:03:52 +0000 Subject: [PATCH 2/2] prevent a "always nsfw" user from unmarking their media --- packages/backend/src/core/DriveService.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index f64568ee9..4203b03c7 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -632,7 +632,8 @@ export class DriveService { @bindThis public async updateFile(file: MiDriveFile, values: Partial, 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)) { throw new DriveService.InvalidFileNameError();