From 375f86ec8210a4f9752f875e46856f9cb6762fec Mon Sep 17 00:00:00 2001 From: mei23 Date: Wed, 10 Oct 2018 02:04:16 +0900 Subject: [PATCH 1/2] Fix users recommendation query --- src/server/api/endpoints/users/recommendation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/api/endpoints/users/recommendation.ts b/src/server/api/endpoints/users/recommendation.ts index 6538a303b..d5807a295 100644 --- a/src/server/api/endpoints/users/recommendation.ts +++ b/src/server/api/endpoints/users/recommendation.ts @@ -67,7 +67,7 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => _id: { $nin: followingIds.concat(mutedUserIds) }, - isLocked: false, + isLocked: { $ne: true }, $or: [{ lastUsedAt: { $gte: new Date(Date.now() - ms('7days')) From 890dc050221f9ffcb1149e036c9e454e209b0642 Mon Sep 17 00:00:00 2001 From: mei23 Date: Wed, 10 Oct 2018 02:08:26 +0900 Subject: [PATCH 2/2] lint fix --- .../api/endpoints/users/recommendation.ts | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/server/api/endpoints/users/recommendation.ts b/src/server/api/endpoints/users/recommendation.ts index d5807a295..f44b1c909 100644 --- a/src/server/api/endpoints/users/recommendation.ts +++ b/src/server/api/endpoints/users/recommendation.ts @@ -3,8 +3,8 @@ import $ from 'cafy'; import User, { pack, ILocalUser } from '../../../../models/user'; import { getFriendIds } from '../../common/get-friends'; import Mute from '../../../../models/mute'; -import * as request from 'request' -import config from '../../../../config' +import * as request from 'request'; +import config from '../../../../config'; export const meta = { desc: { @@ -18,18 +18,19 @@ export const meta = { export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => { if (config.user_recommendation && config.user_recommendation.external) { - const userName = me.username - const hostName = config.hostname - const limit = params.limit - const offset = params.offset - const timeout = config.user_recommendation.timeout - const engine = config.user_recommendation.engine + const userName = me.username; + const hostName = config.hostname; + const limit = params.limit; + const offset = params.offset; + const timeout = config.user_recommendation.timeout; + const engine = config.user_recommendation.engine; const url = engine .replace('{{host}}', hostName) .replace('{{user}}', userName) .replace('{{limit}}', limit) - .replace('{{offset}}', offset) - request( + .replace('{{offset}}', offset); + + request( { url: url, timeout: timeout, @@ -39,12 +40,12 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => }, (error: any, response: any, body: any) => { if (!error && response.statusCode == 200) { - res(body) + res(body); } else { - res([]) + res([]); } } - ) + ); } else { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);