aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/account/actor.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-main/account/actor.service.ts')
-rw-r--r--client/src/app/shared/shared-main/account/actor.service.ts37
1 files changed, 0 insertions, 37 deletions
diff --git a/client/src/app/shared/shared-main/account/actor.service.ts b/client/src/app/shared/shared-main/account/actor.service.ts
deleted file mode 100644
index 464ed4519..000000000
--- a/client/src/app/shared/shared-main/account/actor.service.ts
+++ /dev/null
@@ -1,37 +0,0 @@
1import { Observable, ReplaySubject } from 'rxjs'
2import { catchError, map, tap } from 'rxjs/operators'
3import { HttpClient } from '@angular/common/http'
4import { Injectable } from '@angular/core'
5import { RestExtractor } from '@app/core'
6import { Account as ServerAccount, VideoChannel as ServerVideoChannel } from '@shared/models'
7import { environment } from '../../../../environments/environment'
8
9type KeysOfUnion<T> = T extends T ? keyof T: never
10type ServerActor = KeysOfUnion<ServerAccount | ServerVideoChannel>
11
12@Injectable()
13export class ActorService {
14 static BASE_ACTOR_API_URL = environment.apiUrl + '/api/v1/actors/'
15
16 actorLoaded = new ReplaySubject<string>(1)
17
18 constructor (
19 private authHttp: HttpClient,
20 private restExtractor: RestExtractor
21 ) {}
22
23 getActorType (actorName: string): Observable<string> {
24 return this.authHttp.get<ServerActor>(ActorService.BASE_ACTOR_API_URL + actorName)
25 .pipe(
26 map(actorHash => {
27 if (actorHash[ 'userId' ]) {
28 return 'Account'
29 }
30
31 return 'VideoChannel'
32 }),
33 tap(actor => this.actorLoaded.next(actor)),
34 catchError(res => this.restExtractor.handleError(res))
35 )
36 }
37}