aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/remote/videos.ts2
-rw-r--r--server/controllers/api/videos/index.ts53
-rw-r--r--server/helpers/core-utils.ts2
-rw-r--r--server/helpers/custom-validators/misc.ts10
-rw-r--r--server/helpers/custom-validators/pods.ts23
-rw-r--r--server/helpers/custom-validators/remote/videos.ts12
-rw-r--r--server/helpers/custom-validators/users.ts14
-rw-r--r--server/helpers/custom-validators/videos.ts58
-rw-r--r--server/middlewares/validators/pods.ts2
-rw-r--r--server/middlewares/validators/videos.ts2
-rw-r--r--server/models/pod/pod-interface.ts2
-rw-r--r--server/models/pod/pod.ts6
-rw-r--r--server/models/user/user-video-rate-interface.ts2
-rw-r--r--server/models/user/user-video-rate.ts2
-rw-r--r--server/models/user/user.ts5
-rw-r--r--server/models/video/video-interface.ts2
-rw-r--r--server/models/video/video.ts4
-rw-r--r--server/tests/api/config.js2
18 files changed, 102 insertions, 101 deletions
diff --git a/server/controllers/api/remote/videos.ts b/server/controllers/api/remote/videos.ts
index e7edff606..0a90549af 100644
--- a/server/controllers/api/remote/videos.ts
+++ b/server/controllers/api/remote/videos.ts
@@ -17,7 +17,7 @@ import {
17} from '../../../middlewares' 17} from '../../../middlewares'
18import { logger, retryTransactionWrapper } from '../../../helpers' 18import { logger, retryTransactionWrapper } from '../../../helpers'
19import { quickAndDirtyUpdatesVideoToFriends } from '../../../lib' 19import { quickAndDirtyUpdatesVideoToFriends } from '../../../lib'
20import { PodInstance, VideoInstance } from '../../../models' 20import { PodInstance } from '../../../models'
21import { 21import {
22 RemoteVideoRequest, 22 RemoteVideoRequest,
23 RemoteVideoCreateData, 23 RemoteVideoCreateData,
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index f639df098..3ec9d97bb 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -61,8 +61,7 @@ const storage = multer.diskStorage({
61 else if (file.mimetype === 'video/ogg') extension = 'ogv' 61 else if (file.mimetype === 'video/ogg') extension = 'ogv'
62 generateRandomString(16) 62 generateRandomString(16)
63 .then(randomString => { 63 .then(randomString => {
64 const filename = randomString 64 cb(null, randomString + '.' + extension)
65 cb(null, filename + '.' + extension)
66 }) 65 })
67 .catch(err => { 66 .catch(err => {
68 logger.error('Cannot generate random string for file name.', err) 67 logger.error('Cannot generate random string for file name.', err)
@@ -128,15 +127,15 @@ export {
128 127
129// --------------------------------------------------------------------------- 128// ---------------------------------------------------------------------------
130 129
131function listVideoCategories (req: express.Request, res: express.Response, next: express.NextFunction) { 130function listVideoCategories (req: express.Request, res: express.Response) {
132 res.json(VIDEO_CATEGORIES) 131 res.json(VIDEO_CATEGORIES)
133} 132}
134 133
135function listVideoLicences (req: express.Request, res: express.Response, next: express.NextFunction) { 134function listVideoLicences (req: express.Request, res: express.Response) {
136 res.json(VIDEO_LICENCES) 135 res.json(VIDEO_LICENCES)
137} 136}
138 137
139function listVideoLanguages (req: express.Request, res: express.Response, next: express.NextFunction) { 138function listVideoLanguages (req: express.Request, res: express.Response) {
140 res.json(VIDEO_LANGUAGES) 139 res.json(VIDEO_LANGUAGES)
141} 140}
142 141
@@ -144,7 +143,7 @@ function listVideoLanguages (req: express.Request, res: express.Response, next:
144// We need this because we run the transaction in SERIALIZABLE isolation that can fail 143// We need this because we run the transaction in SERIALIZABLE isolation that can fail
145function addVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) { 144function addVideoRetryWrapper (req: express.Request, res: express.Response, next: express.NextFunction) {
146 const options = { 145 const options = {
147 arguments: [ req, res, req.files.videofile[0] ], 146 arguments: [ req, res, req.files['videofile'][0] ],
148 errorMessage: 'Cannot insert the video with many retries.' 147 errorMessage: 'Cannot insert the video with many retries.'
149 } 148 }
150 149
@@ -157,7 +156,7 @@ function addVideoRetryWrapper (req: express.Request, res: express.Response, next
157} 156}
158 157
159function addVideo (req: express.Request, res: express.Response, videoPhysicalFile: Express.Multer.File) { 158function addVideo (req: express.Request, res: express.Response, videoPhysicalFile: Express.Multer.File) {
160 const videoInfos: VideoCreate = req.body 159 const videoInfo: VideoCreate = req.body
161 160
162 return db.sequelize.transaction(t => { 161 return db.sequelize.transaction(t => {
163 const user = res.locals.oauth.token.User 162 const user = res.locals.oauth.token.User
@@ -169,21 +168,21 @@ function addVideo (req: express.Request, res: express.Response, videoPhysicalFil
169 168
170 return db.Author.findOrCreateAuthor(name, podId, userId, t) 169 return db.Author.findOrCreateAuthor(name, podId, userId, t)
171 .then(author => { 170 .then(author => {
172 const tags = videoInfos.tags 171 const tags = videoInfo.tags
173 if (!tags) return { author, tagInstances: undefined } 172 if (!tags) return { author, tagInstances: undefined }
174 173
175 return db.Tag.findOrCreateTags(tags, t).then(tagInstances => ({ author, tagInstances })) 174 return db.Tag.findOrCreateTags(tags, t).then(tagInstances => ({ author, tagInstances }))
176 }) 175 })
177 .then(({ author, tagInstances }) => { 176 .then(({ author, tagInstances }) => {
178 const videoData = { 177 const videoData = {
179 name: videoInfos.name, 178 name: videoInfo.name,
180 remote: false, 179 remote: false,
181 extname: extname(videoPhysicalFile.filename), 180 extname: extname(videoPhysicalFile.filename),
182 category: videoInfos.category, 181 category: videoInfo.category,
183 licence: videoInfos.licence, 182 licence: videoInfo.licence,
184 language: videoInfos.language, 183 language: videoInfo.language,
185 nsfw: videoInfos.nsfw, 184 nsfw: videoInfo.nsfw,
186 description: videoInfos.description, 185 description: videoInfo.description,
187 duration: videoPhysicalFile['duration'], // duration was added by a previous middleware 186 duration: videoPhysicalFile['duration'], // duration was added by a previous middleware
188 authorId: author.id 187 authorId: author.id
189 } 188 }
@@ -240,7 +239,7 @@ function addVideo (req: express.Request, res: express.Response, videoPhysicalFil
240 239
241 return video.save(options) 240 return video.save(options)
242 .then(videoCreated => { 241 .then(videoCreated => {
243 // Do not forget to add Author informations to the created video 242 // Do not forget to add Author information to the created video
244 videoCreated.Author = author 243 videoCreated.Author = author
245 244
246 return { tagInstances, video: videoCreated, videoFile } 245 return { tagInstances, video: videoCreated, videoFile }
@@ -265,7 +264,7 @@ function addVideo (req: express.Request, res: express.Response, videoPhysicalFil
265 }) 264 })
266 }) 265 })
267 .then(video => { 266 .then(video => {
268 // Let transcoding job send the video to friends because the videofile extension might change 267 // Let transcoding job send the video to friends because the video file extension might change
269 if (CONFIG.TRANSCODING.ENABLED === true) return undefined 268 if (CONFIG.TRANSCODING.ENABLED === true) return undefined
270 269
271 return video.toAddRemoteJSON() 270 return video.toAddRemoteJSON()
@@ -275,7 +274,7 @@ function addVideo (req: express.Request, res: express.Response, videoPhysicalFil
275 }) 274 })
276 }) 275 })
277 }) 276 })
278 .then(() => logger.info('Video with name %s created.', videoInfos.name)) 277 .then(() => logger.info('Video with name %s created.', videoInfo.name))
279 .catch((err: Error) => { 278 .catch((err: Error) => {
280 logger.debug('Cannot insert the video.', err) 279 logger.debug('Cannot insert the video.', err)
281 throw err 280 throw err
@@ -299,14 +298,14 @@ function updateVideoRetryWrapper (req: express.Request, res: express.Response, n
299function updateVideo (req: express.Request, res: express.Response) { 298function updateVideo (req: express.Request, res: express.Response) {
300 const videoInstance = res.locals.video 299 const videoInstance = res.locals.video
301 const videoFieldsSave = videoInstance.toJSON() 300 const videoFieldsSave = videoInstance.toJSON()
302 const videoInfosToUpdate: VideoUpdate = req.body 301 const videoInfoToUpdate: VideoUpdate = req.body
303 302
304 return db.sequelize.transaction(t => { 303 return db.sequelize.transaction(t => {
305 let tagsPromise: Promise<TagInstance[]> 304 let tagsPromise: Promise<TagInstance[]>
306 if (!videoInfosToUpdate.tags) { 305 if (!videoInfoToUpdate.tags) {
307 tagsPromise = Promise.resolve(null) 306 tagsPromise = Promise.resolve(null)
308 } else { 307 } else {
309 tagsPromise = db.Tag.findOrCreateTags(videoInfosToUpdate.tags, t) 308 tagsPromise = db.Tag.findOrCreateTags(videoInfoToUpdate.tags, t)
310 } 309 }
311 310
312 return tagsPromise 311 return tagsPromise
@@ -315,12 +314,12 @@ function updateVideo (req: express.Request, res: express.Response) {
315 transaction: t 314 transaction: t
316 } 315 }
317 316
318 if (videoInfosToUpdate.name !== undefined) videoInstance.set('name', videoInfosToUpdate.name) 317 if (videoInfoToUpdate.name !== undefined) videoInstance.set('name', videoInfoToUpdate.name)
319 if (videoInfosToUpdate.category !== undefined) videoInstance.set('category', videoInfosToUpdate.category) 318 if (videoInfoToUpdate.category !== undefined) videoInstance.set('category', videoInfoToUpdate.category)
320 if (videoInfosToUpdate.licence !== undefined) videoInstance.set('licence', videoInfosToUpdate.licence) 319 if (videoInfoToUpdate.licence !== undefined) videoInstance.set('licence', videoInfoToUpdate.licence)
321 if (videoInfosToUpdate.language !== undefined) videoInstance.set('language', videoInfosToUpdate.language) 320 if (videoInfoToUpdate.language !== undefined) videoInstance.set('language', videoInfoToUpdate.language)
322 if (videoInfosToUpdate.nsfw !== undefined) videoInstance.set('nsfw', videoInfosToUpdate.nsfw) 321 if (videoInfoToUpdate.nsfw !== undefined) videoInstance.set('nsfw', videoInfoToUpdate.nsfw)
323 if (videoInfosToUpdate.description !== undefined) videoInstance.set('description', videoInfosToUpdate.description) 322 if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description)
324 323
325 return videoInstance.save(options).then(() => tagInstances) 324 return videoInstance.save(options).then(() => tagInstances)
326 }) 325 })
@@ -360,7 +359,7 @@ function updateVideo (req: express.Request, res: express.Response) {
360 }) 359 })
361} 360}
362 361
363function getVideo (req: express.Request, res: express.Response, next: express.NextFunction) { 362function getVideo (req: express.Request, res: express.Response) {
364 const videoInstance = res.locals.video 363 const videoInstance = res.locals.video
365 364
366 if (videoInstance.isOwned()) { 365 if (videoInstance.isOwned()) {
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index d28c97f09..f8dd45533 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -74,7 +74,7 @@ const readFilePromise = promisify2<string, string, string>(readFile)
74const readFileBufferPromise = promisify1<string, Buffer>(readFile) 74const readFileBufferPromise = promisify1<string, Buffer>(readFile)
75const unlinkPromise = promisify1WithVoid<string>(unlink) 75const unlinkPromise = promisify1WithVoid<string>(unlink)
76const renamePromise = promisify2WithVoid<string, string>(rename) 76const renamePromise = promisify2WithVoid<string, string>(rename)
77const writeFilePromise = promisify2<string, any, void>(writeFile) 77const writeFilePromise = promisify2WithVoid<string, any>(writeFile)
78const readdirPromise = promisify1<string, string[]>(readdir) 78const readdirPromise = promisify1<string, string[]>(readdir)
79const mkdirpPromise = promisify1<string, string>(mkdirp) 79const mkdirpPromise = promisify1<string, string>(mkdirp)
80const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes) 80const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes)
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index b1291ba7a..f6bb02c8e 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -13,11 +13,9 @@ export {
13 isArray 13 isArray
14} 14}
15 15
16declare global { 16declare module 'express-validator' {
17 namespace ExpressValidator { 17 export interface Validator {
18 export interface Validator { 18 exists,
19 exists, 19 isArray
20 isArray
21 }
22 } 20 }
23} 21}
diff --git a/server/helpers/custom-validators/pods.ts b/server/helpers/custom-validators/pods.ts
index 0519def52..f2ca520c0 100644
--- a/server/helpers/custom-validators/pods.ts
+++ b/server/helpers/custom-validators/pods.ts
@@ -1,9 +1,20 @@
1import * as validator from 'validator' 1import * as validator from 'validator'
2 2
3import { isArray, exists } from './misc' 3import { isArray, exists } from './misc'
4import { isTestInstance } from '../core-utils'
4 5
5function isHostValid (host: string) { 6function isHostValid (host: string) {
6 return exists(host) && validator.isURL(host) && host.split('://').length === 1 7 const isURLOptions = {
8 require_host: true,
9 require_tld: true
10 }
11
12 // We validate 'localhost', so we don't have the top level domain
13 if (isTestInstance()) {
14 isURLOptions.require_tld = false
15 }
16
17 return exists(host) && validator.isURL(host, isURLOptions) && host.split('://').length === 1
7} 18}
8 19
9function isEachUniqueHostValid (hosts: string[]) { 20function isEachUniqueHostValid (hosts: string[]) {
@@ -21,11 +32,9 @@ export {
21 isHostValid 32 isHostValid
22} 33}
23 34
24declare global { 35declare module 'express-validator' {
25 namespace ExpressValidator { 36 export interface Validator {
26 export interface Validator { 37 isEachUniqueHostValid
27 isEachUniqueHostValid 38 isHostValid
28 isHostValid
29 }
30 } 39 }
31} 40}
diff --git a/server/helpers/custom-validators/remote/videos.ts b/server/helpers/custom-validators/remote/videos.ts
index 091cd2186..49f76e909 100644
--- a/server/helpers/custom-validators/remote/videos.ts
+++ b/server/helpers/custom-validators/remote/videos.ts
@@ -101,13 +101,11 @@ export {
101 isEachRemoteRequestVideosEventsValid 101 isEachRemoteRequestVideosEventsValid
102} 102}
103 103
104declare global { 104declare module 'express-validator' {
105 namespace ExpressValidator { 105 export interface Validator {
106 export interface Validator { 106 isEachRemoteRequestVideosValid,
107 isEachRemoteRequestVideosValid, 107 isEachRemoteRequestVideosQaduValid,
108 isEachRemoteRequestVideosQaduValid, 108 isEachRemoteRequestVideosEventsValid
109 isEachRemoteRequestVideosEventsValid
110 }
111 } 109 }
112} 110}
113 111
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts
index 750563ada..2b37bdde8 100644
--- a/server/helpers/custom-validators/users.ts
+++ b/server/helpers/custom-validators/users.ts
@@ -34,13 +34,11 @@ export {
34 isUserDisplayNSFWValid 34 isUserDisplayNSFWValid
35} 35}
36 36
37declare global { 37declare module 'express-validator' {
38 namespace ExpressValidator { 38 export interface Validator {
39 export interface Validator { 39 isUserPasswordValid,
40 isUserPasswordValid, 40 isUserRoleValid,
41 isUserRoleValid, 41 isUserUsernameValid,
42 isUserUsernameValid, 42 isUserDisplayNSFWValid
43 isUserDisplayNSFWValid
44 }
45 } 43 }
46} 44}
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 139fa760f..8b3a26644 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -168,35 +168,33 @@ export {
168 isVideoFileResolutionValid 168 isVideoFileResolutionValid
169} 169}
170 170
171declare global { 171declare module 'express-validator' {
172 namespace ExpressValidator { 172 export interface Validator {
173 export interface Validator { 173 isVideoIdOrUUIDValid,
174 isVideoIdOrUUIDValid, 174 isVideoAuthorValid,
175 isVideoAuthorValid, 175 isVideoDateValid,
176 isVideoDateValid, 176 isVideoCategoryValid,
177 isVideoCategoryValid, 177 isVideoLicenceValid,
178 isVideoLicenceValid, 178 isVideoLanguageValid,
179 isVideoLanguageValid, 179 isVideoNSFWValid,
180 isVideoNSFWValid, 180 isVideoDescriptionValid,
181 isVideoDescriptionValid, 181 isVideoDurationValid,
182 isVideoDurationValid, 182 isVideoInfoHashValid,
183 isVideoInfoHashValid, 183 isVideoNameValid,
184 isVideoNameValid, 184 isVideoTagsValid,
185 isVideoTagsValid, 185 isVideoThumbnailValid,
186 isVideoThumbnailValid, 186 isVideoThumbnailDataValid,
187 isVideoThumbnailDataValid, 187 isVideoExtnameValid,
188 isVideoExtnameValid, 188 isVideoUUIDValid,
189 isVideoUUIDValid, 189 isVideoAbuseReasonValid,
190 isVideoAbuseReasonValid, 190 isVideoAbuseReporterUsernameValid,
191 isVideoAbuseReporterUsernameValid, 191 isVideoFile,
192 isVideoFile, 192 isVideoViewsValid,
193 isVideoViewsValid, 193 isVideoLikesValid,
194 isVideoLikesValid, 194 isVideoRatingTypeValid,
195 isVideoRatingTypeValid, 195 isVideoDislikesValid,
196 isVideoDislikesValid, 196 isVideoEventCountValid,
197 isVideoEventCountValid, 197 isVideoFileSizeValid,
198 isVideoFileSizeValid, 198 isVideoFileResolutionValid
199 isVideoFileResolutionValid
200 }
201 } 199 }
202} 200}
diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts
index d0981cd57..4d0e054b0 100644
--- a/server/middlewares/validators/pods.ts
+++ b/server/middlewares/validators/pods.ts
@@ -11,7 +11,7 @@ import { isTestInstance } from '../../helpers'
11function makeFriendsValidator (req: express.Request, res: express.Response, next: express.NextFunction) { 11function makeFriendsValidator (req: express.Request, res: express.Response, next: express.NextFunction) {
12 // Force https if the administrator wants to make friends 12 // Force https if the administrator wants to make friends
13 if (isTestInstance() === false && CONFIG.WEBSERVER.SCHEME === 'http') { 13 if (isTestInstance() === false && CONFIG.WEBSERVER.SCHEME === 'http') {
14 return res.status(400).send('Cannot make friends with a non HTTPS webserver.') 14 return res.status(400).send('Cannot make friends with a non HTTPS web server.')
15 } 15 }
16 16
17 req.checkBody('hosts', 'Should have an array of unique hosts').isEachUniqueHostValid() 17 req.checkBody('hosts', 'Should have an array of unique hosts').isEachUniqueHostValid()
diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts
index bd223a1cb..29c1ee0ef 100644
--- a/server/middlewares/validators/videos.ts
+++ b/server/middlewares/validators/videos.ts
@@ -24,7 +24,7 @@ function videosAddValidator (req: express.Request, res: express.Response, next:
24 logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files }) 24 logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files })
25 25
26 checkErrors(req, res, () => { 26 checkErrors(req, res, () => {
27 const videoFile = req.files.videofile[0] 27 const videoFile = req.files['videofile'][0]
28 28
29 db.Video.getDurationFromFile(videoFile.path) 29 db.Video.getDurationFromFile(videoFile.path)
30 .then(duration => { 30 .then(duration => {
diff --git a/server/models/pod/pod-interface.ts b/server/models/pod/pod-interface.ts
index 8b0b72167..fc763acac 100644
--- a/server/models/pod/pod-interface.ts
+++ b/server/models/pod/pod-interface.ts
@@ -42,6 +42,7 @@ export interface PodClass {
42} 42}
43 43
44export interface PodAttributes { 44export interface PodAttributes {
45 id?: number
45 host?: string 46 host?: string
46 publicKey?: string 47 publicKey?: string
47 score?: number | Sequelize.literal // Sequelize literal for 'score +' + value 48 score?: number | Sequelize.literal // Sequelize literal for 'score +' + value
@@ -49,7 +50,6 @@ export interface PodAttributes {
49} 50}
50 51
51export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> { 52export interface PodInstance extends PodClass, PodAttributes, Sequelize.Instance<PodAttributes> {
52 id: number
53 createdAt: Date 53 createdAt: Date
54 updatedAt: Date 54 updatedAt: Date
55 55
diff --git a/server/models/pod/pod.ts b/server/models/pod/pod.ts
index 56918e358..df6412721 100644
--- a/server/models/pod/pod.ts
+++ b/server/models/pod/pod.ts
@@ -143,7 +143,7 @@ list = function () {
143} 143}
144 144
145listAllIds = function (transaction: Sequelize.Transaction) { 145listAllIds = function (transaction: Sequelize.Transaction) {
146 const query: Sequelize.FindOptions = { 146 const query = {
147 attributes: [ 'id' ], 147 attributes: [ 'id' ],
148 transaction 148 transaction
149 } 149 }
@@ -170,9 +170,7 @@ listRandomPodIdsWithRequest = function (limit: number, tableWithPods: string, ta
170 limit: limit, 170 limit: limit,
171 where: { 171 where: {
172 id: { 172 id: {
173 $in: [ 173 $in: Sequelize.literal(`(SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins})`)
174 Sequelize.literal(`SELECT DISTINCT "${tableWithPods}"."podId" FROM "${tableWithPods}" ${tableWithPodsJoins}`)
175 ]
176 } 174 }
177 } 175 }
178 } 176 }
diff --git a/server/models/user/user-video-rate-interface.ts b/server/models/user/user-video-rate-interface.ts
index 4e6efc01a..ea0fdc4d9 100644
--- a/server/models/user/user-video-rate-interface.ts
+++ b/server/models/user/user-video-rate-interface.ts
@@ -13,6 +13,8 @@ export interface UserVideoRateClass {
13 13
14export interface UserVideoRateAttributes { 14export interface UserVideoRateAttributes {
15 type: VideoRateType 15 type: VideoRateType
16 userId: number
17 videoId: number
16} 18}
17 19
18export interface UserVideoRateInstance extends UserVideoRateClass, UserVideoRateAttributes, Sequelize.Instance<UserVideoRateAttributes> { 20export interface UserVideoRateInstance extends UserVideoRateClass, UserVideoRateAttributes, Sequelize.Instance<UserVideoRateAttributes> {
diff --git a/server/models/user/user-video-rate.ts b/server/models/user/user-video-rate.ts
index c14598650..7d6dd7281 100644
--- a/server/models/user/user-video-rate.ts
+++ b/server/models/user/user-video-rate.ts
@@ -66,7 +66,7 @@ function associate (models) {
66} 66}
67 67
68load = function (userId: number, videoId: number, transaction: Sequelize.Transaction) { 68load = function (userId: number, videoId: number, transaction: Sequelize.Transaction) {
69 const options: Sequelize.FindOptions = { 69 const options: Sequelize.FindOptions<UserVideoRateAttributes> = {
70 where: { 70 where: {
71 userId, 71 userId,
72 videoId 72 videoId
diff --git a/server/models/user/user.ts b/server/models/user/user.ts
index e1b933988..d481fa13c 100644
--- a/server/models/user/user.ts
+++ b/server/models/user/user.ts
@@ -198,7 +198,7 @@ loadById = function (id: number) {
198loadByUsername = function (username: string) { 198loadByUsername = function (username: string) {
199 const query = { 199 const query = {
200 where: { 200 where: {
201 username: username 201 username
202 } 202 }
203 } 203 }
204 204
@@ -212,5 +212,6 @@ loadByUsernameOrEmail = function (username: string, email: string) {
212 } 212 }
213 } 213 }
214 214
215 return User.findOne(query) 215 // FIXME: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18387
216 return (User as any).findOne(query)
216} 217}
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts
index cc214fd60..fb31c6a8f 100644
--- a/server/models/video/video-interface.ts
+++ b/server/models/video/video-interface.ts
@@ -121,6 +121,7 @@ export interface VideoClass {
121} 121}
122 122
123export interface VideoAttributes { 123export interface VideoAttributes {
124 id?: number
124 uuid?: string 125 uuid?: string
125 name: string 126 name: string
126 category: number 127 category: number
@@ -140,7 +141,6 @@ export interface VideoAttributes {
140} 141}
141 142
142export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { 143export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
143 id: number
144 createdAt: Date 144 createdAt: Date
145 updatedAt: Date 145 updatedAt: Date
146 146
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index b3ca1e668..7dfea8ac9 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -643,7 +643,7 @@ list = function () {
643} 643}
644 644
645listForApi = function (start: number, count: number, sort: string) { 645listForApi = function (start: number, count: number, sort: string) {
646 // Exclude Blakclisted videos from the list 646 // Exclude blacklisted videos from the list
647 const query = { 647 const query = {
648 distinct: true, 648 distinct: true,
649 offset: start, 649 offset: start,
@@ -807,7 +807,7 @@ searchAndPopulateAuthorAndPodAndTags = function (value: string, field: string, s
807 model: Video['sequelize'].models.VideoFile 807 model: Video['sequelize'].models.VideoFile
808 } 808 }
809 809
810 const query: Sequelize.FindOptions = { 810 const query: Sequelize.FindOptions<VideoAttributes> = {
811 distinct: true, 811 distinct: true,
812 where: createBaseVideosWhere(), 812 where: createBaseVideosWhere(),
813 offset: start, 813 offset: start,
diff --git a/server/tests/api/config.js b/server/tests/api/config.js
index 052b3f036..dc3cce052 100644
--- a/server/tests/api/config.js
+++ b/server/tests/api/config.js
@@ -35,7 +35,7 @@ describe('Test config', function () {
35 35
36 const data = res.body 36 const data = res.body
37 37
38 expect(data.signup.allowed).to.be.truthy 38 expect(data.signup.allowed).to.be.true
39 39
40 done() 40 done()
41 }) 41 })