X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fschedule-video-update.ts;h=1e56562e1974dae3f4f198036b6719a692796ea8;hb=d9eaee3939bf2e93e5d775d32bce77842201faba;hp=d4e37beb5ce245eaccb95e7a3923baa9257b8a6f;hpb=2baea0c77cc765f7cbca9c9a2f4272268892a35c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/schedule-video-update.ts b/server/models/video/schedule-video-update.ts index d4e37beb5..1e56562e1 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 { @AllowNull(true) @Default(null) @Column - privacy: VideoPrivacy + privacy: VideoPrivacy.PUBLIC | VideoPrivacy.UNLISTED @CreatedAt createdAt: Date @@ -45,6 +45,21 @@ export class ScheduleVideoUpdateModel extends Model { }) Video: VideoModel + static areVideosToUpdate () { + const query = { + logging: false, + attributes: [ 'id' ], + where: { + updateAt: { + [Sequelize.Op.lte]: new Date() + } + } + } + + return ScheduleVideoUpdateModel.findOne(query) + .then(res => !!res) + } + static listVideosToUpdate (t: Transaction) { const query = { where: { @@ -68,4 +83,21 @@ export class ScheduleVideoUpdateModel extends Model { return ScheduleVideoUpdateModel.findAll(query) } + static deleteByVideoId (videoId: number, t: Transaction) { + const query = { + where: { + videoId + }, + transaction: t + } + + return ScheduleVideoUpdateModel.destroy(query) + } + + toFormattedJSON () { + return { + updateAt: this.updateAt, + privacy: this.privacy || undefined + } + } }