From 819b535ab08d58624dfef6b9a6f663790d8d9e62 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 2 Nov 2018 15:04:02 +0900 Subject: [PATCH] [API] Implement admin/add-emoji --- src/server/api/endpoints/admin/add-emoji.ts | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/server/api/endpoints/admin/add-emoji.ts diff --git a/src/server/api/endpoints/admin/add-emoji.ts b/src/server/api/endpoints/admin/add-emoji.ts new file mode 100644 index 000000000..9ae258d06 --- /dev/null +++ b/src/server/api/endpoints/admin/add-emoji.ts @@ -0,0 +1,38 @@ +import $ from 'cafy'; +import Emoji from '../../../../models/emoji'; +import define from '../../define'; + +export const meta = { + desc: { + 'ja-JP': 'カスタム絵文字を追加します。' + }, + + requireCredential: true, + requireAdmin: true, + + params: { + name: { + validator: $.str + }, + + url: { + validator: $.str + }, + + aliases: { + validator: $.arr($.str).optional, + default: [] as string[] + } + } +}; + +export default define(meta, (ps) => new Promise(async (res, rej) => { + await Emoji.insert({ + name: ps.name, + host: null, + aliases: ps.aliases, + url: ps.url + }); + + res(); +}));