aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/jobs.ts4
-rw-r--r--server/controllers/bots.ts12
-rw-r--r--server/helpers/custom-validators/video-ownership.ts3
-rw-r--r--server/helpers/middlewares/video-abuses.ts3
-rw-r--r--server/lib/activitypub/send/send-update.ts2
-rw-r--r--server/middlewares/validators/redundancy.ts18
-rw-r--r--server/middlewares/validators/users.ts3
-rw-r--r--server/middlewares/validators/videos/video-comments.ts6
-rw-r--r--server/models/account/account-video-rate.ts2
-rw-r--r--server/models/activitypub/actor.ts2
-rw-r--r--server/models/video/video-file.ts2
-rw-r--r--server/models/video/video-playlist-element.ts2
-rw-r--r--server/models/video/video-share.ts2
-rw-r--r--server/models/video/video.ts2
14 files changed, 35 insertions, 28 deletions
diff --git a/server/controllers/api/jobs.ts b/server/controllers/api/jobs.ts
index c19596dde..1fa662349 100644
--- a/server/controllers/api/jobs.ts
+++ b/server/controllers/api/jobs.ts
@@ -36,8 +36,8 @@ export {
36 36
37// --------------------------------------------------------------------------- 37// ---------------------------------------------------------------------------
38 38
39async function listJobs (req: express.Request, res: express.Response, next: express.NextFunction) { 39async function listJobs (req: express.Request, res: express.Response) {
40 const state: JobState = req.params.state 40 const state = req.params.state as JobState
41 const asc = req.query.sort === 'createdAt' 41 const asc = req.query.sort === 'createdAt'
42 42
43 const jobs = await JobQueue.Instance.listForApi(state, req.query.start, req.query.count, asc) 43 const jobs = await JobQueue.Instance.listForApi(state, req.query.start, req.query.count, asc)
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts
index e25d9c21b..ed1040176 100644
--- a/server/controllers/bots.ts
+++ b/server/controllers/bots.ts
@@ -2,7 +2,6 @@ import * as express from 'express'
2import { asyncMiddleware } from '../middlewares' 2import { asyncMiddleware } from '../middlewares'
3import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants' 3import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
4import * as sitemapModule from 'sitemap' 4import * as sitemapModule from 'sitemap'
5import { logger } from '../helpers/logger'
6import { VideoModel } from '../models/video/video' 5import { VideoModel } from '../models/video/video'
7import { VideoChannelModel } from '../models/video/video-channel' 6import { VideoChannelModel } from '../models/video/video-channel'
8import { AccountModel } from '../models/account/account' 7import { AccountModel } from '../models/account/account'
@@ -39,15 +38,10 @@ async function getSitemap (req: express.Request, res: express.Response) {
39 urls: urls 38 urls: urls
40 }) 39 })
41 40
42 sitemap.toXML((err, xml) => { 41 const xml = sitemap.toXML()
43 if (err) {
44 logger.error('Cannot generate sitemap.', { err })
45 return res.sendStatus(500)
46 }
47 42
48 res.header('Content-Type', 'application/xml') 43 res.header('Content-Type', 'application/xml')
49 res.send(xml) 44 res.send(xml)
50 })
51} 45}
52 46
53async function getSitemapVideoChannelUrls () { 47async function getSitemapVideoChannelUrls () {
diff --git a/server/helpers/custom-validators/video-ownership.ts b/server/helpers/custom-validators/video-ownership.ts
index 9570b2799..2d1849332 100644
--- a/server/helpers/custom-validators/video-ownership.ts
+++ b/server/helpers/custom-validators/video-ownership.ts
@@ -3,7 +3,8 @@ import { VideoChangeOwnershipModel } from '../../models/video/video-change-owner
3import { MVideoChangeOwnershipFull } from '@server/typings/models/video/video-change-ownership' 3import { MVideoChangeOwnershipFull } from '@server/typings/models/video/video-change-ownership'
4import { MUserId } from '@server/typings/models' 4import { MUserId } from '@server/typings/models'
5 5
6export async function doesChangeVideoOwnershipExist (id: number, res: Response) { 6export async function doesChangeVideoOwnershipExist (idArg: number | string, res: Response) {
7 const id = parseInt(idArg + '', 10)
7 const videoChangeOwnership = await VideoChangeOwnershipModel.load(id) 8 const videoChangeOwnership = await VideoChangeOwnershipModel.load(id)
8 9
9 if (!videoChangeOwnership) { 10 if (!videoChangeOwnership) {
diff --git a/server/helpers/middlewares/video-abuses.ts b/server/helpers/middlewares/video-abuses.ts
index 1b573ca37..8a1d3d618 100644
--- a/server/helpers/middlewares/video-abuses.ts
+++ b/server/helpers/middlewares/video-abuses.ts
@@ -1,7 +1,8 @@
1import { Response } from 'express' 1import { Response } from 'express'
2import { VideoAbuseModel } from '../../models/video/video-abuse' 2import { VideoAbuseModel } from '../../models/video/video-abuse'
3 3
4async function doesVideoAbuseExist (abuseId: number, videoId: number, res: Response) { 4async function doesVideoAbuseExist (abuseIdArg: number | string, videoId: number, res: Response) {
5 const abuseId = parseInt(abuseIdArg + '', 10)
5 const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId) 6 const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId)
6 7
7 if (videoAbuse === null) { 8 if (videoAbuse === null) {
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts
index 37517c2be..44e0e1161 100644
--- a/server/lib/activitypub/send/send-update.ts
+++ b/server/lib/activitypub/send/send-update.ts
@@ -55,7 +55,7 @@ async function sendUpdateActor (accountOrChannel: MChannelDefault | MAccountDefa
55 logger.info('Creating job to update actor %s.', byActor.url) 55 logger.info('Creating job to update actor %s.', byActor.url)
56 56
57 const url = getUpdateActivityPubUrl(byActor.url, byActor.updatedAt.toISOString()) 57 const url = getUpdateActivityPubUrl(byActor.url, byActor.updatedAt.toISOString())
58 const accountOrChannelObject = accountOrChannel.toActivityPubObject() 58 const accountOrChannelObject = (accountOrChannel as any).toActivityPubObject() // FIXME: typescript bug?
59 const audience = getAudience(byActor) 59 const audience = getAudience(byActor)
60 const updateActivity = buildUpdateActivity(url, byActor, accountOrChannelObject, audience) 60 const updateActivity = buildUpdateActivity(url, byActor, accountOrChannelObject, audience)
61 61
diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.ts
index e65d3b8d3..8098e3a44 100644
--- a/server/middlewares/validators/redundancy.ts
+++ b/server/middlewares/validators/redundancy.ts
@@ -25,8 +25,12 @@ const videoFileRedundancyGetValidator = [
25 if (!await doesVideoExist(req.params.videoId, res)) return 25 if (!await doesVideoExist(req.params.videoId, res)) return
26 26
27 const video = res.locals.videoAll 27 const video = res.locals.videoAll
28
29 const paramResolution = req.params.resolution as unknown as number // We casted to int above
30 const paramFPS = req.params.fps as unknown as number // We casted to int above
31
28 const videoFile = video.VideoFiles.find(f => { 32 const videoFile = video.VideoFiles.find(f => {
29 return f.resolution === req.params.resolution && (!req.params.fps || f.fps === req.params.fps) 33 return f.resolution === paramResolution && (!req.params.fps || paramFPS)
30 }) 34 })
31 35
32 if (!videoFile) return res.status(404).json({ error: 'Video file not found.' }) 36 if (!videoFile) return res.status(404).json({ error: 'Video file not found.' })
@@ -41,8 +45,12 @@ const videoFileRedundancyGetValidator = [
41] 45]
42 46
43const videoPlaylistRedundancyGetValidator = [ 47const videoPlaylistRedundancyGetValidator = [
44 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'), 48 param('videoId')
45 param('streamingPlaylistType').custom(exists).withMessage('Should have a valid streaming playlist type'), 49 .custom(isIdOrUUIDValid)
50 .not().isEmpty().withMessage('Should have a valid video id'),
51 param('streamingPlaylistType')
52 .customSanitizer(toIntOrNull)
53 .custom(exists).withMessage('Should have a valid streaming playlist type'),
46 54
47 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 55 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
48 logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params }) 56 logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params })
@@ -51,7 +59,9 @@ const videoPlaylistRedundancyGetValidator = [
51 if (!await doesVideoExist(req.params.videoId, res)) return 59 if (!await doesVideoExist(req.params.videoId, res)) return
52 60
53 const video = res.locals.videoAll 61 const video = res.locals.videoAll
54 const videoStreamingPlaylist = video.VideoStreamingPlaylists.find(p => p === req.params.streamingPlaylistType) 62
63 const paramPlaylistType = req.params.streamingPlaylistType as unknown as number // We casted to int above
64 const videoStreamingPlaylist = video.VideoStreamingPlaylists.find(p => p.type === paramPlaylistType)
55 65
56 if (!videoStreamingPlaylist) return res.status(404).json({ error: 'Video playlist not found.' }) 66 if (!videoStreamingPlaylist) return res.status(404).json({ error: 'Video playlist not found.' })
57 res.locals.videoStreamingPlaylist = videoStreamingPlaylist 67 res.locals.videoStreamingPlaylist = videoStreamingPlaylist
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index b3466333c..804d1410e 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -448,7 +448,8 @@ export {
448 448
449// --------------------------------------------------------------------------- 449// ---------------------------------------------------------------------------
450 450
451function checkUserIdExist (id: number, res: express.Response) { 451function checkUserIdExist (idArg: number | string, res: express.Response) {
452 const id = parseInt(idArg + '', 10)
452 return checkUserExist(() => UserModel.loadById(id), res) 453 return checkUserExist(() => UserModel.loadById(id), res)
453} 454}
454 455
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index 8adbb02ba..1d81eb5d8 100644
--- a/server/middlewares/validators/videos/video-comments.ts
+++ b/server/middlewares/validators/videos/video-comments.ts
@@ -120,7 +120,8 @@ export {
120 120
121// --------------------------------------------------------------------------- 121// ---------------------------------------------------------------------------
122 122
123async function doesVideoCommentThreadExist (id: number, video: MVideoId, res: express.Response) { 123async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) {
124 const id = parseInt(idArg + '', 10)
124 const videoComment = await VideoCommentModel.loadById(id) 125 const videoComment = await VideoCommentModel.loadById(id)
125 126
126 if (!videoComment) { 127 if (!videoComment) {
@@ -151,7 +152,8 @@ async function doesVideoCommentThreadExist (id: number, video: MVideoId, res: ex
151 return true 152 return true
152} 153}
153 154
154async function doesVideoCommentExist (id: number, video: MVideoId, res: express.Response) { 155async function doesVideoCommentExist (idArg: number | string, video: MVideoId, res: express.Response) {
156 const id = parseInt(idArg + '', 10)
155 const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) 157 const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id)
156 158
157 if (!videoComment) { 159 if (!videoComment) {
diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts
index a6edbeee8..c593595b2 100644
--- a/server/models/account/account-video-rate.ts
+++ b/server/models/account/account-video-rate.ts
@@ -150,7 +150,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
150 static loadLocalAndPopulateVideo ( 150 static loadLocalAndPopulateVideo (
151 rateType: VideoRateType, 151 rateType: VideoRateType,
152 accountName: string, 152 accountName: string,
153 videoId: number, 153 videoId: number | string,
154 t?: Transaction 154 t?: Transaction
155 ): Bluebird<MAccountVideoRateAccountVideo> { 155 ): Bluebird<MAccountVideoRateAccountVideo> {
156 const options: FindOptions = { 156 const options: FindOptions = {
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index 05de1905d..535ebd792 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -430,8 +430,6 @@ export class ActorModel extends Model<ActorModel> {
430 } 430 }
431 431
432 toActivityPubObject (this: MActorAP, name: string) { 432 toActivityPubObject (this: MActorAP, name: string) {
433 let activityPubType
434
435 let icon = undefined 433 let icon = undefined
436 if (this.avatarId) { 434 if (this.avatarId) {
437 const extension = extname(this.Avatar.filename) 435 const extension = extname(this.Avatar.filename)
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 6304f741c..68e2d562a 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -99,7 +99,7 @@ export class VideoFileModel extends Model<VideoFileModel> {
99 static doesInfohashExist (infoHash: string) { 99 static doesInfohashExist (infoHash: string) {
100 const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1' 100 const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1'
101 const options = { 101 const options = {
102 type: QueryTypes.SELECT, 102 type: QueryTypes.SELECT as QueryTypes.SELECT,
103 bind: { infoHash }, 103 bind: { infoHash },
104 raw: true 104 raw: true
105 } 105 }
diff --git a/server/models/video/video-playlist-element.ts b/server/models/video/video-playlist-element.ts
index a28021313..9d2ea710e 100644
--- a/server/models/video/video-playlist-element.ts
+++ b/server/models/video/video-playlist-element.ts
@@ -181,7 +181,7 @@ export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel>
181 return VideoPlaylistElementModel.findOne(query) 181 return VideoPlaylistElementModel.findOne(query)
182 } 182 }
183 183
184 static loadById (playlistElementId: number): Bluebird<MVideoPlaylistElement> { 184 static loadById (playlistElementId: number | string): Bluebird<MVideoPlaylistElement> {
185 return VideoPlaylistElementModel.findByPk(playlistElementId) 185 return VideoPlaylistElementModel.findByPk(playlistElementId)
186 } 186 }
187 187
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts
index 9019b401a..50525b4c2 100644
--- a/server/models/video/video-share.ts
+++ b/server/models/video/video-share.ts
@@ -90,7 +90,7 @@ export class VideoShareModel extends Model<VideoShareModel> {
90 }) 90 })
91 Video: VideoModel 91 Video: VideoModel
92 92
93 static load (actorId: number, videoId: number, t?: Transaction): Bluebird<MVideoShareActor> { 93 static load (actorId: number | string, videoId: number | string, t?: Transaction): Bluebird<MVideoShareActor> {
94 return VideoShareModel.scope(ScopeNames.WITH_ACTOR).findOne({ 94 return VideoShareModel.scope(ScopeNames.WITH_ACTOR).findOne({
95 where: { 95 where: {
96 actorId, 96 actorId,
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 0ee3feaf3..0d1dbf106 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1608,7 +1608,7 @@ export class VideoModel extends Model<VideoModel> {
1608 'LIMIT 1' 1608 'LIMIT 1'
1609 1609
1610 const options = { 1610 const options = {
1611 type: QueryTypes.SELECT, 1611 type: QueryTypes.SELECT as QueryTypes.SELECT,
1612 bind: { followerActorId, videoId }, 1612 bind: { followerActorId, videoId },
1613 raw: true 1613 raw: true
1614 } 1614 }