ActivityPub-federated video streaming platform using P2P directly in your web browser
Use userId key to distinct Account or VideoChannel actor
Kimsible030ccfce59a8
diff --git a/client/src/app/root.component.ts b/client/src/app/root.component.tsindex ae999e0587..5a09e50d1d 100644--- a/client/src/app/root.component.ts+++ b/client/src/app/root.component.ts@@ -23,19 +23,21 @@ export class RootComponent implements OnInit {.pipe(map(params => params[ 'actorName' ]),distinctUntilChanged(),- switchMap(actorName => this.actorService.getActor(actorName)),+ switchMap(actorName => this.actorService.getActorType(actorName)),catchError(err => this.restExtractor.redirectTo404IfNotFound(err, 'other', [HttpStatusCode.BAD_REQUEST_400,HttpStatusCode.NOT_FOUND_404])))- .subscribe(actor => {- if (/\/accounts\//.test(actor.url)) {- this.router.navigate([ `/a/${actor.name}` ], { state: { type: 'others', obj: { status: 200 } }, skipLocationChange: true })+ .subscribe(actorType => {+ const actorName = this.route.snapshot.params[ 'actorName' ]++ if (actorType === 'Account') {+ this.router.navigate([ `/a/${actorName}` ], { state: { type: 'others', obj: { status: 200 } }, skipLocationChange: true })}- if (/\/video-channels\//.test(actor.url)) {- this.router.navigate([ `/c/${actor.name}` ], { state: { type: 'others', obj: { status: 200 } }, skipLocationChange: true })+ if (actorType === 'VideoChannel') {+ this.router.navigate([ `/c/${actorName}` ], { state: { type: 'others', obj: { status: 200 } }, skipLocationChange: true })}})}diff --git a/client/src/app/shared/shared-main/account/actor.service.ts b/client/src/app/shared/shared-main/account/actor.service.tsindex a789b6f5b3..464ed45195 100644--- a/client/src/app/shared/shared-main/account/actor.service.ts+++ b/client/src/app/shared/shared-main/account/actor.service.ts@@ -5,34 +5,30 @@ import { Injectable } from '@angular/core'import { RestExtractor } from '@app/core'import { Account as ServerAccount, VideoChannel as ServerVideoChannel } from '@shared/models'import { environment } from '../../../../environments/environment'-import { Account } from './account.model'-import { VideoChannel } from '../video-channel/video-channel.model'++type KeysOfUnion<T> = T extends T ? keyof T: never+type ServerActor = KeysOfUnion<ServerAccount | ServerVideoChannel>@Injectable()export class ActorService {static BASE_ACTOR_API_URL = environment.apiUrl + '/api/v1/actors/'- actorLoaded = new ReplaySubject<Account | VideoChannel>(1)+ actorLoaded = new ReplaySubject<string>(1)constructor (private authHttp: HttpClient,private restExtractor: RestExtractor) {}- getActor (actorName: string): Observable<Account | VideoChannel> {- return this.authHttp.get<ServerAccount | ServerVideoChannel>(ActorService.BASE_ACTOR_API_URL + actorName)+ getActorType (actorName: string): Observable<string> {+ return this.authHttp.get<ServerActor>(ActorService.BASE_ACTOR_API_URL + actorName).pipe(map(actorHash => {- const isAccount = /\/accounts\/.+/.test(actorHash.url)- const isVideoChannel = /\/video-channels\/.+/.test(actorHash.url)-- if (isAccount) {- return new Account(actorHash)+ if (actorHash[ 'userId' ]) {+ return 'Account'}- if (isVideoChannel) {- return new VideoChannel(actorHash)- }+ return 'VideoChannel'}),tap(actor => this.actorLoaded.next(actor)),catchError(res => this.restExtractor.handleError(res))