refactor: use TRANSIENT scope to avoid service bucket relay (#16985)

* refactor: use TRANSIENT scope to avoid service bucket relay

* lint: fix lints

* refactor: use transient for apResolver

* Update packages/backend/src/core/activitypub/models/ApImageService.ts

* fix
This commit is contained in:
anatawa12
2025-12-22 17:01:10 +09:00
committed by GitHub
parent 06657c81d3
commit 74e847a04d
32 changed files with 398 additions and 713 deletions

View File

@@ -3,14 +3,16 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { Injectable } from '@nestjs/common';
import { Inject, Injectable, Scope } from '@nestjs/common';
import { bindThis } from '@/decorators.js';
import type { GlobalEvents } from '@/core/GlobalEventService.js';
import type { JsonObject } from '@/misc/json-value.js';
import { ChatService } from '@/core/ChatService.js';
import Channel, { type MiChannelService } from '../channel.js';
import Channel, { type ChannelRequest } from '../channel.js';
import { REQUEST } from '@nestjs/core';
class ChatUserChannel extends Channel {
@Injectable({ scope: Scope.TRANSIENT })
export class ChatUserChannel extends Channel {
public readonly chName = 'chatUser';
public static shouldShare = false;
public static requireCredential = true as const;
@@ -18,12 +20,12 @@ class ChatUserChannel extends Channel {
private otherId: string;
constructor(
private chatService: ChatService,
@Inject(REQUEST)
request: ChannelRequest,
id: string,
connection: Channel['connection'],
private chatService: ChatService,
) {
super(id, connection);
super(request);
}
@bindThis
@@ -55,24 +57,3 @@ class ChatUserChannel extends Channel {
this.subscriber.off(`chatUserStream:${this.user!.id}-${this.otherId}`, this.onEvent);
}
}
@Injectable()
export class ChatUserChannelService implements MiChannelService<true> {
public readonly shouldShare = ChatUserChannel.shouldShare;
public readonly requireCredential = ChatUserChannel.requireCredential;
public readonly kind = ChatUserChannel.kind;
constructor(
private chatService: ChatService,
) {
}
@bindThis
public create(id: string, connection: Channel['connection']): ChatUserChannel {
return new ChatUserChannel(
this.chatService,
id,
connection,
);
}
}