aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-07-02 22:49:51 +0200
committerRigel Kent <sendmemail@rigelk.eu>2020-07-02 22:50:33 +0200
commit8491293b02ed2ec53eb0fa128161ea0b08d3def9 (patch)
treeb3d8dd2732f5876e39c73b7d917a7ad02f4e021a /client/src/app/core
parent2b587cad93381a1901df3c993bf1db90bbb0891f (diff)
downloadPeerTube-8491293b02ed2ec53eb0fa128161ea0b08d3def9.tar.gz
PeerTube-8491293b02ed2ec53eb0fa128161ea0b08d3def9.tar.zst
PeerTube-8491293b02ed2ec53eb0fa128161ea0b08d3def9.zip
add blocked filter in users list to filter banned users
fixes #2914
Diffstat (limited to 'client/src/app/core')
-rw-r--r--client/src/app/core/rest/rest.service.ts4
-rw-r--r--client/src/app/core/users/user.service.ts25
2 files changed, 26 insertions, 3 deletions
diff --git a/client/src/app/core/rest/rest.service.ts b/client/src/app/core/rest/rest.service.ts
index c12b6bd41..9e32c6d58 100644
--- a/client/src/app/core/rest/rest.service.ts
+++ b/client/src/app/core/rest/rest.service.ts
@@ -9,11 +9,12 @@ interface QueryStringFilterPrefixes {
9 prefix: string 9 prefix: string
10 handler?: (v: string) => string | number 10 handler?: (v: string) => string | number
11 multiple?: boolean 11 multiple?: boolean
12 isBoolean?: boolean
12 } 13 }
13} 14}
14 15
15type ParseQueryStringFilterResult = { 16type ParseQueryStringFilterResult = {
16 [key: string]: string | number | (string | number)[] 17 [key: string]: string | number | boolean | (string | number | boolean)[]
17} 18}
18 19
19@Injectable() 20@Injectable()
@@ -96,6 +97,7 @@ export class RestService {
96 return t 97 return t
97 }) 98 })
98 .filter(t => !!t || t === 0) 99 .filter(t => !!t || t === 0)
100 .map(t => prefixObj.isBoolean ? t === 'true' : t)
99 101
100 if (matchedTokens.length === 0) continue 102 if (matchedTokens.length === 0) continue
101 103
diff --git a/client/src/app/core/users/user.service.ts b/client/src/app/core/users/user.service.ts
index ab395b1f9..2c817d45e 100644
--- a/client/src/app/core/users/user.service.ts
+++ b/client/src/app/core/users/user.service.ts
@@ -290,11 +290,32 @@ export class UserService {
290 }) 290 })
291 } 291 }
292 292
293 getUsers (pagination: RestPagination, sort: SortMeta, search?: string): Observable<ResultList<UserServerModel>> { 293 getUsers (parameters: {
294 pagination: RestPagination
295 sort: SortMeta
296 search?: string
297 }): Observable<ResultList<UserServerModel>> {
298 const { pagination, sort, search } = parameters
299
294 let params = new HttpParams() 300 let params = new HttpParams()
295 params = this.restService.addRestGetParams(params, pagination, sort) 301 params = this.restService.addRestGetParams(params, pagination, sort)
296 302
297 if (search) params = params.append('search', search) 303 if (search) {
304 const filters = this.restService.parseQueryStringFilter(search, {
305 blocked: {
306 prefix: 'banned:',
307 isBoolean: true,
308 handler: v => {
309 if (v === 'true') return v
310 if (v === 'false') return v
311
312 return undefined
313 }
314 }
315 })
316
317 params = this.restService.addObjectParams(params, filters)
318 }
298 319
299 return this.authHttp.get<ResultList<UserServerModel>>(UserService.BASE_USERS_URL, { params }) 320 return this.authHttp.get<ResultList<UserServerModel>>(UserService.BASE_USERS_URL, { params })
300 .pipe( 321 .pipe(