Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: センシティブフラグ変更の由来をdrive_fileに持つ #15452

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from

Conversation

samunohito
Copy link
Member

@samunohito samunohito commented Feb 11, 2025

What

モデレータによりセンシティブ設定されたファイルは、ユーザ側から非センシティブ化出来ないようにします。
drive_file.isSensitiveが誰による操作で更新されたかを保持し、以下のすべてを満たす場合はエラーとするようにしました。

  • 非センシティブに変更するとき
  • 変更をかけるアカウントが非モデレータ(ユーザ)のとき
  • センシティブとした理由がモデレータによる操作だったとき

Why

fix #15443

Additional info (optional)

ローカルで以下を動作確認

  • 投稿フォームの添付ファイル部分を右クリック
    • ユーザがセンシティブ設定できる
    • ユーザによりセンシティブ設定されたものはユーザの手で解除できる
    • モデレータによりセンシティブ設定されたものはユーザの手で解除できない
    • 「ファイルにNSFWを常に付与」ポリシーが付与されたユーザは解除できない
    • 「ファイルにNSFWを常に付与」ポリシーが付与されたモデレータは解除できない(自分が投稿するとき)
  • ドライブの詳細ページの👁アイコン
    • ユーザがセンシティブ設定できる
    • ユーザによりセンシティブ設定されたものはユーザの手で解除できる
    • モデレータによりセンシティブ設定されたものはユーザの手で解除できない
    • 「ファイルにNSFWを常に付与」ポリシーが付与されたユーザは解除できない
    • 「ファイルにNSFWを常に付与」ポリシーが付与されたモデレータは解除できない(自分が投稿したもの)
  • ドライブの一覧ページで任意のファイルを右クリック
    • ユーザがセンシティブ設定できる
    • ユーザによりセンシティブ設定されたものはユーザの手で解除できる
    • モデレータによりセンシティブ設定されたものはユーザの手で解除できない
    • 「ファイルにNSFWを常に付与」ポリシーが付与されたユーザは解除できない
    • 「ファイルにNSFWを常に付与」ポリシーが付与されたモデレータは解除できない(自分が投稿したもの)
  • コンパネのファイル一覧
    • モデレータがセンシティブ設定できる
    • ユーザによりセンシティブ設定されたものはモデレータの手で解除できる
    • モデレータによりセンシティブ設定されたものはモデレータの手で解除できる
    • 「ファイルにNSFWを常に付与」ポリシーが付与されたモデレータは解除できない(自分が投稿したもの)
    • 「ファイルにNSFWを常に付与」ポリシーが付与されたモデレータは解除できない(他人が投稿したもの)

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

@github-actions github-actions bot added the packages/backend Server side specific issue/PR label Feb 11, 2025
Copy link
Contributor

github-actions bot commented Feb 11, 2025

このPRによるapi.jsonの差分

差分はこちら
--- base
+++ head
@@ -33774,6 +33774,15 @@
                       }
                     }
                   },
+                  "NSFW_MARKED_BY_MODERATOR": {
+                    "value": {
+                      "error": {
+                        "message": "Cannot be removed because it has been flagged as NSFW by a moderator.",
+                        "code": "NSFW_MARKED_BY_MODERATOR",
+                        "id": "c9ff65ab-c344-d715-f3c8-0c325f852951"
+                      }
+                    }
+                  },
                   "INVALID_PARAM": {
                     "value": {
                       "error": {
@@ -80914,6 +80923,15 @@
           "isSensitive": {
             "type": "boolean"
           },
+          "sensitiveChangeReason": {
+            "type": "string",
+            "enum": [
+              "user",
+              "moderator",
+              "auto",
+              "none"
+            ]
+          },
           "blurhash": {
             "type": [
               "string",
@@ -81005,6 +81023,7 @@
           "md5",
           "size",
           "isSensitive",
+          "sensitiveChangeReason",
           "blurhash",
           "properties",
           "url",

Get diff files from Workflow Page

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

Attention: Patch coverage is 37.60000% with 78 lines in your changes missing coverage. Please review.

Project coverage is 40.33%. Comparing base (cf35208) to head (d1115ef).

Files with missing lines Patch % Lines
packages/backend/src/core/DriveService.ts 19.23% 42 Missing ⚠️
packages/frontend/src/pages/admin-file.vue 0.00% 11 Missing ⚠️
packages/frontend/src/pages/drive.file.info.vue 0.00% 10 Missing ⚠️
...ckages/frontend/src/scripts/get-drive-file-menu.ts 0.00% 10 Missing ⚠️
...end/src/server/api/endpoints/drive/files/update.ts 66.66% 3 Missing ⚠️
...ackend/src/core/entities/DriveFileEntityService.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #15452       +/-   ##
============================================
+ Coverage    18.83%   40.33%   +21.50%     
============================================
  Files          768     1611      +843     
  Lines       111567   210779    +99212     
  Branches      1236     4087     +2851     
============================================
+ Hits         21013    85020    +64007     
- Misses       89963   125117    +35154     
- Partials       591      642       +51     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kakkokari-gtyih kakkokari-gtyih added this to the [DO NOT MERGE THESE YET] v2025.3.0~ milestone Feb 11, 2025
@samunohito samunohito force-pushed the enhance/15443-sensitive-reason branch from 5d133cd to 3e1727d Compare February 11, 2025 08:58
@samunohito samunohito marked this pull request as ready for review February 11, 2025 11:09
@samunohito
Copy link
Member Author

open

@kakkokari-gtyih kakkokari-gtyih modified the milestones: [DO NOT MERGE THESE YET] v2025.3.0~, v2025.2.1 Feb 15, 2025
@kakkokari-gtyih
Copy link
Contributor

バックエンドのe2eのほうのテストがあったほうが良さそう

@kakkokari-gtyih kakkokari-gtyih modified the milestones: v2025.2.1, v2025.3.0 Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment