diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-07-11 17:04:57 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-07-11 17:05:55 +0200 |
commit | 075f16caac5236cb04c98ae7b3a989766d764bb3 (patch) | |
tree | 9a30024aa771735a28d83d9a166033b82dbcaf60 /server/models/video | |
parent | 4e979c3e1b81f4762025d9db3052b1f70774b3bb (diff) | |
download | PeerTube-075f16caac5236cb04c98ae7b3a989766d764bb3.tar.gz PeerTube-075f16caac5236cb04c98ae7b3a989766d764bb3.tar.zst PeerTube-075f16caac5236cb04c98ae7b3a989766d764bb3.zip |
Remove "function" in favor of () => {}
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/author.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-abuse.ts | 4 | ||||
-rw-r--r-- | server/models/video/video.ts | 26 |
3 files changed, 14 insertions, 18 deletions
diff --git a/server/models/video/author.ts b/server/models/video/author.ts index 3222c4834..c30cc306d 100644 --- a/server/models/video/author.ts +++ b/server/models/video/author.ts | |||
@@ -20,7 +20,7 @@ export default function defineAuthor (sequelize: Sequelize.Sequelize, DataTypes: | |||
20 | type: DataTypes.STRING, | 20 | type: DataTypes.STRING, |
21 | allowNull: false, | 21 | allowNull: false, |
22 | validate: { | 22 | validate: { |
23 | usernameValid: function (value) { | 23 | usernameValid: value => { |
24 | const res = isUserUsernameValid(value) | 24 | const res = isUserUsernameValid(value) |
25 | if (res === false) throw new Error('Username is not valid.') | 25 | if (res === false) throw new Error('Username is not valid.') |
26 | } | 26 | } |
diff --git a/server/models/video/video-abuse.ts b/server/models/video/video-abuse.ts index f55a25e6a..df92609c0 100644 --- a/server/models/video/video-abuse.ts +++ b/server/models/video/video-abuse.ts | |||
@@ -22,7 +22,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
22 | type: DataTypes.STRING, | 22 | type: DataTypes.STRING, |
23 | allowNull: false, | 23 | allowNull: false, |
24 | validate: { | 24 | validate: { |
25 | reporterUsernameValid: function (value) { | 25 | reporterUsernameValid: value => { |
26 | const res = isVideoAbuseReporterUsernameValid(value) | 26 | const res = isVideoAbuseReporterUsernameValid(value) |
27 | if (res === false) throw new Error('Video abuse reporter username is not valid.') | 27 | if (res === false) throw new Error('Video abuse reporter username is not valid.') |
28 | } | 28 | } |
@@ -32,7 +32,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
32 | type: DataTypes.STRING, | 32 | type: DataTypes.STRING, |
33 | allowNull: false, | 33 | allowNull: false, |
34 | validate: { | 34 | validate: { |
35 | reasonValid: function (value) { | 35 | reasonValid: value => { |
36 | const res = isVideoAbuseReasonValid(value) | 36 | const res = isVideoAbuseReasonValid(value) |
37 | if (res === false) throw new Error('Video abuse reason is not valid.') | 37 | if (res === false) throw new Error('Video abuse reason is not valid.') |
38 | } | 38 | } |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 3bb74bf6d..650025205 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -87,7 +87,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
87 | type: DataTypes.STRING, | 87 | type: DataTypes.STRING, |
88 | allowNull: false, | 88 | allowNull: false, |
89 | validate: { | 89 | validate: { |
90 | nameValid: function (value) { | 90 | nameValid: value => { |
91 | const res = isVideoNameValid(value) | 91 | const res = isVideoNameValid(value) |
92 | if (res === false) throw new Error('Video name is not valid.') | 92 | if (res === false) throw new Error('Video name is not valid.') |
93 | } | 93 | } |
@@ -101,7 +101,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
101 | type: DataTypes.INTEGER, | 101 | type: DataTypes.INTEGER, |
102 | allowNull: false, | 102 | allowNull: false, |
103 | validate: { | 103 | validate: { |
104 | categoryValid: function (value) { | 104 | categoryValid: value => { |
105 | const res = isVideoCategoryValid(value) | 105 | const res = isVideoCategoryValid(value) |
106 | if (res === false) throw new Error('Video category is not valid.') | 106 | if (res === false) throw new Error('Video category is not valid.') |
107 | } | 107 | } |
@@ -112,7 +112,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
112 | allowNull: false, | 112 | allowNull: false, |
113 | defaultValue: null, | 113 | defaultValue: null, |
114 | validate: { | 114 | validate: { |
115 | licenceValid: function (value) { | 115 | licenceValid: value => { |
116 | const res = isVideoLicenceValid(value) | 116 | const res = isVideoLicenceValid(value) |
117 | if (res === false) throw new Error('Video licence is not valid.') | 117 | if (res === false) throw new Error('Video licence is not valid.') |
118 | } | 118 | } |
@@ -122,7 +122,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
122 | type: DataTypes.INTEGER, | 122 | type: DataTypes.INTEGER, |
123 | allowNull: true, | 123 | allowNull: true, |
124 | validate: { | 124 | validate: { |
125 | languageValid: function (value) { | 125 | languageValid: value => { |
126 | const res = isVideoLanguageValid(value) | 126 | const res = isVideoLanguageValid(value) |
127 | if (res === false) throw new Error('Video language is not valid.') | 127 | if (res === false) throw new Error('Video language is not valid.') |
128 | } | 128 | } |
@@ -132,7 +132,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
132 | type: DataTypes.BOOLEAN, | 132 | type: DataTypes.BOOLEAN, |
133 | allowNull: false, | 133 | allowNull: false, |
134 | validate: { | 134 | validate: { |
135 | nsfwValid: function (value) { | 135 | nsfwValid: value => { |
136 | const res = isVideoNSFWValid(value) | 136 | const res = isVideoNSFWValid(value) |
137 | if (res === false) throw new Error('Video nsfw attribute is not valid.') | 137 | if (res === false) throw new Error('Video nsfw attribute is not valid.') |
138 | } | 138 | } |
@@ -142,7 +142,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
142 | type: DataTypes.STRING, | 142 | type: DataTypes.STRING, |
143 | allowNull: false, | 143 | allowNull: false, |
144 | validate: { | 144 | validate: { |
145 | descriptionValid: function (value) { | 145 | descriptionValid: value => { |
146 | const res = isVideoDescriptionValid(value) | 146 | const res = isVideoDescriptionValid(value) |
147 | if (res === false) throw new Error('Video description is not valid.') | 147 | if (res === false) throw new Error('Video description is not valid.') |
148 | } | 148 | } |
@@ -152,7 +152,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
152 | type: DataTypes.STRING, | 152 | type: DataTypes.STRING, |
153 | allowNull: false, | 153 | allowNull: false, |
154 | validate: { | 154 | validate: { |
155 | infoHashValid: function (value) { | 155 | infoHashValid: value => { |
156 | const res = isVideoInfoHashValid(value) | 156 | const res = isVideoInfoHashValid(value) |
157 | if (res === false) throw new Error('Video info hash is not valid.') | 157 | if (res === false) throw new Error('Video info hash is not valid.') |
158 | } | 158 | } |
@@ -162,7 +162,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
162 | type: DataTypes.INTEGER, | 162 | type: DataTypes.INTEGER, |
163 | allowNull: false, | 163 | allowNull: false, |
164 | validate: { | 164 | validate: { |
165 | durationValid: function (value) { | 165 | durationValid: value => { |
166 | const res = isVideoDurationValid(value) | 166 | const res = isVideoDurationValid(value) |
167 | if (res === false) throw new Error('Video duration is not valid.') | 167 | if (res === false) throw new Error('Video duration is not valid.') |
168 | } | 168 | } |
@@ -549,9 +549,7 @@ transcodeVideofile = function (this: VideoInstance) { | |||
549 | }) | 549 | }) |
550 | .catch(err => { | 550 | .catch(err => { |
551 | // Autodesctruction... | 551 | // Autodesctruction... |
552 | video.destroy().asCallback(function (err) { | 552 | video.destroy().catch(err => logger.error('Cannot destruct video after transcoding failure.', err)) |
553 | if (err) logger.error('Cannot destruct video after transcoding failure.', err) | ||
554 | }) | ||
555 | 553 | ||
556 | return rej(err) | 554 | return rej(err) |
557 | }) | 555 | }) |
@@ -574,7 +572,7 @@ generateThumbnailFromData = function (video: VideoInstance, thumbnailData: strin | |||
574 | 572 | ||
575 | getDurationFromFile = function (videoPath: string) { | 573 | getDurationFromFile = function (videoPath: string) { |
576 | return new Promise<number>((res, rej) => { | 574 | return new Promise<number>((res, rej) => { |
577 | ffmpeg.ffprobe(videoPath, function (err, metadata) { | 575 | ffmpeg.ffprobe(videoPath, (err, metadata) => { |
578 | if (err) return rej(err) | 576 | if (err) return rej(err) |
579 | 577 | ||
580 | return res(Math.floor(metadata.format.duration)) | 578 | return res(Math.floor(metadata.format.duration)) |
@@ -865,9 +863,7 @@ function generateImage (video: VideoInstance, videoPath: string, folder: string, | |||
865 | return new Promise<string>((res, rej) => { | 863 | return new Promise<string>((res, rej) => { |
866 | ffmpeg(videoPath) | 864 | ffmpeg(videoPath) |
867 | .on('error', rej) | 865 | .on('error', rej) |
868 | .on('end', function () { | 866 | .on('end', () => res(imageName)) |
869 | return res(imageName) | ||
870 | }) | ||
871 | .thumbnail(options) | 867 | .thumbnail(options) |
872 | }) | 868 | }) |
873 | } | 869 | } |