From cb6f390fb6964a032f15c6885d686d07c945ad38 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 7 Nov 2018 13:14:52 +0900 Subject: GitHub / Twitter連携の設定をDBに保存するように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/api/endpoints/admin/update-meta.ts | 68 ++++++++++++++++++++++++++- src/server/api/endpoints/meta.ts | 4 +- 2 files changed, 69 insertions(+), 3 deletions(-) (limited to 'src/server/api/endpoints') diff --git a/src/server/api/endpoints/admin/update-meta.ts b/src/server/api/endpoints/admin/update-meta.ts index d45a8759f2..39d7ef86b9 100644 --- a/src/server/api/endpoints/admin/update-meta.ts +++ b/src/server/api/endpoints/admin/update-meta.ts @@ -137,7 +137,49 @@ export const meta = { desc: { 'ja-JP': 'インスタンスの対象言語' } - } + }, + + enableTwitterIntegration: { + validator: $.bool.optional, + desc: { + 'ja-JP': 'Twitter連携機能を有効にするか否か' + } + }, + + twitterConsumerKey: { + validator: $.str.optional.nullable, + desc: { + 'ja-JP': 'TwitterアプリのConsumer key' + } + }, + + twitterConsumerSecret: { + validator: $.str.optional.nullable, + desc: { + 'ja-JP': 'TwitterアプリのConsumer secret' + } + }, + + enableGithubIntegration: { + validator: $.bool.optional, + desc: { + 'ja-JP': 'GitHub連携機能を有効にするか否か' + } + }, + + githubClientId: { + validator: $.str.optional.nullable, + desc: { + 'ja-JP': 'GitHubアプリのClient ID' + } + }, + + githubClientSecret: { + validator: $.str.optional.nullable, + desc: { + 'ja-JP': 'GitHubアプリのClient secret' + } + }, } }; @@ -216,6 +258,30 @@ export default define(meta, (ps) => new Promise(async (res, rej) => { set.langs = ps.langs; } + if (ps.enableTwitterIntegration !== undefined) { + set.enableTwitterIntegration = ps.enableTwitterIntegration; + } + + if (ps.twitterConsumerKey !== undefined) { + set.twitterConsumerKey = ps.twitterConsumerKey; + } + + if (ps.twitterConsumerSecret !== undefined) { + set.twitterConsumerSecret = ps.twitterConsumerSecret; + } + + if (ps.enableGithubIntegration !== undefined) { + set.enableGithubIntegration = ps.enableGithubIntegration; + } + + if (ps.githubClientId !== undefined) { + set.githubClientId = ps.githubClientId; + } + + if (ps.githubClientSecret !== undefined) { + set.githubClientSecret = ps.githubClientSecret; + } + await Meta.update({}, { $set: set }, { upsert: true }); diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index 625a9519d7..7cd72d3cc3 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -77,8 +77,8 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => { elasticsearch: config.elasticsearch ? true : false, recaptcha: instance.enableRecaptcha, objectStorage: config.drive && config.drive.storage === 'minio', - twitter: config.twitter ? true : false, - github: config.github ? true : false, + twitter: instance.enableTwitterIntegration, + github: instance.enableGithubIntegration, serviceWorker: config.sw ? true : false, userRecommendation: config.user_recommendation ? config.user_recommendation : {} }; -- cgit v1.2.3-freya