diff options
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 8e3af62a4..f90f2b7f6 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -136,6 +136,7 @@ import { VideoFileModel } from './video-file' | |||
136 | import { VideoImportModel } from './video-import' | 136 | import { VideoImportModel } from './video-import' |
137 | import { VideoJobInfoModel } from './video-job-info' | 137 | import { VideoJobInfoModel } from './video-job-info' |
138 | import { VideoLiveModel } from './video-live' | 138 | import { VideoLiveModel } from './video-live' |
139 | import { VideoPasswordModel } from './video-password' | ||
139 | import { VideoPlaylistElementModel } from './video-playlist-element' | 140 | import { VideoPlaylistElementModel } from './video-playlist-element' |
140 | import { VideoShareModel } from './video-share' | 141 | import { VideoShareModel } from './video-share' |
141 | import { VideoSourceModel } from './video-source' | 142 | import { VideoSourceModel } from './video-source' |
@@ -734,6 +735,15 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
734 | }) | 735 | }) |
735 | VideoCaptions: VideoCaptionModel[] | 736 | VideoCaptions: VideoCaptionModel[] |
736 | 737 | ||
738 | @HasMany(() => VideoPasswordModel, { | ||
739 | foreignKey: { | ||
740 | name: 'videoId', | ||
741 | allowNull: false | ||
742 | }, | ||
743 | onDelete: 'cascade' | ||
744 | }) | ||
745 | VideoPasswords: VideoPasswordModel[] | ||
746 | |||
737 | @HasOne(() => VideoJobInfoModel, { | 747 | @HasOne(() => VideoJobInfoModel, { |
738 | foreignKey: { | 748 | foreignKey: { |
739 | name: 'videoId', | 749 | name: 'videoId', |
@@ -1918,7 +1928,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1918 | 1928 | ||
1919 | // --------------------------------------------------------------------------- | 1929 | // --------------------------------------------------------------------------- |
1920 | 1930 | ||
1921 | requiresAuth (options: { | 1931 | requiresUserAuth (options: { |
1922 | urlParamId: string | 1932 | urlParamId: string |
1923 | checkBlacklist: boolean | 1933 | checkBlacklist: boolean |
1924 | }) { | 1934 | }) { |
@@ -1936,11 +1946,11 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1936 | 1946 | ||
1937 | if (checkBlacklist && this.VideoBlacklist) return true | 1947 | if (checkBlacklist && this.VideoBlacklist) return true |
1938 | 1948 | ||
1939 | if (this.privacy !== VideoPrivacy.PUBLIC) { | 1949 | if (this.privacy === VideoPrivacy.PUBLIC || this.privacy === VideoPrivacy.PASSWORD_PROTECTED) { |
1940 | throw new Error(`Unknown video privacy ${this.privacy} to know if the video requires auth`) | 1950 | return false |
1941 | } | 1951 | } |
1942 | 1952 | ||
1943 | return false | 1953 | throw new Error(`Unknown video privacy ${this.privacy} to know if the video requires auth`) |
1944 | } | 1954 | } |
1945 | 1955 | ||
1946 | hasPrivateStaticPath () { | 1956 | hasPrivateStaticPath () { |