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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
55 changed files with 499 additions and 487 deletions

View file

@ -5,9 +5,8 @@
import { Inject, Injectable } from '@nestjs/common';
import { IdService } from '@/core/IdService.js';
import type { SwSubscriptionsRepository } from '@/models/_.js';
import type { MiMeta, SwSubscriptionsRepository } from '@/models/_.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { MetaService } from '@/core/MetaService.js';
import { DI } from '@/di-symbols.js';
import { PushNotificationService } from '@/core/PushNotificationService.js';
@ -62,11 +61,13 @@ export const paramDef = {
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
constructor(
@Inject(DI.meta)
private serverSettings: MiMeta,
@Inject(DI.swSubscriptionsRepository)
private swSubscriptionsRepository: SwSubscriptionsRepository,
private idService: IdService,
private metaService: MetaService,
private pushNotificationService: PushNotificationService,
) {
super(meta, paramDef, async (ps, me) => {
@ -78,12 +79,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
publickey: ps.publickey,
});
const instance = await this.metaService.fetch(true);
if (exist != null) {
return {
state: 'already-subscribed' as const,
key: instance.swPublicKey,
key: this.serverSettings.swPublicKey,
userId: me.id,
endpoint: exist.endpoint,
sendReadMessage: exist.sendReadMessage,
@ -103,7 +102,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
return {
state: 'subscribed' as const,
key: instance.swPublicKey,
key: this.serverSettings.swPublicKey,
userId: me.id,
endpoint: ps.endpoint,
sendReadMessage: ps.sendReadMessage,