From 44955257058b1f42036a693eba51a0d12b96abd5 Mon Sep 17 00:00:00 2001 From: mei23 Date: Tue, 21 Aug 2018 13:17:37 +0900 Subject: [PATCH] Respect visibility in ActivityPub Note/Outbox --- src/server/activitypub.ts | 5 +++-- src/server/activitypub/outbox.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index c2dec2b997..26eaa68fe8 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -54,7 +54,8 @@ router.get('/notes/:note', async (ctx, next) => { if (!isActivityPubReq(ctx)) return await next(); const note = await Note.findOne({ - _id: new mongo.ObjectID(ctx.params.note) + _id: new mongo.ObjectID(ctx.params.note), + $or: [ { visibility: 'public' }, { visibility: 'home' } ] }); if (note === null) { @@ -62,7 +63,7 @@ router.get('/notes/:note', async (ctx, next) => { return; } - ctx.body = pack(await renderNote(note)); + ctx.body = pack(await renderNote(note, false)); }); // outbox diff --git a/src/server/activitypub/outbox.ts b/src/server/activitypub/outbox.ts index 91473b77e3..71d879e215 100644 --- a/src/server/activitypub/outbox.ts +++ b/src/server/activitypub/outbox.ts @@ -83,7 +83,7 @@ export default async (ctx: Koa.Context) => { if (sinceId) notes.reverse(); - const renderedNotes = await Promise.all(notes.map(note => renderNote(note))); + const renderedNotes = await Promise.all(notes.map(note => renderNote(note, false))); const rendered = renderOrderedCollectionPage( `${partOf}?page=true${sinceId ? `&since_id=${sinceId}` : ''}${untilId ? `&until_id=${untilId}` : ''}`, user.notesCount, renderedNotes, partOf,