aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/account
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-05-28 10:21:39 +0200
committerChocobozzz <me@florianbigard.com>2021-05-28 10:22:50 +0200
commit012580d98f489e599d44a9a2a0bdc892b9455a90 (patch)
treecd6d4abdbf43f4cd1c051ac49682b97c7b6dca92 /client/src/app/shared/shared-main/account
parentd6d96bed80700830063c6055969d2d2ff46c63c6 (diff)
downloadPeerTube-012580d98f489e599d44a9a2a0bdc892b9455a90.tar.gz
PeerTube-012580d98f489e599d44a9a2a0bdc892b9455a90.tar.zst
PeerTube-012580d98f489e599d44a9a2a0bdc892b9455a90.zip
Cleanup
We must not expose private actor objects to clients Just make 2 GET requests on channel/accounts instead
Diffstat (limited to 'client/src/app/shared/shared-main/account')
-rw-r--r--client/src/app/shared/shared-main/account/actor.service.ts37
-rw-r--r--client/src/app/shared/shared-main/account/index.ts1
2 files changed, 0 insertions, 38 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}
diff --git a/client/src/app/shared/shared-main/account/index.ts b/client/src/app/shared/shared-main/account/index.ts
index c6cdcd574..b80ddb9f5 100644
--- a/client/src/app/shared/shared-main/account/index.ts
+++ b/client/src/app/shared/shared-main/account/index.ts
@@ -1,4 +1,3 @@
1export * from './account.model' 1export * from './account.model'
2export * from './account.service' 2export * from './account.service'
3export * from './actor.model' 3export * from './actor.model'
4export * from './actor.service'