Hide suspended users (#4075)
This commit is contained in:
parent
9bf9519b8f
commit
c7ebf6f990
12 changed files with 94 additions and 98 deletions
20
src/server/api/common/get-hide-users.ts
Normal file
20
src/server/api/common/get-hide-users.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
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 me ? await getHideUserIdsById(me._id) : [];
|
||||
}
|
||||
|
||||
export async function getHideUserIdsById(meId: mongo.ObjectID) {
|
||||
const suspended = (await User.find({
|
||||
isSuspended: true
|
||||
})).map(user => user._id);
|
||||
|
||||
const muted = meId ? (await Mute.find({
|
||||
muterId: meId
|
||||
})).map(mute => mute.muteeId) : [];
|
||||
|
||||
return unique(suspended.concat(muted));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue