summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/notes
diff options
context:
space:
mode:
authorAya Morisawa <AyaMorisawa4869@gmail.com>2018-09-07 00:02:55 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2018-09-07 00:02:55 +0900
commit00d79487cd89f3cae675ecc0392c47ba547b69a5 (patch)
treea55b9cf9240fce4ca853d78e004dac75f8c06002 /src/server/api/endpoints/notes
parentAdd concat function (#2640) (diff)
downloadsharkey-00d79487cd89f3cae675ecc0392c47ba547b69a5.tar.gz
sharkey-00d79487cd89f3cae675ecc0392c47ba547b69a5.tar.bz2
sharkey-00d79487cd89f3cae675ecc0392c47ba547b69a5.zip
Add erase function (#2641)
Diffstat (limited to 'src/server/api/endpoints/notes')
-rw-r--r--src/server/api/endpoints/notes/search_by_tag.ts9
1 files changed, 5 insertions, 4 deletions
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));
}