2019-02-01 00:57:51 +00:00
|
|
|
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) {
|
2019-02-12 08:19:15 +00:00
|
|
|
return await getHideUserIdsById(me ? me._id : null);
|
2019-02-01 00:57:51 +00:00
|
|
|
}
|
|
|
|
|
2019-02-01 01:00:36 +00:00
|
|
|
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([])
|
|
|
|
]);
|
2019-02-01 00:57:51 +00:00
|
|
|
|
2019-02-01 01:00:36 +00:00
|
|
|
return unique(suspended.map(user => user._id).concat(muted.map(mute => mute.muteeId)));
|
2019-02-01 00:57:51 +00:00
|
|
|
}
|