summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/RelayService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/core/RelayService.ts')
-rw-r--r--packages/backend/src/core/RelayService.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/packages/backend/src/core/RelayService.ts b/packages/backend/src/core/RelayService.ts
index 8dd3d64f5b..ad01f98902 100644
--- a/packages/backend/src/core/RelayService.ts
+++ b/packages/backend/src/core/RelayService.ts
@@ -16,6 +16,8 @@ import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
import { DI } from '@/di-symbols.js';
import { deepClone } from '@/misc/clone.js';
import { bindThis } from '@/decorators.js';
+import { UserKeypairService } from './UserKeypairService.js';
+import type { PrivateKeyWithPem } from '@misskey-dev/node-http-message-signatures';
const ACTOR_USERNAME = 'relay.actor' as const;
@@ -34,6 +36,7 @@ export class RelayService {
private queueService: QueueService,
private createSystemUserService: CreateSystemUserService,
private apRendererService: ApRendererService,
+ private userKeypairService: UserKeypairService,
) {
this.relaysCache = new MemorySingleCache<MiRelay[]>(1000 * 60 * 10);
}
@@ -111,7 +114,7 @@ export class RelayService {
}
@bindThis
- public async deliverToRelays(user: { id: MiUser['id']; host: null; }, activity: any): Promise<void> {
+ public async deliverToRelays(user: { id: MiUser['id']; host: null; }, activity: any, privateKey?: PrivateKeyWithPem): Promise<void> {
if (activity == null) return;
const relays = await this.relaysCache.fetch(() => this.relaysRepository.findBy({
@@ -121,11 +124,9 @@ export class RelayService {
const copy = deepClone(activity);
if (!copy.to) copy.to = ['https://www.w3.org/ns/activitystreams#Public'];
+ privateKey = privateKey ?? await this.userKeypairService.getLocalUserPrivateKeyPem(user.id);
+ const signed = await this.apRendererService.attachLdSignature(copy, privateKey);
- const signed = await this.apRendererService.attachLdSignature(copy, user);
-
- for (const relay of relays) {
- this.queueService.deliver(user, signed, relay.inbox, false);
- }
+ this.queueService.deliverMany(user, signed, new Map(relays.map(({ inbox }) => [inbox, false])), privateKey);
}
}