]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/follows/shared/follow.service.ts
Unfollow with host
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / follows / shared / follow.service.ts
index f66ed477df662d10fbc68e990c5c8b3148c68ad8..089be9d64542cd1054880db1467b1e2c3ad8d579 100644 (file)
@@ -1,17 +1,16 @@
-import { Injectable } from '@angular/core'
 import { HttpClient, HttpParams } from '@angular/common/http'
-import { Observable } from 'rxjs/Observable'
+import { Injectable } from '@angular/core'
+import { SortMeta } from 'primeng/primeng'
 import 'rxjs/add/operator/catch'
 import 'rxjs/add/operator/map'
-
-import { SortMeta } from 'primeng/primeng'
-
-import { RestExtractor, RestPagination, RestService } from '../../../shared'
+import { Observable } from 'rxjs/Observable'
 import { AccountFollow, ResultList } from '../../../../../../shared'
+import { environment } from '../../../../environments/environment'
+import { RestExtractor, RestPagination, RestService } from '../../../shared'
 
 @Injectable()
 export class FollowService {
-  private static BASE_APPLICATION_URL = API_URL + '/api/v1/server'
+  private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/server'
 
   constructor (
     private authHttp: HttpClient,
@@ -37,7 +36,7 @@ export class FollowService {
       .catch(res => this.restExtractor.handleError(res))
   }
 
-  follow (notEmptyHosts: String[]) {
+  follow (notEmptyHosts: string[]) {
     const body = {
       hosts: notEmptyHosts
     }
@@ -46,4 +45,10 @@ export class FollowService {
                         .map(this.restExtractor.extractDataBool)
                         .catch(res => this.restExtractor.handleError(res))
   }
+
+  unfollow (follow: AccountFollow) {
+    return this.authHttp.delete(FollowService.BASE_APPLICATION_URL + '/following/' + follow.following.host)
+      .map(this.restExtractor.extractDataBool)
+      .catch(res => this.restExtractor.handleError(res))
+  }
 }