diff options
| author | Yuriha <121590760+yuriha-chan@users.noreply.github.com> | 2024-02-29 20:48:02 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-29 20:48:02 +0900 |
| commit | 26d4c5fd94638e332b93feed8dff749ab5564d6a (patch) | |
| tree | fc3dc29a6fbb6c41771ba2ab06e7a15fef652f59 /packages/backend/src/core | |
| parent | Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop (diff) | |
| download | misskey-26d4c5fd94638e332b93feed8dff749ab5564d6a.tar.gz misskey-26d4c5fd94638e332b93feed8dff749ab5564d6a.tar.bz2 misskey-26d4c5fd94638e332b93feed8dff749ab5564d6a.zip | |
メンションの最大数をロールごとに設定可能にする (#13343)
* Add new role policy: maximum mentions per note
* fix
* Reviewを反映
* fix
* Add ChangeLog
* Update type definitions
* Add E2E test
* CHANGELOG に説明を追加
---------
Co-authored-by: taichan <40626578+tai-cha@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src/core')
| -rw-r--r-- | packages/backend/src/core/NoteCreateService.ts | 4 | ||||
| -rw-r--r-- | packages/backend/src/core/RoleService.ts | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index b412d5db11..727787f868 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -379,6 +379,10 @@ export class NoteCreateService implements OnApplicationShutdown { } } + if (mentionedUsers.length > 0 && mentionedUsers.length > (await this.roleService.getUserPolicies(user.id)).mentionLimit) { + throw new IdentifiableError('9f466dab-c856-48cd-9e65-ff90ff750580', 'Note contains too many mentions'); + } + const note = await this.insertNote(user, data, tags, emojis, mentionedUsers); setImmediate('post created', { signal: this.#shutdownController.signal }).then( diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts index 8312489a78..09f3097114 100644 --- a/packages/backend/src/core/RoleService.ts +++ b/packages/backend/src/core/RoleService.ts @@ -35,6 +35,7 @@ export type RolePolicies = { gtlAvailable: boolean; ltlAvailable: boolean; canPublicNote: boolean; + mentionLimit: number; canInvite: boolean; inviteLimit: number; inviteLimitCycle: number; @@ -62,6 +63,7 @@ export const DEFAULT_POLICIES: RolePolicies = { gtlAvailable: true, ltlAvailable: true, canPublicNote: true, + mentionLimit: 20, canInvite: false, inviteLimit: 0, inviteLimitCycle: 60 * 24 * 7, @@ -328,6 +330,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit { gtlAvailable: calc('gtlAvailable', vs => vs.some(v => v === true)), ltlAvailable: calc('ltlAvailable', vs => vs.some(v => v === true)), canPublicNote: calc('canPublicNote', vs => vs.some(v => v === true)), + mentionLimit: calc('mentionLimit', vs => Math.max(...vs)), canInvite: calc('canInvite', vs => vs.some(v => v === true)), inviteLimit: calc('inviteLimit', vs => Math.max(...vs)), inviteLimitCycle: calc('inviteLimitCycle', vs => Math.max(...vs)), |