From 8491293b02ed2ec53eb0fa128161ea0b08d3def9 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 2 Jul 2020 22:49:51 +0200 Subject: add blocked filter in users list to filter banned users fixes #2914 --- server/models/account/user.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'server/models/account') diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 3bde1e744..de193131a 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -412,11 +412,18 @@ export class UserModel extends Model { return this.count() } - static listForApi (start: number, count: number, sort: string, search?: string) { - let where: WhereOptions + static listForApi (parameters: { + start: number + count: number + sort: string + search?: string + blocked?: boolean + }) { + const { start, count, sort, search, blocked } = parameters + const where: WhereOptions = {} if (search) { - where = { + Object.assign(where, { [Op.or]: [ { email: { @@ -429,7 +436,13 @@ export class UserModel extends Model { } } ] - } + }) + } + + if (blocked !== undefined) { + Object.assign(where, { + blocked: blocked + }) } const query: FindOptions = { -- cgit v1.2.3