ロールに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>
This commit is contained in:
nenohi 2023-05-05 14:18:06 +09:00 committed by GitHub
parent be226ec187
commit 2d84e04240
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 144 additions and 6 deletions

View file

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