Fix html tag with blacklisted video
authorChocobozzz <me@florianbigard.com>
Thu, 22 Aug 2019 08:46:54 +0000 (10:46 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 22 Aug 2019 08:46:54 +0000 (10:46 +0200)
server/lib/client-html.ts
server/models/video/video.ts
server/typings/models/video/video.ts

index a33aef26d20bd5953bc71e9c61d39370dfce9901..a1f4ae85856227ba6cf9519058903f43096fb601 100644 (file)
@@ -42,11 +42,11 @@ export class ClientHtml {
 
     const [ html, video ] = await Promise.all([
       ClientHtml.getIndexHTML(req, res),
-      VideoModel.load(videoId)
+      VideoModel.loadWithBlacklist(videoId)
     ])
 
     // Let Angular application handle errors
-    if (!video || video.privacy === VideoPrivacy.PRIVATE) {
+    if (!video || video.privacy === VideoPrivacy.PRIVATE || video.VideoBlacklist) {
       return ClientHtml.getIndexHTML(req, res)
     }
 
index ab7b49f1e6c9b95d1fd22f3059a11b7822bbbb63..6a95f6ef7e58d10bf51c2b27aac4f9b46cf57db3 100644 (file)
@@ -135,6 +135,7 @@ import {
   MVideoFullLight,
   MVideoIdThumbnail,
   MVideoThumbnail,
+  MVideoThumbnailBlacklist,
   MVideoWithAllFiles,
   MVideoWithFile,
   MVideoWithRights
@@ -1409,6 +1410,19 @@ export class VideoModel extends Model<VideoModel> {
     return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options)
   }
 
+  static loadWithBlacklist (id: number | string, t?: Transaction): Bluebird<MVideoThumbnailBlacklist> {
+    const where = buildWhereIdOrUUID(id)
+    const options = {
+      where,
+      transaction: t
+    }
+
+    return VideoModel.scope([
+      ScopeNames.WITH_THUMBNAILS,
+      ScopeNames.WITH_BLACKLISTED
+    ]).findOne(options)
+  }
+
   static loadWithRights (id: number | string, t?: Transaction): Bluebird<MVideoWithRights> {
     const where = buildWhereIdOrUUID(id)
     const options = {
index be32d4617ed20b552307af5ff72b8267cb330fd0..9a53bd337cf5245b1cb06630dd2e9c8479bc1940 100644 (file)
@@ -52,6 +52,10 @@ export type MVideoWithFileThumbnail = MVideo &
   Use<'VideoFiles', MVideoFile[]> &
   Use<'Thumbnails', MThumbnail[]>
 
+export type MVideoThumbnailBlacklist = MVideo &
+  Use<'Thumbnails', MThumbnail[]> &
+  Use<'VideoBlacklist', MVideoBlacklistLight>
+
 export type MVideoTag = MVideo &
   Use<'Tags', MTag[]>