]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/user.ts
add blocked filter in users list to filter banned users
[github/Chocobozzz/PeerTube.git] / server / models / account / user.ts
index fbd3080c6a82c5803c716f970bb4ea3d083537b4..de193131a27815d8ee31168528beae93eeaa7575 100644 (file)
@@ -68,7 +68,7 @@ import {
   MUserNotifSettingChannelDefault,
   MUserWithNotificationSetting,
   MVideoFullLight
-} from '@server/typings/models'
+} from '@server/types/models'
 
 enum ScopeNames {
   FOR_ME_API = 'FOR_ME_API',
@@ -412,11 +412,18 @@ export class UserModel extends Model<UserModel> {
     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<UserModel> {
             }
           }
         ]
-      }
+      })
+    }
+
+    if (blocked !== undefined) {
+      Object.assign(where, {
+        blocked: blocked
+      })
     }
 
     const query: FindOptions = {