diff options
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 468117504..82362917e 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -52,7 +52,7 @@ import { | |||
52 | import { AttributesOnly } from '@shared/typescript-utils' | 52 | import { AttributesOnly } from '@shared/typescript-utils' |
53 | import { peertubeTruncate } from '../../helpers/core-utils' | 53 | import { peertubeTruncate } from '../../helpers/core-utils' |
54 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 54 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
55 | import { exists, isBooleanValid } from '../../helpers/custom-validators/misc' | 55 | import { exists, isBooleanValid, isUUIDValid } from '../../helpers/custom-validators/misc' |
56 | import { | 56 | import { |
57 | isVideoDescriptionValid, | 57 | isVideoDescriptionValid, |
58 | isVideoDurationValid, | 58 | isVideoDurationValid, |
@@ -1696,12 +1696,12 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1696 | let files: VideoFile[] = [] | 1696 | let files: VideoFile[] = [] |
1697 | 1697 | ||
1698 | if (Array.isArray(this.VideoFiles)) { | 1698 | if (Array.isArray(this.VideoFiles)) { |
1699 | const result = videoFilesModelToFormattedJSON(this, this.VideoFiles, includeMagnet) | 1699 | const result = videoFilesModelToFormattedJSON(this, this.VideoFiles, { includeMagnet }) |
1700 | files = files.concat(result) | 1700 | files = files.concat(result) |
1701 | } | 1701 | } |
1702 | 1702 | ||
1703 | for (const p of (this.VideoStreamingPlaylists || [])) { | 1703 | for (const p of (this.VideoStreamingPlaylists || [])) { |
1704 | const result = videoFilesModelToFormattedJSON(this, p.VideoFiles, includeMagnet) | 1704 | const result = videoFilesModelToFormattedJSON(this, p.VideoFiles, { includeMagnet }) |
1705 | files = files.concat(result) | 1705 | files = files.concat(result) |
1706 | } | 1706 | } |
1707 | 1707 | ||
@@ -1868,22 +1868,14 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
1868 | return setAsUpdated('video', this.id, transaction) | 1868 | return setAsUpdated('video', this.id, transaction) |
1869 | } | 1869 | } |
1870 | 1870 | ||
1871 | requiresAuth () { | 1871 | requiresAuth (paramId: string) { |
1872 | return this.privacy === VideoPrivacy.PRIVATE || this.privacy === VideoPrivacy.INTERNAL || !!this.VideoBlacklist | 1872 | if (this.privacy === VideoPrivacy.UNLISTED) { |
1873 | } | 1873 | if (!isUUIDValid(paramId)) return true |
1874 | 1874 | ||
1875 | setPrivacy (newPrivacy: VideoPrivacy) { | 1875 | return false |
1876 | if (this.privacy === VideoPrivacy.PRIVATE && newPrivacy !== VideoPrivacy.PRIVATE) { | ||
1877 | this.publishedAt = new Date() | ||
1878 | } | 1876 | } |
1879 | 1877 | ||
1880 | this.privacy = newPrivacy | 1878 | return this.privacy === VideoPrivacy.PRIVATE || this.privacy === VideoPrivacy.INTERNAL || !!this.VideoBlacklist |
1881 | } | ||
1882 | |||
1883 | isConfidential () { | ||
1884 | return this.privacy === VideoPrivacy.PRIVATE || | ||
1885 | this.privacy === VideoPrivacy.UNLISTED || | ||
1886 | this.privacy === VideoPrivacy.INTERNAL | ||
1887 | } | 1879 | } |
1888 | 1880 | ||
1889 | async setNewState (newState: VideoState, isNewVideo: boolean, transaction: Transaction) { | 1881 | async setNewState (newState: VideoState, isNewVideo: boolean, transaction: Transaction) { |