summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-11-07 13:14:52 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-11-07 13:14:52 +0900
commitcb6f390fb6964a032f15c6885d686d07c945ad38 (patch)
treee1e5d1de37ec20bc8b49c523fdaeff2227814944 /src/server/api/endpoints
parentFix (diff)
downloadsharkey-cb6f390fb6964a032f15c6885d686d07c945ad38.tar.gz
sharkey-cb6f390fb6964a032f15c6885d686d07c945ad38.tar.bz2
sharkey-cb6f390fb6964a032f15c6885d686d07c945ad38.zip
GitHub / Twitter連携の設定をDBに保存するように
Diffstat (limited to 'src/server/api/endpoints')
-rw-r--r--src/server/api/endpoints/admin/update-meta.ts68
-rw-r--r--src/server/api/endpoints/meta.ts4
2 files changed, 69 insertions, 3 deletions
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 : {}
};