import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { RestExtractor, RestPagination, RestService } from '@app/core'
-import { AccountBlock as AccountBlockServer, ResultList, ServerBlock } from '@shared/models'
+import { AccountBlock as AccountBlockServer, BlockStatus, ResultList, ServerBlock } from '@shared/models'
import { environment } from '../../../environments/environment'
import { Account } from '../shared-main'
import { AccountBlock } from './account-block.model'
@Injectable()
export class BlocklistService {
+ static BASE_BLOCKLIST_URL = environment.apiUrl + '/api/v1/blocklist'
static BASE_USER_BLOCKLIST_URL = environment.apiUrl + '/api/v1/users/me/blocklist'
static BASE_SERVER_BLOCKLIST_URL = environment.apiUrl + '/api/v1/server/blocklist'
private restService: RestService
) { }
+ /** ********************* Blocklist status ***********************/
+
+ getStatus (options: {
+ accounts?: string[]
+ hosts?: string[]
+ }) {
+ const { accounts, hosts } = options
+
+ let params = new HttpParams()
+
+ if (accounts) params = this.restService.addArrayParams(params, 'accounts', accounts)
+ if (hosts) params = this.restService.addArrayParams(params, 'hosts', hosts)
+
+ return this.authHttp.get<BlockStatus>(BlocklistService.BASE_BLOCKLIST_URL + '/status', { params })
+ .pipe(catchError(err => this.restExtractor.handleError(err)))
+ }
+
/** ********************* User -> Account blocklist ***********************/
getUserAccountBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) {