summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-01-14 18:04:56 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-01-14 18:04:56 +0900
commite46e7f5252582d395f2b8f9db115dabfa26a92a5 (patch)
treedfe5b8b6be3eb0168cc793545190add3d69df080 /packages/backend/src
parentUpdate roles.editor.vue (diff)
downloadsharkey-e46e7f5252582d395f2b8f9db115dabfa26a92a5.tar.gz
sharkey-e46e7f5252582d395f2b8f9db115dabfa26a92a5.tar.bz2
sharkey-e46e7f5252582d395f2b8f9db115dabfa26a92a5.zip
ノートをピン留めできる数を設定可能に
Resolve #9555
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/NotePiningService.ts4
-rw-r--r--packages/backend/src/core/RoleService.ts3
2 files changed, 6 insertions, 1 deletions
diff --git a/packages/backend/src/core/NotePiningService.ts b/packages/backend/src/core/NotePiningService.ts
index f8997574a7..bc038e17a7 100644
--- a/packages/backend/src/core/NotePiningService.ts
+++ b/packages/backend/src/core/NotePiningService.ts
@@ -12,6 +12,7 @@ import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js';
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
import { bindThis } from '@/decorators.js';
+import { RoleService } from '@/core/RoleService.js';
@Injectable()
export class NotePiningService {
@@ -30,6 +31,7 @@ export class NotePiningService {
private userEntityService: UserEntityService,
private idService: IdService,
+ private roleService: RoleService,
private relayService: RelayService,
private apDeliverManagerService: ApDeliverManagerService,
private apRendererService: ApRendererService,
@@ -55,7 +57,7 @@ export class NotePiningService {
const pinings = await this.userNotePiningsRepository.findBy({ userId: user.id });
- if (pinings.length >= 5) {
+ if (pinings.length >= (await this.roleService.getUserRoleOptions(user.id)).pinLimit) {
throw new IdentifiableError('15a018eb-58e5-4da1-93be-330fcc5e4e1a', 'You can not pin notes any more.');
}
diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts
index 0ddcb44ca1..984aef727f 100644
--- a/packages/backend/src/core/RoleService.ts
+++ b/packages/backend/src/core/RoleService.ts
@@ -20,6 +20,7 @@ export type RoleOptions = {
canInvite: boolean;
canManageCustomEmojis: boolean;
driveCapacityMb: number;
+ pinLimit: number;
antennaLimit: number;
wordMuteLimit: number;
webhookLimit: number;
@@ -36,6 +37,7 @@ export const DEFAULT_ROLE: RoleOptions = {
canInvite: false,
canManageCustomEmojis: false,
driveCapacityMb: 100,
+ pinLimit: 5,
antennaLimit: 5,
wordMuteLimit: 200,
webhookLimit: 3,
@@ -211,6 +213,7 @@ export class RoleService implements OnApplicationShutdown {
canInvite: getOptionValues('canInvite').some(x => x === true),
canManageCustomEmojis: getOptionValues('canManageCustomEmojis').some(x => x === true),
driveCapacityMb: Math.max(...getOptionValues('driveCapacityMb')),
+ pinLimit: Math.max(...getOptionValues('pinLimit')),
antennaLimit: Math.max(...getOptionValues('antennaLimit')),
wordMuteLimit: Math.max(...getOptionValues('wordMuteLimit')),
webhookLimit: Math.max(...getOptionValues('webhookLimit')),