aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-15 16:52:15 +0200
committerChocobozzz <me@florianbigard.com>2018-06-15 18:20:56 +0200
commitbbe0f0645ca958d33a3f409b15166609733b663f (patch)
treeedcd5d702c73cda74a2177c4bdc08c616334337d /server/models/video/video.ts
parent2baea0c77cc765f7cbca9c9a2f4272268892a35c (diff)
downloadPeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.tar.gz
PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.tar.zst
PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.zip
Add ability to schedule video publication
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts33
1 files changed, 23 insertions, 10 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 440f4d171..0041e4d38 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -97,7 +97,8 @@ export enum ScopeNames {
97 AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', 97 AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST',
98 WITH_ACCOUNT_DETAILS = 'WITH_ACCOUNT_DETAILS', 98 WITH_ACCOUNT_DETAILS = 'WITH_ACCOUNT_DETAILS',
99 WITH_TAGS = 'WITH_TAGS', 99 WITH_TAGS = 'WITH_TAGS',
100 WITH_FILES = 'WITH_FILES' 100 WITH_FILES = 'WITH_FILES',
101 WITH_SCHEDULED_UPDATE = 'WITH_SCHEDULED_UPDATE'
101} 102}
102 103
103@Scopes({ 104@Scopes({
@@ -286,6 +287,14 @@ export enum ScopeNames {
286 required: true 287 required: true
287 } 288 }
288 ] 289 ]
290 },
291 [ScopeNames.WITH_SCHEDULED_UPDATE]: {
292 include: [
293 {
294 model: () => ScheduleVideoUpdateModel.unscoped(),
295 required: false
296 }
297 ]
289 } 298 }
290}) 299})
291@Table({ 300@Table({
@@ -843,7 +852,7 @@ export class VideoModel extends Model<VideoModel> {
843 } 852 }
844 853
845 return VideoModel 854 return VideoModel
846 .scope([ ScopeNames.WITH_TAGS, ScopeNames.WITH_FILES, ScopeNames.WITH_ACCOUNT_DETAILS ]) 855 .scope([ ScopeNames.WITH_TAGS, ScopeNames.WITH_FILES, ScopeNames.WITH_ACCOUNT_DETAILS, ScopeNames.WITH_SCHEDULED_UPDATE ])
847 .findById(id, options) 856 .findById(id, options)
848 } 857 }
849 858
@@ -869,7 +878,7 @@ export class VideoModel extends Model<VideoModel> {
869 } 878 }
870 879
871 return VideoModel 880 return VideoModel
872 .scope([ ScopeNames.WITH_TAGS, ScopeNames.WITH_FILES, ScopeNames.WITH_ACCOUNT_DETAILS ]) 881 .scope([ ScopeNames.WITH_TAGS, ScopeNames.WITH_FILES, ScopeNames.WITH_ACCOUNT_DETAILS, ScopeNames.WITH_SCHEDULED_UPDATE ])
873 .findOne(options) 882 .findOne(options)
874 } 883 }
875 884
@@ -1022,9 +1031,9 @@ export class VideoModel extends Model<VideoModel> {
1022 1031
1023 toFormattedJSON (options?: { 1032 toFormattedJSON (options?: {
1024 additionalAttributes: { 1033 additionalAttributes: {
1025 state: boolean, 1034 state?: boolean,
1026 waitTranscoding: boolean, 1035 waitTranscoding?: boolean,
1027 scheduledUpdate: boolean 1036 scheduledUpdate?: boolean
1028 } 1037 }
1029 }): Video { 1038 }): Video {
1030 const formattedAccount = this.VideoChannel.Account.toFormattedJSON() 1039 const formattedAccount = this.VideoChannel.Account.toFormattedJSON()
@@ -1084,18 +1093,18 @@ export class VideoModel extends Model<VideoModel> {
1084 } 1093 }
1085 1094
1086 if (options) { 1095 if (options) {
1087 if (options.additionalAttributes.state) { 1096 if (options.additionalAttributes.state === true) {
1088 videoObject.state = { 1097 videoObject.state = {
1089 id: this.state, 1098 id: this.state,
1090 label: VideoModel.getStateLabel(this.state) 1099 label: VideoModel.getStateLabel(this.state)
1091 } 1100 }
1092 } 1101 }
1093 1102
1094 if (options.additionalAttributes.waitTranscoding) { 1103 if (options.additionalAttributes.waitTranscoding === true) {
1095 videoObject.waitTranscoding = this.waitTranscoding 1104 videoObject.waitTranscoding = this.waitTranscoding
1096 } 1105 }
1097 1106
1098 if (options.additionalAttributes.scheduledUpdate && this.ScheduleVideoUpdate) { 1107 if (options.additionalAttributes.scheduledUpdate === true && this.ScheduleVideoUpdate) {
1099 videoObject.scheduledUpdate = { 1108 videoObject.scheduledUpdate = {
1100 updateAt: this.ScheduleVideoUpdate.updateAt, 1109 updateAt: this.ScheduleVideoUpdate.updateAt,
1101 privacy: this.ScheduleVideoUpdate.privacy || undefined 1110 privacy: this.ScheduleVideoUpdate.privacy || undefined
@@ -1107,7 +1116,11 @@ export class VideoModel extends Model<VideoModel> {
1107 } 1116 }
1108 1117
1109 toFormattedDetailsJSON (): VideoDetails { 1118 toFormattedDetailsJSON (): VideoDetails {
1110 const formattedJson = this.toFormattedJSON() 1119 const formattedJson = this.toFormattedJSON({
1120 additionalAttributes: {
1121 scheduledUpdate: true
1122 }
1123 })
1111 1124
1112 const detailsJson = { 1125 const detailsJson = {
1113 support: this.support, 1126 support: this.support,