description: videoToCreateData.description,
authorId: author.id,
duration: videoToCreateData.duration,
- createdAt: videoToCreateData.createdAt
+ createdAt: videoToCreateData.createdAt,
+ updatedAt: videoToCreateData.updatedAt
}
const video = db.Video.build(videoData)
videoInstance.set('infoHash', videoAttributesToUpdate.infoHash)
videoInstance.set('duration', videoAttributesToUpdate.duration)
videoInstance.set('createdAt', videoAttributesToUpdate.createdAt)
+ videoInstance.set('updatedAt', videoAttributesToUpdate.updatedAt)
videoInstance.set('extname', videoAttributesToUpdate.extname)
videoInstance.save(options).asCallback(function (err) {
isRequestTypeAddValid(request.type) &&
isVideoAuthorValid(video.author) &&
isVideoDateValid(video.createdAt) &&
+ isVideoDateValid(video.updatedAt) &&
isVideoDescriptionValid(video.description) &&
isVideoDurationValid(video.duration) &&
isVideoInfoHashValid(video.infoHash) &&
(
isRequestTypeUpdateValid(request.type) &&
isVideoDateValid(video.createdAt) &&
+ isVideoDateValid(video.updatedAt) &&
isVideoDescriptionValid(video.description) &&
isVideoDurationValid(video.duration) &&
isVideoInfoHashValid(video.infoHash) &&
// ---------------------------------------------------------------------------
module.exports = function (sequelize, DataTypes) {
- // TODO: add indexes on searchable columns
const Video = sequelize.define('Video',
{
id: {
duration: this.duration,
tags: map(this.Tags, 'name'),
thumbnailPath: constants.STATIC_PATHS.THUMBNAILS + '/' + this.getThumbnailName(),
- createdAt: this.createdAt
+ createdAt: this.createdAt,
+ updatedAt: this.updatedAt
}
return json
thumbnailData: thumbnailData.toString('binary'),
tags: map(self.Tags, 'name'),
createdAt: self.createdAt,
+ updatedAt: self.updatedAt,
extname: self.extname
}
duration: this.duration,
tags: map(this.Tags, 'name'),
createdAt: this.createdAt,
+ updatedAt: this.updatedAt,
extname: this.extname
}
expect(video.duration).to.equal(10)
expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
expect(video.author).to.equal('root')
if (server.url !== 'http://localhost:9001') {
expect(video.duration).to.equal(5)
expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ])
expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
expect(video.author).to.equal('root')
if (server.url !== 'http://localhost:9002') {
expect(video1.tags).to.deep.equal([ 'tag1p3' ])
expect(video1.author).to.equal('root')
expect(miscsUtils.dateIsValid(video1.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video1.updatedAt)).to.be.true
expect(video2.name).to.equal('my super name for pod 3-2')
expect(video2.description).to.equal('my super description for pod 3-2')
expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ])
expect(video2.author).to.equal('root')
expect(miscsUtils.dateIsValid(video2.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video2.updatedAt)).to.be.true
if (server.url !== 'http://localhost:9003') {
expect(video1.isLocal).to.be.false
expect(!!videoUpdated).to.be.true
expect(videoUpdated.description).to.equal('my super description updated')
expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
+ expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true
callback()
})
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
if (err) throw err
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
if (err) throw err
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
if (err) throw err
// expect(video.isLocal).to.be.true
// expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
// expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ // expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
// videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
// if (err) throw err
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
videosUtils.testVideoImage(server.url, 'video_short.webm', video.thumbnailPath, function (err, test) {
if (err) throw err
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
done()
})
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ])
expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
done()
})
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ])
expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
+ expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
done()
})
// ---------------------- Export functions --------------------
-function dateIsValid (dateString) {
+function dateIsValid (dateString, interval) {
const dateToCheck = new Date(dateString)
const now = new Date()
// Check if the interval is more than 2 minutes
- if (now - dateToCheck > 120000) return false
+ if (!interval) interval = 120000
+
+ if (now - dateToCheck > interval) return false
return true
}