X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Faccount%2Fuser.ts;h=39654cfcf2f51326f71dc538913aa911942fdb44;hb=7ad9b9846c44d198a736183fb186c2039f5236b5;hp=e56b0bf40b06bb988e8cf9c04f82ace36cd8ec50;hpb=0491173a61aed66205c017e0d7e0503ea316c144;p=github%2FChocobozzz%2FPeerTube.git 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 { return this.count() } - static listForApi (start: number, count: number, sort: string) { + static listForApi (start: number, count: number, sort: string, search?: string) { + let where = undefined + if (search) { + where = { + [Sequelize.Op.or]: [ + { + email: { + [Sequelize.Op.iLike]: '%' + search + '%' + } + }, + { + username: { + [ Sequelize.Op.iLike ]: '%' + search + '%' + } + } + ] + } + } + const query = { attributes: { include: [ @@ -204,7 +222,8 @@ export class UserModel extends Model { }, offset: start, limit: count, - order: getSort(sort) + order: getSort(sort), + where } return UserModel.findAndCountAll(query)