summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/RoleService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/core/RoleService.ts')
-rw-r--r--packages/backend/src/core/RoleService.ts25
1 files changed, 19 insertions, 6 deletions
diff --git a/packages/backend/src/core/RoleService.ts b/packages/backend/src/core/RoleService.ts
index 0210012a03..583eea1a34 100644
--- a/packages/backend/src/core/RoleService.ts
+++ b/packages/backend/src/core/RoleService.ts
@@ -8,6 +8,7 @@ import * as Redis from 'ioredis';
import { In } from 'typeorm';
import { ModuleRef } from '@nestjs/core';
import type {
+ MiMeta,
MiRole,
MiRoleAssignment,
RoleAssignmentsRepository,
@@ -18,7 +19,6 @@ import { MemoryKVCache, MemorySingleCache } from '@/misc/cache.js';
import type { MiUser } from '@/models/User.js';
import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js';
-import { MetaService } from '@/core/MetaService.js';
import { CacheService } from '@/core/CacheService.js';
import type { RoleCondFormulaValue } from '@/models/Role.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
@@ -58,6 +58,11 @@ export type RolePolicies = {
userEachUserListsLimit: number;
rateLimitFactor: number;
avatarDecorationLimit: number;
+ canImportAntennas: boolean;
+ canImportBlocking: boolean;
+ canImportFollowing: boolean;
+ canImportMuting: boolean;
+ canImportUserLists: boolean;
};
export const DEFAULT_POLICIES: RolePolicies = {
@@ -87,6 +92,11 @@ export const DEFAULT_POLICIES: RolePolicies = {
userEachUserListsLimit: 50,
rateLimitFactor: 1,
avatarDecorationLimit: 1,
+ canImportAntennas: true,
+ canImportBlocking: true,
+ canImportFollowing: true,
+ canImportMuting: true,
+ canImportUserLists: true,
};
@Injectable()
@@ -101,8 +111,8 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
constructor(
private moduleRef: ModuleRef,
- @Inject(DI.redis)
- private redisClient: Redis.Redis,
+ @Inject(DI.meta)
+ private meta: MiMeta,
@Inject(DI.redisForTimelines)
private redisForTimelines: Redis.Redis,
@@ -119,7 +129,6 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
@Inject(DI.roleAssignmentsRepository)
private roleAssignmentsRepository: RoleAssignmentsRepository,
- private metaService: MetaService,
private cacheService: CacheService,
private userEntityService: UserEntityService,
private globalEventService: GlobalEventService,
@@ -339,8 +348,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
@bindThis
public async getUserPolicies(userId: MiUser['id'] | null): Promise<RolePolicies> {
- const meta = await this.metaService.fetch();
- const basePolicies = { ...DEFAULT_POLICIES, ...meta.policies };
+ const basePolicies = { ...DEFAULT_POLICIES, ...this.meta.policies };
if (userId == null) return basePolicies;
@@ -387,6 +395,11 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
userEachUserListsLimit: calc('userEachUserListsLimit', vs => Math.max(...vs)),
rateLimitFactor: calc('rateLimitFactor', vs => Math.max(...vs)),
avatarDecorationLimit: calc('avatarDecorationLimit', vs => Math.max(...vs)),
+ canImportAntennas: calc('canImportAntennas', vs => vs.some(v => v === true)),
+ canImportBlocking: calc('canImportBlocking', vs => vs.some(v => v === true)),
+ canImportFollowing: calc('canImportFollowing', vs => vs.some(v => v === true)),
+ canImportMuting: calc('canImportMuting', vs => vs.some(v => v === true)),
+ canImportUserLists: calc('canImportUserLists', vs => vs.some(v => v === true)),
};
}