From 00d79487cd89f3cae675ecc0392c47ba547b69a5 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Fri, 7 Sep 2018 00:02:55 +0900 Subject: Add erase function (#2641) --- src/server/api/endpoints/notes/search_by_tag.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/server/api/endpoints/notes') diff --git a/src/server/api/endpoints/notes/search_by_tag.ts b/src/server/api/endpoints/notes/search_by_tag.ts index 82f11a9775..77082c2600 100644 --- a/src/server/api/endpoints/notes/search_by_tag.ts +++ b/src/server/api/endpoints/notes/search_by_tag.ts @@ -5,6 +5,7 @@ import Mute from '../../../../models/mute'; import { getFriendIds } from '../../common/get-friends'; import { pack } from '../../../../models/note'; import getParams from '../../get-params'; +import { erase } from '../../../../prelude/array'; export const meta = { desc: { @@ -103,23 +104,23 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => if (psErr) throw psErr; if (ps.includeUserUsernames != null) { - const ids = (await Promise.all(ps.includeUserUsernames.map(async (username) => { + const ids = erase(null, await Promise.all(ps.includeUserUsernames.map(async (username) => { const _user = await User.findOne({ usernameLower: username.toLowerCase() }); return _user ? _user._id : null; - }))).filter(id => id != null); + }))); ids.forEach(id => ps.includeUserIds.push(id)); } if (ps.excludeUserUsernames != null) { - const ids = (await Promise.all(ps.excludeUserUsernames.map(async (username) => { + const ids = erase(null, await Promise.all(ps.excludeUserUsernames.map(async (username) => { const _user = await User.findOne({ usernameLower: username.toLowerCase() }); return _user ? _user._id : null; - }))).filter(id => id != null); + }))); ids.forEach(id => ps.excludeUserIds.push(id)); } -- cgit v1.2.3-freya