diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-12-07 17:03:56 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-12-07 17:05:23 +0100 |
commit | 8e7f08b5a5e65195ad6dd3d7850fda57021421f3 (patch) | |
tree | 1ee2bff1a5a51643e6b86c6f21e4766013a9213d /server/models | |
parent | 27e1a06c331278e5d37bc5172ee7e4fc968e4b5e (diff) | |
download | PeerTube-8e7f08b5a5e65195ad6dd3d7850fda57021421f3.tar.gz PeerTube-8e7f08b5a5e65195ad6dd3d7850fda57021421f3.tar.zst PeerTube-8e7f08b5a5e65195ad6dd3d7850fda57021421f3.zip |
Make some fields optional when uploading a video
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/video/video.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 60023bc8c..8b1eb1f96 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -104,7 +104,8 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
104 | }, | 104 | }, |
105 | category: { | 105 | category: { |
106 | type: DataTypes.INTEGER, | 106 | type: DataTypes.INTEGER, |
107 | allowNull: false, | 107 | allowNull: true, |
108 | defaultValue: null, | ||
108 | validate: { | 109 | validate: { |
109 | categoryValid: value => { | 110 | categoryValid: value => { |
110 | const res = isVideoCategoryValid(value) | 111 | const res = isVideoCategoryValid(value) |
@@ -114,7 +115,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
114 | }, | 115 | }, |
115 | licence: { | 116 | licence: { |
116 | type: DataTypes.INTEGER, | 117 | type: DataTypes.INTEGER, |
117 | allowNull: false, | 118 | allowNull: true, |
118 | defaultValue: null, | 119 | defaultValue: null, |
119 | validate: { | 120 | validate: { |
120 | licenceValid: value => { | 121 | licenceValid: value => { |
@@ -126,6 +127,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
126 | language: { | 127 | language: { |
127 | type: DataTypes.INTEGER, | 128 | type: DataTypes.INTEGER, |
128 | allowNull: true, | 129 | allowNull: true, |
130 | defaultValue: null, | ||
129 | validate: { | 131 | validate: { |
130 | languageValid: value => { | 132 | languageValid: value => { |
131 | const res = isVideoLanguageValid(value) | 133 | const res = isVideoLanguageValid(value) |
@@ -155,7 +157,8 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
155 | }, | 157 | }, |
156 | description: { | 158 | description: { |
157 | type: DataTypes.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max), | 159 | type: DataTypes.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max), |
158 | allowNull: false, | 160 | allowNull: true, |
161 | defaultValue: null, | ||
159 | validate: { | 162 | validate: { |
160 | descriptionValid: value => { | 163 | descriptionValid: value => { |
161 | const res = isVideoDescriptionValid(value) | 164 | const res = isVideoDescriptionValid(value) |
@@ -664,6 +667,8 @@ toActivityPubObject = function (this: VideoInstance) { | |||
664 | } | 667 | } |
665 | 668 | ||
666 | getTruncatedDescription = function (this: VideoInstance) { | 669 | getTruncatedDescription = function (this: VideoInstance) { |
670 | if (!this.description) return null | ||
671 | |||
667 | const options = { | 672 | const options = { |
668 | length: CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max | 673 | length: CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max |
669 | } | 674 | } |
@@ -754,8 +759,6 @@ getDescriptionPath = function (this: VideoInstance) { | |||
754 | 759 | ||
755 | getCategoryLabel = function (this: VideoInstance) { | 760 | getCategoryLabel = function (this: VideoInstance) { |
756 | let categoryLabel = VIDEO_CATEGORIES[this.category] | 761 | let categoryLabel = VIDEO_CATEGORIES[this.category] |
757 | |||
758 | // Maybe our server is not up to date and there are new categories since our version | ||
759 | if (!categoryLabel) categoryLabel = 'Misc' | 762 | if (!categoryLabel) categoryLabel = 'Misc' |
760 | 763 | ||
761 | return categoryLabel | 764 | return categoryLabel |
@@ -763,15 +766,12 @@ getCategoryLabel = function (this: VideoInstance) { | |||
763 | 766 | ||
764 | getLicenceLabel = function (this: VideoInstance) { | 767 | getLicenceLabel = function (this: VideoInstance) { |
765 | let licenceLabel = VIDEO_LICENCES[this.licence] | 768 | let licenceLabel = VIDEO_LICENCES[this.licence] |
766 | |||
767 | // Maybe our server is not up to date and there are new licences since our version | ||
768 | if (!licenceLabel) licenceLabel = 'Unknown' | 769 | if (!licenceLabel) licenceLabel = 'Unknown' |
769 | 770 | ||
770 | return licenceLabel | 771 | return licenceLabel |
771 | } | 772 | } |
772 | 773 | ||
773 | getLanguageLabel = function (this: VideoInstance) { | 774 | getLanguageLabel = function (this: VideoInstance) { |
774 | // Language is an optional attribute | ||
775 | let languageLabel = VIDEO_LANGUAGES[this.language] | 775 | let languageLabel = VIDEO_LANGUAGES[this.language] |
776 | if (!languageLabel) languageLabel = 'Unknown' | 776 | if (!languageLabel) languageLabel = 'Unknown' |
777 | 777 | ||