diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-07-02 16:30:33 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-08-06 15:08:58 +0200 |
commit | 71ab65d02f359000f9ca6a00f163d66d56a33955 (patch) | |
tree | 0fb0460b05b90f151a8a24f1dc3a82c6c5697546 /client/src/standalone/videos/embed.ts | |
parent | a3b5e78af3696f807e54bc4b11e559bbd9b6ba1e (diff) | |
download | PeerTube-71ab65d02f359000f9ca6a00f163d66d56a33955.tar.gz PeerTube-71ab65d02f359000f9ca6a00f163d66d56a33955.tar.zst PeerTube-71ab65d02f359000f9ca6a00f163d66d56a33955.zip |
decouple video abuse details from embed, add embed to block list details
Diffstat (limited to 'client/src/standalone/videos/embed.ts')
-rw-r--r-- | client/src/standalone/videos/embed.ts | 13 |
1 files changed, 11 insertions, 2 deletions
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' | |||
17 | import { TranslationsManager } from '../../assets/player/translations-manager' | 17 | import { TranslationsManager } from '../../assets/player/translations-manager' |
18 | import videojs from 'video.js' | 18 | import videojs from 'video.js' |
19 | import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' | 19 | import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' |
20 | import { AuthUser } from '@app/core/auth/auth-user.model' | ||
20 | 21 | ||
21 | type Translations = { [ id: string ]: string } | 22 | type Translations = { [ id: string ]: string } |
22 | 23 | ||
@@ -42,6 +43,9 @@ export class PeerTubeEmbed { | |||
42 | mode: PlayerMode | 43 | mode: PlayerMode |
43 | scope = 'peertube' | 44 | scope = 'peertube' |
44 | 45 | ||
46 | user: AuthUser | ||
47 | headers = new Headers() | ||
48 | |||
45 | static async main () { | 49 | static async main () { |
46 | const videoContainerId = 'video-container' | 50 | const videoContainerId = 'video-container' |
47 | const embed = new PeerTubeEmbed(videoContainerId) | 51 | const embed = new PeerTubeEmbed(videoContainerId) |
@@ -57,11 +61,11 @@ export class PeerTubeEmbed { | |||
57 | } | 61 | } |
58 | 62 | ||
59 | loadVideoInfo (videoId: string): Promise<Response> { | 63 | loadVideoInfo (videoId: string): Promise<Response> { |
60 | return fetch(this.getVideoUrl(videoId)) | 64 | return fetch(this.getVideoUrl(videoId), { headers: this.headers }) |
61 | } | 65 | } |
62 | 66 | ||
63 | loadVideoCaptions (videoId: string): Promise<Response> { | 67 | loadVideoCaptions (videoId: string): Promise<Response> { |
64 | return fetch(this.getVideoUrl(videoId) + '/captions') | 68 | return fetch(this.getVideoUrl(videoId) + '/captions', { headers: this.headers }) |
65 | } | 69 | } |
66 | 70 | ||
67 | loadConfig (): Promise<Response> { | 71 | loadConfig (): Promise<Response> { |
@@ -111,6 +115,7 @@ export class PeerTubeEmbed { | |||
111 | 115 | ||
112 | async init () { | 116 | async init () { |
113 | try { | 117 | try { |
118 | this.user = AuthUser.load() | ||
114 | await this.initCore() | 119 | await this.initCore() |
115 | } catch (e) { | 120 | } catch (e) { |
116 | console.error(e) | 121 | console.error(e) |
@@ -163,6 +168,10 @@ export class PeerTubeEmbed { | |||
163 | const urlParts = window.location.pathname.split('/') | 168 | const urlParts = window.location.pathname.split('/') |
164 | const videoId = urlParts[ urlParts.length - 1 ] | 169 | const videoId = urlParts[ urlParts.length - 1 ] |
165 | 170 | ||
171 | if (this.user) { | ||
172 | this.headers.set('Authorization', `${this.user.getTokenType()} ${this.user.getAccessToken()}`) | ||
173 | } | ||
174 | |||
166 | const videoPromise = this.loadVideoInfo(videoId) | 175 | const videoPromise = this.loadVideoInfo(videoId) |
167 | const captionsPromise = this.loadVideoCaptions(videoId) | 176 | const captionsPromise = this.loadVideoCaptions(videoId) |
168 | const configPromise = this.loadConfig() | 177 | const configPromise = this.loadConfig() |