diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-28 10:21:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-28 10:22:50 +0200 |
commit | 012580d98f489e599d44a9a2a0bdc892b9455a90 (patch) | |
tree | cd6d4abdbf43f4cd1c051ac49682b97c7b6dca92 /client/src/app/shared/shared-main/account | |
parent | d6d96bed80700830063c6055969d2d2ff46c63c6 (diff) | |
download | PeerTube-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.ts | 37 | ||||
-rw-r--r-- | client/src/app/shared/shared-main/account/index.ts | 1 |
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 @@ | |||
1 | import { Observable, ReplaySubject } from 'rxjs' | ||
2 | import { catchError, map, tap } from 'rxjs/operators' | ||
3 | import { HttpClient } from '@angular/common/http' | ||
4 | import { Injectable } from '@angular/core' | ||
5 | import { RestExtractor } from '@app/core' | ||
6 | import { Account as ServerAccount, VideoChannel as ServerVideoChannel } from '@shared/models' | ||
7 | import { environment } from '../../../../environments/environment' | ||
8 | |||
9 | type KeysOfUnion<T> = T extends T ? keyof T: never | ||
10 | type ServerActor = KeysOfUnion<ServerAccount | ServerVideoChannel> | ||
11 | |||
12 | @Injectable() | ||
13 | export 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 @@ | |||
1 | export * from './account.model' | 1 | export * from './account.model' |
2 | export * from './account.service' | 2 | export * from './account.service' |
3 | export * from './actor.model' | 3 | export * from './actor.model' |
4 | export * from './actor.service' | ||