From 556e2eba958416860dfed3765025edd85f959b7f Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sat, 16 Mar 2019 09:54:40 +0900 Subject: [PATCH] Resolve #1727 (#4512) --- src/server/activitypub.ts | 13 +++++++++++++ src/server/web/views/note.pug | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index 2151ada34..df5f5b141 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -17,6 +17,7 @@ import Following from './activitypub/following'; import Featured from './activitypub/featured'; import renderQuestion from '../remote/activitypub/renderer/question'; import { inbox as processInbox } from '../queue'; +import { isSelfHost } from '../misc/convert-host'; // Init router const router = new Router(); @@ -79,6 +80,16 @@ router.get('/notes/:note', async (ctx, next) => { return; } + // リモートだったらリダイレクト + if (note._user.host != null) { + if (note.uri == null || isSelfHost(note._user.host)) { + ctx.status = 500; + return; + } + ctx.redirect(note.uri); + return; + } + ctx.body = renderActivity(await renderNote(note, false)); ctx.set('Cache-Control', 'public, max-age=180'); setResponseType(ctx); @@ -93,6 +104,7 @@ router.get('/notes/:note/activity', async ctx => { const note = await Note.findOne({ _id: new ObjectID(ctx.params.note), + '_user.host': null, visibility: { $in: ['public', 'home'] }, localOnly: { $ne: true } }); @@ -116,6 +128,7 @@ router.get('/questions/:question', async (ctx, next) => { const poll = await Note.findOne({ _id: new ObjectID(ctx.params.question), + '_user.host': null, visibility: { $in: ['public', 'home'] }, localOnly: { $ne: true }, poll: { diff --git a/src/server/web/views/note.pug b/src/server/web/views/note.pug index 782a32a50..875d67e2f 100644 --- a/src/server/web/views/note.pug +++ b/src/server/web/views/note.pug @@ -31,3 +31,5 @@ block meta if !user.host link(rel='alternate' href=url type='application/activity+json') + if note.uri + link(rel='alternate' href=note.uri type='application/activity+json')