diff options
Diffstat (limited to 'client/src/app/shared/shared-moderation/blocklist.service.ts')
-rw-r--r-- | client/src/app/shared/shared-moderation/blocklist.service.ts | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/client/src/app/shared/shared-moderation/blocklist.service.ts b/client/src/app/shared/shared-moderation/blocklist.service.ts index f4836c6c4..3e92c2831 100644 --- a/client/src/app/shared/shared-moderation/blocklist.service.ts +++ b/client/src/app/shared/shared-moderation/blocklist.service.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { SortMeta } from 'primeng/api' | 1 | import { SortMeta } from 'primeng/api' |
2 | import { catchError, map } from 'rxjs/operators' | 2 | import { from } from 'rxjs' |
3 | import { catchError, concatMap, map, toArray } from 'rxjs/operators' | ||
3 | import { HttpClient, HttpParams } from '@angular/common/http' | 4 | import { HttpClient, HttpParams } from '@angular/common/http' |
4 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
5 | import { RestExtractor, RestPagination, RestService } from '@app/core' | 6 | import { RestExtractor, RestPagination, RestService } from '@app/core' |
@@ -120,11 +121,15 @@ export class BlocklistService { | |||
120 | ) | 121 | ) |
121 | } | 122 | } |
122 | 123 | ||
123 | blockAccountByInstance (account: Pick<Account, 'nameWithHost'>) { | 124 | blockAccountByInstance (accountsArg: Pick<Account, 'nameWithHost'> | Pick<Account, 'nameWithHost'>[]) { |
124 | const body = { accountName: account.nameWithHost } | 125 | const accounts = Array.isArray(accountsArg) ? accountsArg : [ accountsArg ] |
125 | 126 | ||
126 | return this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', body) | 127 | return from(accounts) |
127 | .pipe(catchError(err => this.restExtractor.handleError(err))) | 128 | .pipe( |
129 | concatMap(a => this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', { accountName: a.nameWithHost })), | ||
130 | toArray(), | ||
131 | catchError(err => this.restExtractor.handleError(err)) | ||
132 | ) | ||
128 | } | 133 | } |
129 | 134 | ||
130 | unblockAccountByInstance (account: Pick<Account, 'nameWithHost'>) { | 135 | unblockAccountByInstance (account: Pick<Account, 'nameWithHost'>) { |