diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-15 16:43:14 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-16 16:41:36 +0200 |
commit | 65b21c961c69c4a63c7c0c34be3d6d034a1176c7 (patch) | |
tree | 35ec4a16c90a1de99b2865fbabb368b683ca6c87 /client/src/app/shared/blocklist | |
parent | b44164bb567fe7c9f65f1ac2908d44990a8ccc8e (diff) | |
download | PeerTube-65b21c961c69c4a63c7c0c34be3d6d034a1176c7.tar.gz PeerTube-65b21c961c69c4a63c7c0c34be3d6d034a1176c7.tar.zst PeerTube-65b21c961c69c4a63c7c0c34be3d6d034a1176c7.zip |
Add ability to mute a user/instance by server in client
Diffstat (limited to 'client/src/app/shared/blocklist')
-rw-r--r-- | client/src/app/shared/blocklist/account-block.model.ts | 2 | ||||
-rw-r--r-- | client/src/app/shared/blocklist/blocklist.service.ts | 56 | ||||
-rw-r--r-- | client/src/app/shared/blocklist/index.ts | 2 |
3 files changed, 58 insertions, 2 deletions
diff --git a/client/src/app/shared/blocklist/account-block.model.ts b/client/src/app/shared/blocklist/account-block.model.ts index 336680f65..e7b433d88 100644 --- a/client/src/app/shared/blocklist/account-block.model.ts +++ b/client/src/app/shared/blocklist/account-block.model.ts | |||
@@ -11,4 +11,4 @@ export class AccountBlock implements AccountBlockServer { | |||
11 | this.blockedAccount = new Account(block.blockedAccount) | 11 | this.blockedAccount = new Account(block.blockedAccount) |
12 | this.createdAt = block.createdAt | 12 | this.createdAt = block.createdAt |
13 | } | 13 | } |
14 | } \ No newline at end of file | 14 | } |
diff --git a/client/src/app/shared/blocklist/blocklist.service.ts b/client/src/app/shared/blocklist/blocklist.service.ts index d9c318258..c1f7312f0 100644 --- a/client/src/app/shared/blocklist/blocklist.service.ts +++ b/client/src/app/shared/blocklist/blocklist.service.ts | |||
@@ -11,6 +11,7 @@ import { AccountBlock } from '@app/shared/blocklist/account-block.model' | |||
11 | @Injectable() | 11 | @Injectable() |
12 | export class BlocklistService { | 12 | export class BlocklistService { |
13 | static BASE_USER_BLOCKLIST_URL = environment.apiUrl + '/api/v1/users/me/blocklist' | 13 | static BASE_USER_BLOCKLIST_URL = environment.apiUrl + '/api/v1/users/me/blocklist' |
14 | static BASE_SERVER_BLOCKLIST_URL = environment.apiUrl + '/api/v1/server/blocklist' | ||
14 | 15 | ||
15 | constructor ( | 16 | constructor ( |
16 | private authHttp: HttpClient, | 17 | private authHttp: HttpClient, |
@@ -73,6 +74,61 @@ export class BlocklistService { | |||
73 | .pipe(catchError(err => this.restExtractor.handleError(err))) | 74 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
74 | } | 75 | } |
75 | 76 | ||
77 | /*********************** Instance -> Account blocklist ***********************/ | ||
78 | |||
79 | getInstanceAccountBlocklist (pagination: RestPagination, sort: SortMeta) { | ||
80 | let params = new HttpParams() | ||
81 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
82 | |||
83 | return this.authHttp.get<ResultList<AccountBlock>>(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', { params }) | ||
84 | .pipe( | ||
85 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | ||
86 | map(res => this.restExtractor.applyToResultListData(res, this.formatAccountBlock.bind(this))), | ||
87 | catchError(err => this.restExtractor.handleError(err)) | ||
88 | ) | ||
89 | } | ||
90 | |||
91 | blockAccountByInstance (account: Account) { | ||
92 | const body = { accountName: account.nameWithHost } | ||
93 | |||
94 | return this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', body) | ||
95 | .pipe(catchError(err => this.restExtractor.handleError(err))) | ||
96 | } | ||
97 | |||
98 | unblockAccountByInstance (account: Account) { | ||
99 | const path = BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts/' + account.nameWithHost | ||
100 | |||
101 | return this.authHttp.delete(path) | ||
102 | .pipe(catchError(err => this.restExtractor.handleError(err))) | ||
103 | } | ||
104 | |||
105 | /*********************** Instance -> Server blocklist ***********************/ | ||
106 | |||
107 | getInstanceServerBlocklist (pagination: RestPagination, sort: SortMeta) { | ||
108 | let params = new HttpParams() | ||
109 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
110 | |||
111 | return this.authHttp.get<ResultList<ServerBlock>>(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/servers', { params }) | ||
112 | .pipe( | ||
113 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | ||
114 | catchError(err => this.restExtractor.handleError(err)) | ||
115 | ) | ||
116 | } | ||
117 | |||
118 | blockServerByInstance (host: string) { | ||
119 | const body = { host } | ||
120 | |||
121 | return this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/servers', body) | ||
122 | .pipe(catchError(err => this.restExtractor.handleError(err))) | ||
123 | } | ||
124 | |||
125 | unblockServerByInstance (host: string) { | ||
126 | const path = BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/servers/' + host | ||
127 | |||
128 | return this.authHttp.delete(path) | ||
129 | .pipe(catchError(err => this.restExtractor.handleError(err))) | ||
130 | } | ||
131 | |||
76 | private formatAccountBlock (accountBlock: AccountBlockServer) { | 132 | private formatAccountBlock (accountBlock: AccountBlockServer) { |
77 | return new AccountBlock(accountBlock) | 133 | return new AccountBlock(accountBlock) |
78 | } | 134 | } |
diff --git a/client/src/app/shared/blocklist/index.ts b/client/src/app/shared/blocklist/index.ts index 8cf6a55f7..5886ca07e 100644 --- a/client/src/app/shared/blocklist/index.ts +++ b/client/src/app/shared/blocklist/index.ts | |||
@@ -1,2 +1,2 @@ | |||
1 | export * from './blocklist.service' | 1 | export * from './blocklist.service' |
2 | export * from './account-block.model' \ No newline at end of file | 2 | export * from './account-block.model' |