From d5caf22d8c4f1509fed7cb5e3ef5237e24c677fd Mon Sep 17 00:00:00 2001 From: Satsuki Yanagi <17376330+u1-liquid@users.noreply.github.com> Date: Fri, 5 Jul 2019 07:45:00 +0900 Subject: [PATCH] Update Emojis immediately (#5106) --- src/server/api/endpoints/admin/emoji/add.ts | 3 +++ src/server/api/endpoints/admin/emoji/remove.ts | 3 +++ src/server/api/endpoints/admin/emoji/update.ts | 3 +++ src/server/api/endpoints/meta.ts | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/server/api/endpoints/admin/emoji/add.ts b/src/server/api/endpoints/admin/emoji/add.ts index c26e8dd04..5ba00afde 100644 --- a/src/server/api/endpoints/admin/emoji/add.ts +++ b/src/server/api/endpoints/admin/emoji/add.ts @@ -3,6 +3,7 @@ import define from '../../../define'; import { detectUrlMine } from '../../../../../misc/detect-url-mine'; import { Emojis } from '../../../../../models'; import { genId } from '../../../../../misc/gen-id'; +import { getConnection } from 'typeorm'; export const meta = { desc: { @@ -43,6 +44,8 @@ export default define(meta, async (ps) => { type, }); + await getConnection().queryResultCache!.remove(['meta_emojis']); + return { id: emoji.id }; diff --git a/src/server/api/endpoints/admin/emoji/remove.ts b/src/server/api/endpoints/admin/emoji/remove.ts index 316834b88..3ebf933bc 100644 --- a/src/server/api/endpoints/admin/emoji/remove.ts +++ b/src/server/api/endpoints/admin/emoji/remove.ts @@ -2,6 +2,7 @@ import $ from 'cafy'; import define from '../../../define'; import { ID } from '../../../../../misc/cafy-id'; import { Emojis } from '../../../../../models'; +import { getConnection } from 'typeorm'; export const meta = { desc: { @@ -26,4 +27,6 @@ export default define(meta, async (ps) => { if (emoji == null) throw new Error('emoji not found'); await Emojis.delete(emoji.id); + + await getConnection().queryResultCache!.remove(['meta_emojis']); }); diff --git a/src/server/api/endpoints/admin/emoji/update.ts b/src/server/api/endpoints/admin/emoji/update.ts index 48b4a4ee2..f8bc638fc 100644 --- a/src/server/api/endpoints/admin/emoji/update.ts +++ b/src/server/api/endpoints/admin/emoji/update.ts @@ -3,6 +3,7 @@ import define from '../../../define'; import { detectUrlMine } from '../../../../../misc/detect-url-mine'; import { ID } from '../../../../../misc/cafy-id'; import { Emojis } from '../../../../../models'; +import { getConnection } from 'typeorm'; export const meta = { desc: { @@ -47,4 +48,6 @@ export default define(meta, async (ps) => { url: ps.url, type, }); + + await getConnection().queryResultCache!.remove(['meta_emojis']); }); diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index a3390a011..a754a885a 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -95,7 +95,7 @@ export const meta = { export default define(meta, async (ps, me) => { const instance = await fetchMeta(true); - const emojis = await Emojis.find({ where: { host: null }, cache: 3600000 }); // 1 hour + const emojis = await Emojis.find({ where: { host: null }, cache: { id: 'meta_emojis', milliseconds: 3600000 } }); // 1 hour const response: any = { maintainerName: instance.maintainerName,