sharkey/src/server/api/common/get-hide-users.ts
MeiMei f3ce8564ea よく話すユーザーからサスペンドされたユーザーを隠すなど (#4228)
* Resolve #4226

* fix

* Fix: anonymousでアクセスするとサスペンドユーザーが隠れない

* fix
2019-02-12 17:19:15 +09:00

26 lines
640 B
TypeScript

import * as mongo from 'mongodb';
import Mute from '../../../models/mute';
import User, { IUser } from '../../../models/user';
import { unique } from '../../../prelude/array';
export async function getHideUserIds(me: IUser) {
return await getHideUserIdsById(me ? me._id : null);
}
export async function getHideUserIdsById(meId?: mongo.ObjectID) {
const [suspended, muted] = await Promise.all([
User.find({
isSuspended: true
}, {
fields: {
_id: true
}
}),
meId ? Mute.find({
muterId: meId
}) : Promise.resolve([])
]);
return unique(suspended.map(user => user._id).concat(muted.map(mute => mute.muteeId)));
}