summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/DriveService.ts
diff options
context:
space:
mode:
authornenohi <kimutipartylove@gmail.com>2023-05-05 14:18:06 +0900
committerGitHub <noreply@github.com>2023-05-05 14:18:06 +0900
commit2d84e042405322fc7f9dd5955f9d72f59cdb3a81 (patch)
tree4fc0725045c36b6937c49e363f17be7758c36b64 /packages/backend/src/core/DriveService.ts
parentMerge branch 'develop' of https://github.com/misskey-dev/misskey into develop (diff)
downloadsharkey-2d84e042405322fc7f9dd5955f9d72f59cdb3a81.tar.gz
sharkey-2d84e042405322fc7f9dd5955f9d72f59cdb3a81.tar.bz2
sharkey-2d84e042405322fc7f9dd5955f9d72f59cdb3a81.zip
ロールにNSFWを強制的につけるオプションを追加 (#10731)
* ロールにNSFWを強制的につけるオプションを追加 * すでにあるファイルにNSFWが付与できない * NSFWを付与しようとするとエラーに * add test * Update packages/backend/src/core/RoleService.ts Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * spacingで怒られたので * ロール作成時のプロパティ削除 --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Diffstat (limited to 'packages/backend/src/core/DriveService.ts')
-rw-r--r--packages/backend/src/core/DriveService.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts
index 7f66f1137f..1483b55469 100644
--- a/packages/backend/src/core/DriveService.ts
+++ b/packages/backend/src/core/DriveService.ts
@@ -449,7 +449,12 @@ export class DriveService {
}: AddFileArgs): Promise<DriveFile> {
let skipNsfwCheck = false;
const instance = await this.metaService.fetch();
- if (user == null) skipNsfwCheck = true;
+ const userRoleNSFW = user && (await this.roleService.getUserPolicies(user.id)).alwaysMarkNsfw;
+ if (user == null) {
+ skipNsfwCheck = true;
+ } else if (userRoleNSFW) {
+ skipNsfwCheck = true;
+ }
if (instance.sensitiveMediaDetection === 'none') skipNsfwCheck = true;
if (user && instance.sensitiveMediaDetection === 'local' && this.userEntityService.isRemoteUser(user)) skipNsfwCheck = true;
if (user && instance.sensitiveMediaDetection === 'remote' && this.userEntityService.isLocalUser(user)) skipNsfwCheck = true;
@@ -571,6 +576,7 @@ export class DriveService {
if (info.sensitive && profile!.autoSensitive) file.isSensitive = true;
if (info.sensitive && instance.setSensitiveFlagAutomatically) file.isSensitive = true;
+ if (userRoleNSFW) file.isSensitive = true;
if (url !== null) {
file.src = url;