diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-06-15 13:18:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-15 13:18:22 +0200 |
commit | 228393302d98136d4dc35c5f197edc8cebd5d64f (patch) | |
tree | f92b3ad80bcc9c89088ff1d4de5ebff76a3f46ed /client/src/app/shared/blocklist/blocklist.service.ts | |
parent | 7dfe35288613967f5ac69cd46901ec60c5050b93 (diff) | |
download | PeerTube-228393302d98136d4dc35c5f197edc8cebd5d64f.tar.gz PeerTube-228393302d98136d4dc35c5f197edc8cebd5d64f.tar.zst PeerTube-228393302d98136d4dc35c5f197edc8cebd5d64f.zip |
factorize account/server blocklists for users and instance (#2875)
Diffstat (limited to 'client/src/app/shared/blocklist/blocklist.service.ts')
-rw-r--r-- | client/src/app/shared/blocklist/blocklist.service.ts | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/client/src/app/shared/blocklist/blocklist.service.ts b/client/src/app/shared/blocklist/blocklist.service.ts index 5cf265bc1..c70a8173a 100644 --- a/client/src/app/shared/blocklist/blocklist.service.ts +++ b/client/src/app/shared/blocklist/blocklist.service.ts | |||
@@ -8,6 +8,8 @@ import { AccountBlock as AccountBlockServer, ResultList, ServerBlock } from '../ | |||
8 | import { Account } from '@app/shared/account/account.model' | 8 | import { Account } from '@app/shared/account/account.model' |
9 | import { AccountBlock } from '@app/shared/blocklist/account-block.model' | 9 | import { AccountBlock } from '@app/shared/blocklist/account-block.model' |
10 | 10 | ||
11 | export enum BlocklistComponentType { Account, Instance } | ||
12 | |||
11 | @Injectable() | 13 | @Injectable() |
12 | export class BlocklistService { | 14 | export class BlocklistService { |
13 | static BASE_USER_BLOCKLIST_URL = environment.apiUrl + '/api/v1/users/me/blocklist' | 15 | static BASE_USER_BLOCKLIST_URL = environment.apiUrl + '/api/v1/users/me/blocklist' |
@@ -21,10 +23,14 @@ export class BlocklistService { | |||
21 | 23 | ||
22 | /*********************** User -> Account blocklist ***********************/ | 24 | /*********************** User -> Account blocklist ***********************/ |
23 | 25 | ||
24 | getUserAccountBlocklist (pagination: RestPagination, sort: SortMeta) { | 26 | getUserAccountBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) { |
27 | const { pagination, sort, search } = options | ||
28 | |||
25 | let params = new HttpParams() | 29 | let params = new HttpParams() |
26 | params = this.restService.addRestGetParams(params, pagination, sort) | 30 | params = this.restService.addRestGetParams(params, pagination, sort) |
27 | 31 | ||
32 | if (search) params = params.append('search', search) | ||
33 | |||
28 | return this.authHttp.get<ResultList<AccountBlock>>(BlocklistService.BASE_USER_BLOCKLIST_URL + '/accounts', { params }) | 34 | return this.authHttp.get<ResultList<AccountBlock>>(BlocklistService.BASE_USER_BLOCKLIST_URL + '/accounts', { params }) |
29 | .pipe( | 35 | .pipe( |
30 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | 36 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |
@@ -49,10 +55,14 @@ export class BlocklistService { | |||
49 | 55 | ||
50 | /*********************** User -> Server blocklist ***********************/ | 56 | /*********************** User -> Server blocklist ***********************/ |
51 | 57 | ||
52 | getUserServerBlocklist (pagination: RestPagination, sort: SortMeta) { | 58 | getUserServerBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) { |
59 | const { pagination, sort, search } = options | ||
60 | |||
53 | let params = new HttpParams() | 61 | let params = new HttpParams() |
54 | params = this.restService.addRestGetParams(params, pagination, sort) | 62 | params = this.restService.addRestGetParams(params, pagination, sort) |
55 | 63 | ||
64 | if (search) params = params.append('search', search) | ||
65 | |||
56 | return this.authHttp.get<ResultList<ServerBlock>>(BlocklistService.BASE_USER_BLOCKLIST_URL + '/servers', { params }) | 66 | return this.authHttp.get<ResultList<ServerBlock>>(BlocklistService.BASE_USER_BLOCKLIST_URL + '/servers', { params }) |
57 | .pipe( | 67 | .pipe( |
58 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | 68 | map(res => this.restExtractor.convertResultListDateToHuman(res)), |
@@ -76,7 +86,7 @@ export class BlocklistService { | |||
76 | 86 | ||
77 | /*********************** Instance -> Account blocklist ***********************/ | 87 | /*********************** Instance -> Account blocklist ***********************/ |
78 | 88 | ||
79 | getInstanceAccountBlocklist (options: { pagination: RestPagination, sort: SortMeta, search: string }) { | 89 | getInstanceAccountBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) { |
80 | const { pagination, sort, search } = options | 90 | const { pagination, sort, search } = options |
81 | 91 | ||
82 | let params = new HttpParams() | 92 | let params = new HttpParams() |
@@ -108,7 +118,7 @@ export class BlocklistService { | |||
108 | 118 | ||
109 | /*********************** Instance -> Server blocklist ***********************/ | 119 | /*********************** Instance -> Server blocklist ***********************/ |
110 | 120 | ||
111 | getInstanceServerBlocklist (options: { pagination: RestPagination, sort: SortMeta, search: string }) { | 121 | getInstanceServerBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) { |
112 | const { pagination, sort, search } = options | 122 | const { pagination, sort, search } = options |
113 | 123 | ||
114 | let params = new HttpParams() | 124 | let params = new HttpParams() |