diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-15 16:52:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-15 18:20:56 +0200 |
commit | bbe0f0645ca958d33a3f409b15166609733b663f (patch) | |
tree | edcd5d702c73cda74a2177c4bdc08c616334337d /server/models/video/schedule-video-update.ts | |
parent | 2baea0c77cc765f7cbca9c9a2f4272268892a35c (diff) | |
download | PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.tar.gz PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.tar.zst PeerTube-bbe0f0645ca958d33a3f409b15166609733b663f.zip |
Add ability to schedule video publication
Diffstat (limited to 'server/models/video/schedule-video-update.ts')
-rw-r--r-- | server/models/video/schedule-video-update.ts | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/server/models/video/schedule-video-update.ts b/server/models/video/schedule-video-update.ts index d4e37beb5..3cf5f6c99 100644 --- a/server/models/video/schedule-video-update.ts +++ b/server/models/video/schedule-video-update.ts | |||
@@ -25,7 +25,7 @@ export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> { | |||
25 | @AllowNull(true) | 25 | @AllowNull(true) |
26 | @Default(null) | 26 | @Default(null) |
27 | @Column | 27 | @Column |
28 | privacy: VideoPrivacy | 28 | privacy: VideoPrivacy.PUBLIC | VideoPrivacy.UNLISTED |
29 | 29 | ||
30 | @CreatedAt | 30 | @CreatedAt |
31 | createdAt: Date | 31 | createdAt: Date |
@@ -45,6 +45,21 @@ export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> { | |||
45 | }) | 45 | }) |
46 | Video: VideoModel | 46 | Video: VideoModel |
47 | 47 | ||
48 | static areVideosToUpdate () { | ||
49 | const query = { | ||
50 | logging: false, | ||
51 | attributes: [ 'id' ], | ||
52 | where: { | ||
53 | updateAt: { | ||
54 | [Sequelize.Op.lte]: new Date() | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | |||
59 | return ScheduleVideoUpdateModel.findOne(query) | ||
60 | .then(res => !!res) | ||
61 | } | ||
62 | |||
48 | static listVideosToUpdate (t: Transaction) { | 63 | static listVideosToUpdate (t: Transaction) { |
49 | const query = { | 64 | const query = { |
50 | where: { | 65 | where: { |
@@ -68,4 +83,10 @@ export class ScheduleVideoUpdateModel extends Model<ScheduleVideoUpdateModel> { | |||
68 | return ScheduleVideoUpdateModel.findAll(query) | 83 | return ScheduleVideoUpdateModel.findAll(query) |
69 | } | 84 | } |
70 | 85 | ||
86 | toFormattedJSON () { | ||
87 | return { | ||
88 | updateAt: this.updateAt, | ||
89 | privacy: this.privacy || undefined | ||
90 | } | ||
91 | } | ||
71 | } | 92 | } |