summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/ActivityPubServerService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/server/ActivityPubServerService.ts')
-rw-r--r--packages/backend/src/server/ActivityPubServerService.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/packages/backend/src/server/ActivityPubServerService.ts b/packages/backend/src/server/ActivityPubServerService.ts
index bdd2e97508..632a2ccb2e 100644
--- a/packages/backend/src/server/ActivityPubServerService.ts
+++ b/packages/backend/src/server/ActivityPubServerService.ts
@@ -1,3 +1,4 @@
+import { IncomingMessage } from 'node:http';
import { Inject, Injectable } from '@nestjs/common';
import fastifyAccepts from '@fastify/accepts';
import httpSignature from '@peertube/http-signature';
@@ -19,6 +20,7 @@ import { QueryService } from '@/core/QueryService.js';
import { UtilityService } from '@/core/UtilityService.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { bindThis } from '@/decorators.js';
+import { IActivity } from '@/core/activitypub/type.js';
import type { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions } from 'fastify';
import type { FindOptionsWhere } from 'typeorm';
@@ -97,7 +99,8 @@ export class ActivityPubServerService {
return;
}
- this.queueService.inbox(request.body, signature);
+ // TODO: request.bodyのバリデーション?
+ this.queueService.inbox(request.body as IActivity, signature);
reply.code(202);
}
@@ -413,20 +416,21 @@ export class ActivityPubServerService {
@bindThis
public createServer(fastify: FastifyInstance, options: FastifyPluginOptions, done: (err?: Error) => void) {
- fastify.addConstraintStrategy({
+ // addConstraintStrategy の型定義がおかしいため
+ (fastify.addConstraintStrategy as any)({
name: 'apOrHtml',
storage() {
- const store = {};
+ const store = {} as any;
return {
- get(key) {
+ get(key: string) {
return store[key] ?? null;
},
- set(key, value) {
+ set(key: string, value: any) {
store[key] = value;
},
};
},
- deriveConstraint(request, ctx) {
+ deriveConstraint(request: IncomingMessage) {
const accepted = accepts(request).type(['html', ACTIVITY_JSON, LD_JSON]);
const isAp = typeof accepted === 'string' && !accepted.match(/html/);
return isAp ? 'ap' : 'html';