Feature / user recommendation config in admin ui (#3357)
* add config for external user recommendation into admin ui * debug * correct admin ui * switch external user recommendation to admin ui config * debug * debug * debug * Revert "debug" This reverts commit f4a0460e5bde21cd1f39a735f496a2d74233ef3f. * explicit parseInt radix * add Japanese message * change default engine to https * remove unused settings * debug * nullable externalUserRecommendationTimeout
This commit is contained in:
@ -200,6 +200,27 @@ export const meta = {
|
||||
desc: {
|
||||
'ja-JP': 'DiscordアプリのClient Secret'
|
||||
}
|
||||
},
|
||||
|
||||
enableExternalUserRecommendation: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': '外部ユーザーレコメンデーションを有効にする'
|
||||
}
|
||||
},
|
||||
|
||||
externalUserRecommendationEngine: {
|
||||
validator: $.str.optional.nullable,
|
||||
desc: {
|
||||
'ja-JP': '外部ユーザーレコメンデーションのサードパーティエンジン'
|
||||
}
|
||||
},
|
||||
|
||||
externalUserRecommendationTimeout: {
|
||||
validator: $.num.optional.nullable.min(0),
|
||||
desc: {
|
||||
'ja-JP': '外部ユーザーレコメンデーションのタイムアウト (ミリ秒)'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -315,6 +336,18 @@ export default define(meta, (ps) => new Promise(async (res, rej) => {
|
||||
set.discordClientSecret = ps.discordClientSecret;
|
||||
}
|
||||
|
||||
if (ps.enableExternalUserRecommendation !== undefined) {
|
||||
set.enableExternalUserRecommendation = ps.enableExternalUserRecommendation;
|
||||
}
|
||||
|
||||
if (ps.externalUserRecommendationEngine !== undefined) {
|
||||
set.externalUserRecommendationEngine = ps.externalUserRecommendationEngine;
|
||||
}
|
||||
|
||||
if (ps.externalUserRecommendationTimeout !== undefined) {
|
||||
set.externalUserRecommendationTimeout = ps.externalUserRecommendationTimeout;
|
||||
}
|
||||
|
||||
await Meta.update({}, {
|
||||
$set: set
|
||||
}, { upsert: true });
|
||||
|
@ -72,6 +72,10 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||
enableTwitterIntegration: instance.enableTwitterIntegration,
|
||||
enableGithubIntegration: instance.enableGithubIntegration,
|
||||
enableDiscordIntegration: instance.enableDiscordIntegration,
|
||||
|
||||
enableExternalUserRecommendation: instance.enableExternalUserRecommendation,
|
||||
externalUserRecommendationEngine: instance.externalUserRecommendationEngine,
|
||||
externalUserRecommendationTimeout: instance.externalUserRecommendationTimeout
|
||||
};
|
||||
|
||||
if (ps.detail) {
|
||||
@ -85,7 +89,11 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||
github: instance.enableGithubIntegration,
|
||||
discord: instance.enableDiscordIntegration,
|
||||
serviceWorker: config.sw ? true : false,
|
||||
userRecommendation: config.user_recommendation ? config.user_recommendation : {}
|
||||
userRecommendation: {
|
||||
external: instance.enableExternalUserRecommendation,
|
||||
engine: instance.externalUserRecommendationEngine,
|
||||
timeout: instance.externalUserRecommendationTimeout
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@ import Mute from '../../../../models/mute';
|
||||
import * as request from 'request';
|
||||
import config from '../../../../config';
|
||||
import define from '../../define';
|
||||
import fetchMeta from '../../../../misc/fetch-meta';
|
||||
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
@ -30,13 +32,15 @@ export const meta = {
|
||||
};
|
||||
|
||||
export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||
if (config.user_recommendation && config.user_recommendation.external) {
|
||||
const instance = await fetchMeta();
|
||||
|
||||
if (instance.enableExternalUserRecommendation) {
|
||||
const userName = me.username;
|
||||
const hostName = config.hostname;
|
||||
const limit = ps.limit;
|
||||
const offset = ps.offset;
|
||||
const timeout = config.user_recommendation.timeout;
|
||||
const engine = config.user_recommendation.engine;
|
||||
const timeout = instance.externalUserRecommendationTimeout;
|
||||
const engine = instance.externalUserRecommendationEngine;
|
||||
const url = engine
|
||||
.replace('{{host}}', hostName)
|
||||
.replace('{{user}}', userName)
|
||||
|
Reference in New Issue
Block a user