From 71ab65d02f359000f9ca6a00f163d66d56a33955 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 2 Jul 2020 16:30:33 +0200 Subject: decouple video abuse details from embed, add embed to block list details --- client/src/standalone/videos/embed.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'client/src/standalone/videos/embed.ts') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 468b1889f..dca23ca7e 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -17,6 +17,7 @@ import { PeerTubeEmbedApi } from './embed-api' import { TranslationsManager } from '../../assets/player/translations-manager' import videojs from 'video.js' import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' +import { AuthUser } from '@app/core/auth/auth-user.model' type Translations = { [ id: string ]: string } @@ -42,6 +43,9 @@ export class PeerTubeEmbed { mode: PlayerMode scope = 'peertube' + user: AuthUser + headers = new Headers() + static async main () { const videoContainerId = 'video-container' const embed = new PeerTubeEmbed(videoContainerId) @@ -57,11 +61,11 @@ export class PeerTubeEmbed { } loadVideoInfo (videoId: string): Promise { - return fetch(this.getVideoUrl(videoId)) + return fetch(this.getVideoUrl(videoId), { headers: this.headers }) } loadVideoCaptions (videoId: string): Promise { - return fetch(this.getVideoUrl(videoId) + '/captions') + return fetch(this.getVideoUrl(videoId) + '/captions', { headers: this.headers }) } loadConfig (): Promise { @@ -111,6 +115,7 @@ export class PeerTubeEmbed { async init () { try { + this.user = AuthUser.load() await this.initCore() } catch (e) { console.error(e) @@ -163,6 +168,10 @@ export class PeerTubeEmbed { const urlParts = window.location.pathname.split('/') const videoId = urlParts[ urlParts.length - 1 ] + if (this.user) { + this.headers.set('Authorization', `${this.user.getTokenType()} ${this.user.getAccessToken()}`) + } + const videoPromise = this.loadVideoInfo(videoId) const captionsPromise = this.loadVideoCaptions(videoId) const configPromise = this.loadConfig() -- cgit v1.2.3