aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/server/models/video.js b/server/models/video.js
index 86d6438c8..39eb28ed9 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -64,6 +64,7 @@ module.exports = function (sequelize, DataTypes) {
64 licence: { 64 licence: {
65 type: DataTypes.INTEGER, 65 type: DataTypes.INTEGER,
66 allowNull: false, 66 allowNull: false,
67 defaultValue: null,
67 validate: { 68 validate: {
68 licenceValid: function (value) { 69 licenceValid: function (value) {
69 const res = customVideosValidators.isVideoLicenceValid(value) 70 const res = customVideosValidators.isVideoLicenceValid(value)
@@ -71,6 +72,16 @@ module.exports = function (sequelize, DataTypes) {
71 } 72 }
72 } 73 }
73 }, 74 },
75 language: {
76 type: DataTypes.INTEGER,
77 allowNull: true,
78 validate: {
79 languageValid: function (value) {
80 const res = customVideosValidators.isVideoLanguageValid(value)
81 if (res === false) throw new Error('Video language is not valid.')
82 }
83 }
84 },
74 nsfw: { 85 nsfw: {
75 type: DataTypes.BOOLEAN, 86 type: DataTypes.BOOLEAN,
76 allowNull: false, 87 allowNull: false,
@@ -398,6 +409,10 @@ function toFormatedJSON () {
398 let licenceLabel = constants.VIDEO_LICENCES[this.licence] 409 let licenceLabel = constants.VIDEO_LICENCES[this.licence]
399 if (!licenceLabel) licenceLabel = 'Unknown' 410 if (!licenceLabel) licenceLabel = 'Unknown'
400 411
412 // Language is an optional attribute
413 let languageLabel = constants.VIDEO_LANGUAGES[this.language]
414 if (!languageLabel) languageLabel = 'Unknown'
415
401 const json = { 416 const json = {
402 id: this.id, 417 id: this.id,
403 name: this.name, 418 name: this.name,
@@ -405,6 +420,8 @@ function toFormatedJSON () {
405 categoryLabel, 420 categoryLabel,
406 licence: this.licence, 421 licence: this.licence,
407 licenceLabel, 422 licenceLabel,
423 language: this.language,
424 languageLabel,
408 nsfw: this.nsfw, 425 nsfw: this.nsfw,
409 description: this.description, 426 description: this.description,
410 podHost, 427 podHost,
@@ -439,6 +456,7 @@ function toAddRemoteJSON (callback) {
439 name: self.name, 456 name: self.name,
440 category: self.category, 457 category: self.category,
441 licence: self.licence, 458 licence: self.licence,
459 language: self.language,
442 nsfw: self.nsfw, 460 nsfw: self.nsfw,
443 description: self.description, 461 description: self.description,
444 infoHash: self.infoHash, 462 infoHash: self.infoHash,
@@ -464,6 +482,7 @@ function toUpdateRemoteJSON (callback) {
464 name: this.name, 482 name: this.name,
465 category: this.category, 483 category: this.category,
466 licence: this.licence, 484 licence: this.licence,
485 language: this.language,
467 nsfw: this.nsfw, 486 nsfw: this.nsfw,
468 description: this.description, 487 description: this.description,
469 infoHash: this.infoHash, 488 infoHash: this.infoHash,