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