spec(ActivityPub): 個別ユーザーのinboxに届いた限定公開のPostはそのユーザーに閲覧権限があると見なす (MisskeyIO#361)

This commit is contained in:
まっちゃとーにゅ 2024-01-16 07:36:34 +09:00 committed by GitHub
parent fd0966bc8c
commit 83bf53c600
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 112 additions and 24 deletions

View file

@ -100,7 +100,8 @@ export class ActivityPubServerService {
}
@bindThis
private inbox(request: FastifyRequest, reply: FastifyReply) {
private async inbox(request: FastifyRequest, reply: FastifyReply) {
const userId = (request.params as { user: string; } | undefined)?.user;
let signature;
try {
@ -162,14 +163,23 @@ export class ActivityPubServerService {
}
}
const user = userId ? await this.usersRepository.findOneBy({
id: userId,
host: IsNull(),
}) : null;
if (userId && user == null) {
reply.code(404);
return;
}
const activity = request.body as IActivity;
if (!activity.type || !signature.keyId) {
reply.code(400);
return;
}
this.queueService.inbox(activity, signature);
await this.queueService.inbox(user, activity, signature);
reply.code(202);
}
@ -553,7 +563,7 @@ export class ActivityPubServerService {
//#region Routing
// inbox (limit: 64kb)
fastify.post('/inbox', { config: { rawBody: true }, bodyLimit: 1024 * 64 }, async (request, reply) => await this.inbox(request, reply));
fastify.post('/users/:user/inbox', { config: { rawBody: true }, bodyLimit: 1024 * 64 }, async (request, reply) => await this.inbox(request, reply));
fastify.post<{ Params: { user: string; }; }>('/users/:user/inbox', { config: { rawBody: true }, bodyLimit: 1024 * 64 }, async (request, reply) => await this.inbox(request, reply));
// note
fastify.get<{ Params: { note: string; } }>('/notes/:note', { constraints: { apOrHtml: 'ap' } }, async (request, reply) => {