From 41d1b1b8c994b2268e4e39d7e46fcbf7807c1ad0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 23 Mar 2023 17:18:38 +0900 Subject: [PATCH] =?UTF-8?q?enhance:=20=E3=82=B3=E3=83=B3=E3=83=87=E3=82=A3?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=8A=E3=83=AB=E3=83=AD=E3=83=BC=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E6=9D=A1=E4=BB=B6=E3=81=AB=E3=80=8C=E6=8A=95=E7=A8=BF?= =?UTF-8?q?=E6=95=B0=E3=81=8C=EF=BD=9E=E4=BB=A5=E4=B8=8B=E3=80=8D=E3=80=8C?= =?UTF-8?q?=E6=8A=95=E7=A8=BF=E6=95=B0=E3=81=8C=EF=BD=9E=E4=BB=A5=E4=B8=8A?= =?UTF-8?q?=E3=80=8D=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve #10395 --- CHANGELOG.md | 2 +- locales/ja-JP.yml | 4 +++- packages/backend/src/core/RoleService.ts | 6 ++++++ packages/backend/src/models/entities/Role.ts | 14 +++++++++++++- .../src/pages/admin/RolesEditorFormula.vue | 6 +++++- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f32284f9..976db8a6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ ## 13.x.x (unreleased) ### General -- +- コンディショナルロールの条件に「投稿数が~以下」「投稿数が~以上」を追加 ### Client - センシティブワードの一覧にピン留めユーザーのIDが表示される問題を修正 diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 2011ca363..36d4a4f2f 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1279,6 +1279,8 @@ _role: followersMoreThanOrEq: "フォロワー数が~以上" followingLessThanOrEq: "フォロー数が~以下" followingMoreThanOrEq: "フォロー数が~以上" + notesLessThanOrEq: "投稿数が~以下" + notesMoreThanOrEq: "投稿数が~以上" and: "~かつ~" or: "~または~" not: "~ではない" @@ -1929,4 +1931,4 @@ _disabledTimeline: _drivecleaner: orderBySizeDesc: "サイズが大きい順" - orderByCreatedAtAsc: "追加日が古い順" \ No newline at end of file + orderByCreatedAtAsc: "追加日が古い順" diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts index 4775196c6..bb7680f4e 100644 --- a/packages/backend/src/core/RoleService.ts +++ b/packages/backend/src/core/RoleService.ts @@ -192,6 +192,12 @@ export class RoleService implements OnApplicationShutdown { case 'followingMoreThanOrEq': { return user.followingCount >= value.value; } + case 'notesLessThanOrEq': { + return user.notesCount <= value.value; + } + case 'notesMoreThanOrEq': { + return user.notesCount >= value.value; + } default: return false; } diff --git a/packages/backend/src/models/entities/Role.ts b/packages/backend/src/models/entities/Role.ts index 85ff26674..eca9bcf27 100644 --- a/packages/backend/src/models/entities/Role.ts +++ b/packages/backend/src/models/entities/Role.ts @@ -54,6 +54,16 @@ type CondFormulaValueFollowingMoreThanOrEq = { value: number; }; +type CondFormulaValueNotesLessThanOrEq = { + type: 'notesLessThanOrEq'; + value: number; +}; + +type CondFormulaValueNotesMoreThanOrEq = { + type: 'notesMoreThanOrEq'; + value: number; +}; + export type RoleCondFormulaValue = CondFormulaValueAnd | CondFormulaValueOr | @@ -65,7 +75,9 @@ export type RoleCondFormulaValue = CondFormulaValueFollowersLessThanOrEq | CondFormulaValueFollowersMoreThanOrEq | CondFormulaValueFollowingLessThanOrEq | - CondFormulaValueFollowingMoreThanOrEq; + CondFormulaValueFollowingMoreThanOrEq | + CondFormulaValueNotesLessThanOrEq | + CondFormulaValueNotesMoreThanOrEq; @Entity() export class Role { diff --git a/packages/frontend/src/pages/admin/RolesEditorFormula.vue b/packages/frontend/src/pages/admin/RolesEditorFormula.vue index 07729b8cf..343d2c4c5 100644 --- a/packages/frontend/src/pages/admin/RolesEditorFormula.vue +++ b/packages/frontend/src/pages/admin/RolesEditorFormula.vue @@ -10,6 +10,8 @@ + + @@ -42,7 +44,7 @@ - + @@ -91,6 +93,8 @@ const type = computed({ if (t === 'followersMoreThanOrEq') v.value.value = 10; if (t === 'followingLessThanOrEq') v.value.value = 10; if (t === 'followingMoreThanOrEq') v.value.value = 10; + if (t === 'notesLessThanOrEq') v.value.value = 10; + if (t === 'notesMoreThanOrEq') v.value.value = 10; v.value.type = t; }, });