Skip to content

Commit

Permalink
enhance: コンディショナルロールの条件に「投稿数が~以下」「投稿数が~以上」を追加
Browse files Browse the repository at this point in the history
Resolve #10395
  • Loading branch information
syuilo committed Mar 23, 2023
1 parent 48a97d2 commit 41d1b1b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
## 13.x.x (unreleased)

### General
-
- コンディショナルロールの条件に「投稿数が~以下」「投稿数が~以上」を追加

### Client
- センシティブワードの一覧にピン留めユーザーのIDが表示される問題を修正
Expand Down
4 changes: 3 additions & 1 deletion locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,8 @@ _role:
followersMoreThanOrEq: "フォロワー数が~以上"
followingLessThanOrEq: "フォロー数が~以下"
followingMoreThanOrEq: "フォロー数が~以上"
notesLessThanOrEq: "投稿数が~以下"
notesMoreThanOrEq: "投稿数が~以上"
and: "~かつ~"
or: "~または~"
not: "~ではない"
Expand Down Expand Up @@ -1929,4 +1931,4 @@ _disabledTimeline:

_drivecleaner:
orderBySizeDesc: "サイズが大きい順"
orderByCreatedAtAsc: "追加日が古い順"
orderByCreatedAtAsc: "追加日が古い順"
6 changes: 6 additions & 0 deletions packages/backend/src/core/RoleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 13 additions & 1 deletion packages/backend/src/models/entities/Role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -65,7 +75,9 @@ export type RoleCondFormulaValue =
CondFormulaValueFollowersLessThanOrEq |
CondFormulaValueFollowersMoreThanOrEq |
CondFormulaValueFollowingLessThanOrEq |
CondFormulaValueFollowingMoreThanOrEq;
CondFormulaValueFollowingMoreThanOrEq |
CondFormulaValueNotesLessThanOrEq |
CondFormulaValueNotesMoreThanOrEq;

@Entity()
export class Role {
Expand Down
6 changes: 5 additions & 1 deletion packages/frontend/src/pages/admin/RolesEditorFormula.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<option value="followersMoreThanOrEq">{{ i18n.ts._role._condition.followersMoreThanOrEq }}</option>
<option value="followingLessThanOrEq">{{ i18n.ts._role._condition.followingLessThanOrEq }}</option>
<option value="followingMoreThanOrEq">{{ i18n.ts._role._condition.followingMoreThanOrEq }}</option>
<option value="notesLessThanOrEq">{{ i18n.ts._role._condition.notesLessThanOrEq }}</option>
<option value="notesMoreThanOrEq">{{ i18n.ts._role._condition.notesMoreThanOrEq }}</option>
<option value="and">{{ i18n.ts._role._condition.and }}</option>
<option value="or">{{ i18n.ts._role._condition.or }}</option>
<option value="not">{{ i18n.ts._role._condition.not }}</option>
Expand Down Expand Up @@ -42,7 +44,7 @@
<template #suffix>sec</template>
</MkInput>

<MkInput v-else-if="['followersLessThanOrEq', 'followersMoreThanOrEq', 'followingLessThanOrEq', 'followingMoreThanOrEq'].includes(type)" v-model="v.value" type="number">
<MkInput v-else-if="['followersLessThanOrEq', 'followersMoreThanOrEq', 'followingLessThanOrEq', 'followingMoreThanOrEq', 'notesLessThanOrEq', 'notesMoreThanOrEq'].includes(type)" v-model="v.value" type="number">
</MkInput>
</div>
</template>
Expand Down Expand Up @@ -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;
},
});
Expand Down

0 comments on commit 41d1b1b

Please sign in to comment.