parent
							
								
									efe530cb17
								
							
						
					
					
						commit
						556e2eba95
					
				
					 2 changed files with 15 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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: {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue