Fix html tag with blacklisted video

This commit is contained in:
Chocobozzz 2019-08-22 10:46:54 +02:00
parent 5c5e587307
commit d636ab58d0
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 20 additions and 2 deletions

View File

@ -42,11 +42,11 @@ export class ClientHtml {
const [ html, video ] = await Promise.all([ const [ html, video ] = await Promise.all([
ClientHtml.getIndexHTML(req, res), ClientHtml.getIndexHTML(req, res),
VideoModel.load(videoId) VideoModel.loadWithBlacklist(videoId)
]) ])
// Let Angular application handle errors // Let Angular application handle errors
if (!video || video.privacy === VideoPrivacy.PRIVATE) { if (!video || video.privacy === VideoPrivacy.PRIVATE || video.VideoBlacklist) {
return ClientHtml.getIndexHTML(req, res) return ClientHtml.getIndexHTML(req, res)
} }

View File

@ -135,6 +135,7 @@ import {
MVideoFullLight, MVideoFullLight,
MVideoIdThumbnail, MVideoIdThumbnail,
MVideoThumbnail, MVideoThumbnail,
MVideoThumbnailBlacklist,
MVideoWithAllFiles, MVideoWithAllFiles,
MVideoWithFile, MVideoWithFile,
MVideoWithRights MVideoWithRights
@ -1409,6 +1410,19 @@ export class VideoModel extends Model<VideoModel> {
return VideoModel.scope(ScopeNames.WITH_THUMBNAILS).findOne(options) 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> { static loadWithRights (id: number | string, t?: Transaction): Bluebird<MVideoWithRights> {
const where = buildWhereIdOrUUID(id) const where = buildWhereIdOrUUID(id)
const options = { const options = {

View File

@ -52,6 +52,10 @@ export type MVideoWithFileThumbnail = MVideo &
Use<'VideoFiles', MVideoFile[]> & Use<'VideoFiles', MVideoFile[]> &
Use<'Thumbnails', MThumbnail[]> Use<'Thumbnails', MThumbnail[]>
export type MVideoThumbnailBlacklist = MVideo &
Use<'Thumbnails', MThumbnail[]> &
Use<'VideoBlacklist', MVideoBlacklistLight>
export type MVideoTag = MVideo & export type MVideoTag = MVideo &
Use<'Tags', MTag[]> Use<'Tags', MTag[]>