This commit is contained in:
MeiMei 2019-03-16 09:54:40 +09:00 committed by syuilo
parent efe530cb17
commit 556e2eba95
2 changed files with 15 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import Following from './activitypub/following';
import Featured from './activitypub/featured'; import Featured from './activitypub/featured';
import renderQuestion from '../remote/activitypub/renderer/question'; import renderQuestion from '../remote/activitypub/renderer/question';
import { inbox as processInbox } from '../queue'; import { inbox as processInbox } from '../queue';
import { isSelfHost } from '../misc/convert-host';
// Init router // Init router
const router = new Router(); const router = new Router();
@ -79,6 +80,16 @@ router.get('/notes/:note', async (ctx, next) => {
return; 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.body = renderActivity(await renderNote(note, false));
ctx.set('Cache-Control', 'public, max-age=180'); ctx.set('Cache-Control', 'public, max-age=180');
setResponseType(ctx); setResponseType(ctx);
@ -93,6 +104,7 @@ router.get('/notes/:note/activity', async ctx => {
const note = await Note.findOne({ const note = await Note.findOne({
_id: new ObjectID(ctx.params.note), _id: new ObjectID(ctx.params.note),
'_user.host': null,
visibility: { $in: ['public', 'home'] }, visibility: { $in: ['public', 'home'] },
localOnly: { $ne: true } localOnly: { $ne: true }
}); });
@ -116,6 +128,7 @@ router.get('/questions/:question', async (ctx, next) => {
const poll = await Note.findOne({ const poll = await Note.findOne({
_id: new ObjectID(ctx.params.question), _id: new ObjectID(ctx.params.question),
'_user.host': null,
visibility: { $in: ['public', 'home'] }, visibility: { $in: ['public', 'home'] },
localOnly: { $ne: true }, localOnly: { $ne: true },
poll: { poll: {

View File

@ -31,3 +31,5 @@ block meta
if !user.host if !user.host
link(rel='alternate' href=url type='application/activity+json') link(rel='alternate' href=url type='application/activity+json')
if note.uri
link(rel='alternate' href=note.uri type='application/activity+json')