From 988ac80087a116173ab36043a7a9dd2228d2986c Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Thu, 6 Feb 2020 17:07:37 +0900 Subject: Correct Like id generation (#5852) --- src/server/activitypub.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/server/activitypub.ts') diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index be8a118b9d..c665fe28ca 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -13,10 +13,11 @@ import Following from './activitypub/following'; import Featured from './activitypub/featured'; import { inbox as processInbox } from '../queue'; import { isSelfHost } from '../misc/convert-host'; -import { Notes, Users, Emojis, UserKeypairs } from '../models'; +import { Notes, Users, Emojis, UserKeypairs, NoteReactions } from '../models'; import { ILocalUser, User } from '../models/entities/user'; import { In } from 'typeorm'; import { ensure } from '../prelude/ensure'; +import { renderLike } from '../remote/activitypub/renderer/like'; // Init router const router = new Router(); @@ -202,4 +203,25 @@ router.get('/emojis/:emoji', async ctx => { setResponseType(ctx); }); +// like +router.get('/likes/:like', async ctx => { + const reaction = await NoteReactions.findOne(ctx.params.like); + + if (reaction == null) { + ctx.status = 404; + return; + } + + const note = await Notes.findOne(reaction.noteId); + + if (note == null) { + ctx.status = 404; + return; + } + + ctx.body = renderActivity(await renderLike(reaction, note)); + ctx.set('Cache-Control', 'public, max-age=180'); + setResponseType(ctx); +}); + export default router; -- cgit v1.3.1-freya