aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-08 15:51:38 +0200
committerChocobozzz <me@florianbigard.com>2018-10-08 15:55:32 +0200
commit24b9417cec5cc785a57b2fe169a1ae88b88801a4 (patch)
tree42adf8fb4355c96fe2585ebd6312563e8182d682 /server/models/account
parent791645e620fb98c6e7c32271d91d91ff7e41b892 (diff)
downloadPeerTube-24b9417cec5cc785a57b2fe169a1ae88b88801a4.tar.gz
PeerTube-24b9417cec5cc785a57b2fe169a1ae88b88801a4.tar.zst
PeerTube-24b9417cec5cc785a57b2fe169a1ae88b88801a4.zip
Add users search filter
Diffstat (limited to 'server/models/account')
-rw-r--r--server/models/account/user.ts23
1 files changed, 21 insertions, 2 deletions
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index e56b0bf40..39654cfcf 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -181,7 +181,25 @@ export class UserModel extends Model<UserModel> {
181 return this.count() 181 return this.count()
182 } 182 }
183 183
184 static listForApi (start: number, count: number, sort: string) { 184 static listForApi (start: number, count: number, sort: string, search?: string) {
185 let where = undefined
186 if (search) {
187 where = {
188 [Sequelize.Op.or]: [
189 {
190 email: {
191 [Sequelize.Op.iLike]: '%' + search + '%'
192 }
193 },
194 {
195 username: {
196 [ Sequelize.Op.iLike ]: '%' + search + '%'
197 }
198 }
199 ]
200 }
201 }
202
185 const query = { 203 const query = {
186 attributes: { 204 attributes: {
187 include: [ 205 include: [
@@ -204,7 +222,8 @@ export class UserModel extends Model<UserModel> {
204 }, 222 },
205 offset: start, 223 offset: start,
206 limit: count, 224 limit: count,
207 order: getSort(sort) 225 order: getSort(sort),
226 where
208 } 227 }
209 228
210 return UserModel.findAndCountAll(query) 229 return UserModel.findAndCountAll(query)