aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-moderation/blocklist.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-moderation/blocklist.service.ts')
-rw-r--r--client/src/app/shared/shared-moderation/blocklist.service.ts15
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 @@
1import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
2import { catchError, map } from 'rxjs/operators' 2import { from } from 'rxjs'
3import { catchError, concatMap, map, toArray } from 'rxjs/operators'
3import { HttpClient, HttpParams } from '@angular/common/http' 4import { HttpClient, HttpParams } from '@angular/common/http'
4import { Injectable } from '@angular/core' 5import { Injectable } from '@angular/core'
5import { RestExtractor, RestPagination, RestService } from '@app/core' 6import { 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'>) {