]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-moderation/blocklist.service.ts
Adding peertube-plugin-quickstart-typescript in the documentation.
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-moderation / blocklist.service.ts
index f4836c6c4bd694893ea29cc66163ae8207f1b4cb..1169bf75780a58c3e9c69afb4b2fdeab68dda520 100644 (file)
@@ -1,8 +1,10 @@
 import { SortMeta } from 'primeng/api'
-import { catchError, map } from 'rxjs/operators'
+import { from } from 'rxjs'
+import { catchError, concatMap, map, toArray } from 'rxjs/operators'
 import { HttpClient, HttpParams } from '@angular/common/http'
 import { Injectable } from '@angular/core'
 import { RestExtractor, RestPagination, RestService } from '@app/core'
+import { arrayify } from '@shared/core-utils'
 import { AccountBlock as AccountBlockServer, BlockStatus, ResultList, ServerBlock } from '@shared/models'
 import { environment } from '../../../environments/environment'
 import { Account } from '../shared-main'
@@ -120,11 +122,15 @@ export class BlocklistService {
                )
   }
 
-  blockAccountByInstance (account: Pick<Account, 'nameWithHost'>) {
-    const body = { accountName: account.nameWithHost }
+  blockAccountByInstance (accountsArg: Pick<Account, 'nameWithHost'> | Pick<Account, 'nameWithHost'>[]) {
+    const accounts = arrayify(accountsArg)
 
-    return this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', body)
-               .pipe(catchError(err => this.restExtractor.handleError(err)))
+    return from(accounts)
+      .pipe(
+        concatMap(a => this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', { accountName: a.nameWithHost })),
+        toArray(),
+        catchError(err => this.restExtractor.handleError(err))
+      )
   }
 
   unblockAccountByInstance (account: Pick<Account, 'nameWithHost'>) {