aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video.js')
-rw-r--r--server/models/video.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/server/models/video.js b/server/models/video.js
index c4c7b5de8..0f44b98c3 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -61,6 +61,16 @@ module.exports = function (sequelize, DataTypes) {
61 } 61 }
62 } 62 }
63 }, 63 },
64 licence: {
65 type: DataTypes.INTEGER,
66 allowNull: false,
67 validate: {
68 licenceValid: function (value) {
69 const res = customVideosValidators.isVideoLicenceValid(value)
70 if (res === false) throw new Error('Video licence is not valid.')
71 }
72 }
73 },
64 description: { 74 description: {
65 type: DataTypes.STRING, 75 type: DataTypes.STRING,
66 allowNull: false, 76 allowNull: false,
@@ -374,11 +384,17 @@ function toFormatedJSON () {
374 let categoryLabel = constants.VIDEO_CATEGORIES[this.category] 384 let categoryLabel = constants.VIDEO_CATEGORIES[this.category]
375 if (!categoryLabel) categoryLabel = 'Misc' 385 if (!categoryLabel) categoryLabel = 'Misc'
376 386
387 // Maybe our pod is not up to date and there are new licences since our version
388 let licenceLabel = constants.VIDEO_LICENCES[this.licence]
389 if (!licenceLabel) licenceLabel = 'Unknown'
390
377 const json = { 391 const json = {
378 id: this.id, 392 id: this.id,
379 name: this.name, 393 name: this.name,
380 category: this.category, 394 category: this.category,
381 categoryLabel, 395 categoryLabel,
396 licence: this.licence,
397 licenceLabel,
382 description: this.description, 398 description: this.description,
383 podHost, 399 podHost,
384 isLocal: this.isOwned(), 400 isLocal: this.isOwned(),
@@ -411,6 +427,7 @@ function toAddRemoteJSON (callback) {
411 const remoteVideo = { 427 const remoteVideo = {
412 name: self.name, 428 name: self.name,
413 category: self.category, 429 category: self.category,
430 licence: self.licence,
414 description: self.description, 431 description: self.description,
415 infoHash: self.infoHash, 432 infoHash: self.infoHash,
416 remoteId: self.id, 433 remoteId: self.id,
@@ -434,6 +451,7 @@ function toUpdateRemoteJSON (callback) {
434 const json = { 451 const json = {
435 name: this.name, 452 name: this.name,
436 category: this.category, 453 category: this.category,
454 licence: this.licence,
437 description: this.description, 455 description: this.description,
438 infoHash: this.infoHash, 456 infoHash: this.infoHash,
439 remoteId: this.id, 457 remoteId: this.id,