Add erase function (#2641)
This commit is contained in:
parent
3cace734c7
commit
00d79487cd
11 changed files with 31 additions and 19 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue