add config for external user recommendation into admin ui
This commit is contained in:
parent
f7d5f597f3
commit
7510f0f215
|
@ -45,6 +45,12 @@
|
||||||
<section>
|
<section>
|
||||||
<ui-button @click="updateMeta">{{ $t('save') }}</ui-button>
|
<ui-button @click="updateMeta">{{ $t('save') }}</ui-button>
|
||||||
</section>
|
</section>
|
||||||
|
<section>
|
||||||
|
<header><fa :icon="faUserPlus"/> {{ $t('user-recommendation-config') }}</header>
|
||||||
|
<ui-switch v-model="enableExternalUserRecommendation">{{ $t('enable-external-user-recommendation') }}</ui-switch>
|
||||||
|
<ui-input v-model="externalUserRecommendationEngine" :disabled="!enableExternalUserRecommendation">{{ $t('external-user-recommendation-engine') }}</ui-input>
|
||||||
|
<ui-input v-model="externalUserRecommendationTimeout" type="number" :disabled="!enableExternalUserRecommendation">{{ $t('external-user-recommendation-timeout') }}<span slot="suffix">ns</span><span slot="desc">{{ $t('ns') }}</span></ui-input>
|
||||||
|
</section>
|
||||||
</ui-card>
|
</ui-card>
|
||||||
|
|
||||||
<ui-card>
|
<ui-card>
|
||||||
|
@ -95,7 +101,7 @@ import Vue from 'vue';
|
||||||
import i18n from '../../i18n';
|
import i18n from '../../i18n';
|
||||||
import { host } from '../../config';
|
import { host } from '../../config';
|
||||||
import { toUnicode } from 'punycode';
|
import { toUnicode } from 'punycode';
|
||||||
import { faHeadset, faShieldAlt, faGhost } from '@fortawesome/free-solid-svg-icons';
|
import { faHeadset, faShieldAlt, faGhost, faUserPlus } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
i18n: i18n('admin/views/instance.vue'),
|
i18n: i18n('admin/views/instance.vue'),
|
||||||
|
@ -129,7 +135,10 @@ export default Vue.extend({
|
||||||
discordClientSecret: null,
|
discordClientSecret: null,
|
||||||
proxyAccount: null,
|
proxyAccount: null,
|
||||||
inviteCode: null,
|
inviteCode: null,
|
||||||
faHeadset, faShieldAlt, faGhost
|
enableExternalUserRecommendation: false,
|
||||||
|
externalUserRecommendationEngine: null,
|
||||||
|
externalUserRecommendationTimeout: null,
|
||||||
|
faHeadset, faShieldAlt, faGhost, faUserPlus
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -158,6 +167,9 @@ export default Vue.extend({
|
||||||
this.enableDiscordIntegration = meta.enableDiscordIntegration;
|
this.enableDiscordIntegration = meta.enableDiscordIntegration;
|
||||||
this.discordClientId = meta.discordClientId;
|
this.discordClientId = meta.discordClientId;
|
||||||
this.discordClientSecret = meta.discordClientSecret;
|
this.discordClientSecret = meta.discordClientSecret;
|
||||||
|
this.enableExternalUserRecommendation = meta.ebableExternalUserRecommendation;
|
||||||
|
this.externalUserRecommendationEngine = meta.externalUserRecommendationEngine;
|
||||||
|
this.externalUserRecommendationTimeout = meta.externalUserRecommendationTimeout;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -199,7 +211,10 @@ export default Vue.extend({
|
||||||
githubClientSecret: this.githubClientSecret,
|
githubClientSecret: this.githubClientSecret,
|
||||||
enableDiscordIntegration: this.enableDiscordIntegration,
|
enableDiscordIntegration: this.enableDiscordIntegration,
|
||||||
discordClientId: this.discordClientId,
|
discordClientId: this.discordClientId,
|
||||||
discordClientSecret: this.discordClientSecret
|
discordClientSecret: this.discordClientSecret,
|
||||||
|
enableExternalUserRecommendation: this.enableExternalUserRecommendation,
|
||||||
|
externalUserRecommendationEngine: this.externalUserRecommendationEngine,
|
||||||
|
externalUserRecommenadtionTimeout: this.externalUserRecommendationTimeout
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.$root.alert({
|
this.$root.alert({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
|
|
@ -15,7 +15,10 @@ const defaultMeta: any = {
|
||||||
maxNoteTextLength: 1000,
|
maxNoteTextLength: 1000,
|
||||||
enableTwitterIntegration: false,
|
enableTwitterIntegration: false,
|
||||||
enableGithubIntegration: false,
|
enableGithubIntegration: false,
|
||||||
enableDiscordIntegration: false
|
enableDiscordIntegration: false,
|
||||||
|
enableExternalUserRecommendation: false;
|
||||||
|
externalUserRecommendationEngine: "http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-misskey-api.cgi?{{host}}+{{user}}+{{limit}}+{{offset}}";
|
||||||
|
externalUserRecommendationTimeout: 300000;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function(): Promise<IMeta> {
|
export default async function(): Promise<IMeta> {
|
||||||
|
|
|
@ -125,6 +125,19 @@ if ((config as any).github) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if ((config as any).user_recommendation) {
|
||||||
|
Meta.findOne({}).then(m => {
|
||||||
|
if (m != null && m.enableExternalUserRecommendation == null) {
|
||||||
|
Meta.update({}, {
|
||||||
|
$set: {
|
||||||
|
enableExternalUserRecommendation: true,
|
||||||
|
externalUserRecommendationEngine: (config as any).user_recommendation.engine,
|
||||||
|
externalUserRecommendationTimeout: (config as any).user_recommendation.timeout
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export type IMeta = {
|
export type IMeta = {
|
||||||
name?: string;
|
name?: string;
|
||||||
|
@ -195,4 +208,8 @@ export type IMeta = {
|
||||||
enableDiscordIntegration?: boolean;
|
enableDiscordIntegration?: boolean;
|
||||||
discordClientId?: string;
|
discordClientId?: string;
|
||||||
discordClientSecret?: string;
|
discordClientSecret?: string;
|
||||||
|
|
||||||
|
enableExternalUserRecommendation? boolean;
|
||||||
|
externalUserRecommendationEngine? string;
|
||||||
|
externalUserRecommendationTimeout? number;
|
||||||
};
|
};
|
||||||
|
|
|
@ -200,6 +200,27 @@ export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
'ja-JP': 'DiscordアプリのClient Secret'
|
'ja-JP': 'DiscordアプリのClient Secret'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
enableExternalUserRecommendation: {
|
||||||
|
validator: $.bool.optional,
|
||||||
|
desc: {
|
||||||
|
'ja-JP': '外部ユーザーレコメンデーションを有効にする'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
externalUserRecommendationEngine: {
|
||||||
|
validator: $.str.optional.nullable,
|
||||||
|
desc: {
|
||||||
|
'ja-JP': '外部ユーザーレコメンデーションのサードパーティエンジン'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
externalUserRecommendationTimeout: {
|
||||||
|
validator: $.num.optional.min(0),
|
||||||
|
desc: {
|
||||||
|
'ja-JP': '外部ユーザーレコメンデーションのタイムアウト (ミリ秒)'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -315,6 +336,18 @@ export default define(meta, (ps) => new Promise(async (res, rej) => {
|
||||||
set.discordClientSecret = ps.discordClientSecret;
|
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({}, {
|
await Meta.update({}, {
|
||||||
$set: set
|
$set: set
|
||||||
}, { upsert: true });
|
}, { upsert: true });
|
||||||
|
|
|
@ -85,7 +85,11 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||||
github: instance.enableGithubIntegration,
|
github: instance.enableGithubIntegration,
|
||||||
discord: instance.enableDiscordIntegration,
|
discord: instance.enableDiscordIntegration,
|
||||||
serviceWorker: config.sw ? true : false,
|
serviceWorker: config.sw ? true : false,
|
||||||
userRecommendation: config.user_recommendation ? config.user_recommendation : {}
|
userRecommendation: {
|
||||||
|
external: instance.enableExternalUserRecommendation,
|
||||||
|
engine: instance.externalUserRecommendationEngine,
|
||||||
|
timeout: instance.externalUserRecommendationTimeout
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue