From 5dddc75d09eb28da60b665d9f83f10acfe2a7431 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Wed, 19 Dec 2018 04:23:08 +0900 Subject: [PATCH] Add AP emojis endpoint (#3667) --- src/server/activitypub.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/server/activitypub.ts b/src/server/activitypub.ts index a308c6aae..42d90ab91 100644 --- a/src/server/activitypub.ts +++ b/src/server/activitypub.ts @@ -7,9 +7,11 @@ import { createHttpJob } from '../queue'; import pack from '../remote/activitypub/renderer'; import Note from '../models/note'; import User, { isLocalUser, ILocalUser, IUser } from '../models/user'; +import Emoji from '../models/emoji'; import renderNote from '../remote/activitypub/renderer/note'; import renderKey from '../remote/activitypub/renderer/key'; import renderPerson from '../remote/activitypub/renderer/person'; +import renderEmoji from '../remote/activitypub/renderer/emoji'; import Outbox, { packActivity } from './activitypub/outbox'; import Followers from './activitypub/followers'; import Following from './activitypub/following'; @@ -188,4 +190,21 @@ router.get('/@:user', async (ctx, next) => { }); //#endregion +// emoji +router.get('/emojis/:emoji', async ctx => { + const emoji = await Emoji.findOne({ + host: null, + name: ctx.params.emoji + }); + + if (emoji === null) { + ctx.status = 404; + return; + } + + ctx.body = pack(await renderEmoji(emoji)); + ctx.set('Cache-Control', 'public, max-age=180'); + setResponseType(ctx); +}); + export default router;