refactor/perf(backend): provide metadata statically (#14601)

* wip

* Update ReactionService.ts

* Update ApiCallService.ts

* Update timeline.ts

* Update GlobalModule.ts

* Update GlobalModule.ts

* Update NoteEntityService.ts

* wip

* wip

* wip

* Update ApPersonService.ts

* wip

* Update GlobalModule.ts

* Update mock-resolver.ts

* Update RoleService.ts

* Update activitypub.ts

* Update activitypub.ts

* Update activitypub.ts

* Update activitypub.ts

* Update activitypub.ts

* clean up

* Update utils.ts

* Update UtilityService.ts

* Revert "Update utils.ts"

This reverts commit a27d4be764.

* Revert "Update UtilityService.ts"

This reverts commit e5fd9e004c.

* vuwa-

* Revert "vuwa-"

This reverts commit 0c3bd12472.

* Update entry.ts

* Update entry.ts

* Update entry.ts

* Update entry.ts

* Update jest.setup.ts
This commit is contained in:
syuilo
2024-09-22 12:53:13 +09:00
committed by GitHub
parent 3ad5c753fa
commit 023fa30280
55 changed files with 499 additions and 487 deletions

View File

@@ -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';
@@ -111,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,
@@ -129,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,
@@ -349,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;