Browse Source

Update server dependencies

Chocobozzz 1 month ago
parent
commit
d5d9b6d7bf
No account linked to committer's email address

+ 11
- 11
package.json View File

@@ -107,7 +107,7 @@
107 107
     "body-parser": "^1.12.4",
108 108
     "bull": "^3.4.2",
109 109
     "bytes": "^3.0.0",
110
-    "commander": "^2.13.0",
110
+    "commander": "^3.0.2",
111 111
     "config": "^3.0.0",
112 112
     "cookie-parser": "^1.4.3",
113 113
     "cors": "^2.8.1",
@@ -146,17 +146,17 @@
146 146
     "reflect-metadata": "^0.1.12",
147 147
     "request": "^2.81.0",
148 148
     "scripty": "^1.5.0",
149
-    "sequelize": "5.13.1",
149
+    "sequelize": "5.21.1",
150 150
     "sequelize-typescript": "^1.0.0-beta.4",
151
-    "sharp": "^0.22.0",
152
-    "sitemap": "^2",
151
+    "sharp": "^0.23.1",
152
+    "sitemap": "^5.0.0",
153 153
     "socket.io": "^2.2.0",
154 154
     "srt-to-vtt": "^1.1.2",
155 155
     "useragent": "^2.3.0",
156 156
     "uuid": "^3.1.0",
157 157
     "validator": "^11.0.0",
158 158
     "webfinger.js": "^2.6.6",
159
-    "webtorrent": "^0.105.1",
159
+    "webtorrent": "^0.107.16",
160 160
     "winston": "3.2.1",
161 161
     "ws": "^7.0.0",
162 162
     "youtube-dl": "^2.0.0"
@@ -194,21 +194,21 @@
194 194
     "@types/pem": "^1.9.3",
195 195
     "@types/redis": "^2.8.5",
196 196
     "@types/request": "^2.0.3",
197
-    "@types/sharp": "^0.22.1",
197
+    "@types/sharp": "^0.23.0",
198 198
     "@types/socket.io": "^2.1.2",
199 199
     "@types/supertest": "^2.0.3",
200 200
     "@types/validator": "^10.9.0",
201
-    "@types/webtorrent": "^0.98.4",
201
+    "@types/webtorrent": "^0.107.0",
202 202
     "@types/ws": "^6.0.0",
203 203
     "chai": "^4.1.1",
204 204
     "chai-json-schema": "^1.5.0",
205 205
     "chai-xml": "^0.3.2",
206
-    "concurrently": "^4.1.0",
206
+    "concurrently": "^5.0.0",
207 207
     "husky": "^3.0.1",
208
-    "libxmljs": "0.19.5",
208
+    "libxmljs": "0.19.7",
209 209
     "lint-staged": "^9.2.0",
210 210
     "maildev": "^1.0.0-rc3",
211
-    "marked-man": "^0.6.0",
211
+    "marked-man": "^0.7.0",
212 212
     "mocha": "^6.0.0",
213 213
     "mocha-parallel-tests": "^2.2.1",
214 214
     "nodemon": "^1.18.6",
@@ -216,7 +216,7 @@
216 216
     "source-map-support": "^0.5.0",
217 217
     "supertest": "^4.0.2",
218 218
     "swagger-cli": "^2.2.0",
219
-    "ts-node": "8.3.0",
219
+    "ts-node": "8.4.1",
220 220
     "tslint": "^5.7.0",
221 221
     "tslint-config-standard": "^8.0.1",
222 222
     "typescript": "^3.4.3",

+ 2
- 2
server/controllers/api/jobs.ts View File

@@ -36,8 +36,8 @@ export {
36 36
 
37 37
 // ---------------------------------------------------------------------------
38 38
 
39
-async function listJobs (req: express.Request, res: express.Response, next: express.NextFunction) {
40
-  const state: JobState = req.params.state
39
+async function listJobs (req: express.Request, res: express.Response) {
40
+  const state = req.params.state as JobState
41 41
   const asc = req.query.sort === 'createdAt'
42 42
 
43 43
   const jobs = await JobQueue.Instance.listForApi(state, req.query.start, req.query.count, asc)

+ 3
- 9
server/controllers/bots.ts View File

@@ -2,7 +2,6 @@ import * as express from 'express'
2 2
 import { asyncMiddleware } from '../middlewares'
3 3
 import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
4 4
 import * as sitemapModule from 'sitemap'
5
-import { logger } from '../helpers/logger'
6 5
 import { VideoModel } from '../models/video/video'
7 6
 import { VideoChannelModel } from '../models/video/video-channel'
8 7
 import { AccountModel } from '../models/account/account'
@@ -39,15 +38,10 @@ async function getSitemap (req: express.Request, res: express.Response) {
39 38
     urls: urls
40 39
   })
41 40
 
42
-  sitemap.toXML((err, xml) => {
43
-    if (err) {
44
-      logger.error('Cannot generate sitemap.', { err })
45
-      return res.sendStatus(500)
46
-    }
41
+  const xml = sitemap.toXML()
47 42
 
48
-    res.header('Content-Type', 'application/xml')
49
-    res.send(xml)
50
-  })
43
+  res.header('Content-Type', 'application/xml')
44
+  res.send(xml)
51 45
 }
52 46
 
53 47
 async function getSitemapVideoChannelUrls () {

+ 2
- 1
server/helpers/custom-validators/video-ownership.ts View File

@@ -3,7 +3,8 @@ import { VideoChangeOwnershipModel } from '../../models/video/video-change-owner
3 3
 import { MVideoChangeOwnershipFull } from '@server/typings/models/video/video-change-ownership'
4 4
 import { MUserId } from '@server/typings/models'
5 5
 
6
-export async function doesChangeVideoOwnershipExist (id: number, res: Response) {
6
+export async function doesChangeVideoOwnershipExist (idArg: number | string, res: Response) {
7
+  const id = parseInt(idArg + '', 10)
7 8
   const videoChangeOwnership = await VideoChangeOwnershipModel.load(id)
8 9
 
9 10
   if (!videoChangeOwnership) {

+ 2
- 1
server/helpers/middlewares/video-abuses.ts View File

@@ -1,7 +1,8 @@
1 1
 import { Response } from 'express'
2 2
 import { VideoAbuseModel } from '../../models/video/video-abuse'
3 3
 
4
-async function doesVideoAbuseExist (abuseId: number, videoId: number, res: Response) {
4
+async function doesVideoAbuseExist (abuseIdArg: number | string, videoId: number, res: Response) {
5
+  const abuseId = parseInt(abuseIdArg + '', 10)
5 6
   const videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, videoId)
6 7
 
7 8
   if (videoAbuse === null) {

+ 1
- 1
server/lib/activitypub/send/send-update.ts View File

@@ -55,7 +55,7 @@ async function sendUpdateActor (accountOrChannel: MChannelDefault | MAccountDefa
55 55
   logger.info('Creating job to update actor %s.', byActor.url)
56 56
 
57 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 59
   const audience = getAudience(byActor)
60 60
   const updateActivity = buildUpdateActivity(url, byActor, accountOrChannelObject, audience)
61 61
 

+ 14
- 4
server/middlewares/validators/redundancy.ts View File

@@ -25,8 +25,12 @@ const videoFileRedundancyGetValidator = [
25 25
     if (!await doesVideoExist(req.params.videoId, res)) return
26 26
 
27 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 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 36
     if (!videoFile) return res.status(404).json({ error: 'Video file not found.' })
@@ -41,8 +45,12 @@ const videoFileRedundancyGetValidator = [
41 45
 ]
42 46
 
43 47
 const videoPlaylistRedundancyGetValidator = [
44
-  param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'),
45
-  param('streamingPlaylistType').custom(exists).withMessage('Should have a valid streaming playlist type'),
48
+  param('videoId')
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 55
   async (req: express.Request, res: express.Response, next: express.NextFunction) => {
48 56
     logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params })
@@ -51,7 +59,9 @@ const videoPlaylistRedundancyGetValidator = [
51 59
     if (!await doesVideoExist(req.params.videoId, res)) return
52 60
 
53 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 66
     if (!videoStreamingPlaylist) return res.status(404).json({ error: 'Video playlist not found.' })
57 67
     res.locals.videoStreamingPlaylist = videoStreamingPlaylist

+ 2
- 1
server/middlewares/validators/users.ts View File

@@ -448,7 +448,8 @@ export {
448 448
 
449 449
 // ---------------------------------------------------------------------------
450 450
 
451
-function checkUserIdExist (id: number, res: express.Response) {
451
+function checkUserIdExist (idArg: number | string, res: express.Response) {
452
+  const id = parseInt(idArg + '', 10)
452 453
   return checkUserExist(() => UserModel.loadById(id), res)
453 454
 }
454 455
 

+ 4
- 2
server/middlewares/validators/videos/video-comments.ts View File

@@ -120,7 +120,8 @@ export {
120 120
 
121 121
 // ---------------------------------------------------------------------------
122 122
 
123
-async function doesVideoCommentThreadExist (id: number, video: MVideoId, res: express.Response) {
123
+async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) {
124
+  const id = parseInt(idArg + '', 10)
124 125
   const videoComment = await VideoCommentModel.loadById(id)
125 126
 
126 127
   if (!videoComment) {
@@ -151,7 +152,8 @@ async function doesVideoCommentThreadExist (id: number, video: MVideoId, res: ex
151 152
   return true
152 153
 }
153 154
 
154
-async function doesVideoCommentExist (id: number, video: MVideoId, res: express.Response) {
155
+async function doesVideoCommentExist (idArg: number | string, video: MVideoId, res: express.Response) {
156
+  const id = parseInt(idArg + '', 10)
155 157
   const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id)
156 158
 
157 159
   if (!videoComment) {

+ 1
- 1
server/models/account/account-video-rate.ts View File

@@ -150,7 +150,7 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
150 150
   static loadLocalAndPopulateVideo (
151 151
     rateType: VideoRateType,
152 152
     accountName: string,
153
-    videoId: number,
153
+    videoId: number | string,
154 154
     t?: Transaction
155 155
   ): Bluebird<MAccountVideoRateAccountVideo> {
156 156
     const options: FindOptions = {

+ 0
- 2
server/models/activitypub/actor.ts View File

@@ -430,8 +430,6 @@ export class ActorModel extends Model<ActorModel> {
430 430
   }
431 431
 
432 432
   toActivityPubObject (this: MActorAP, name: string) {
433
-    let activityPubType
434
-
435 433
     let icon = undefined
436 434
     if (this.avatarId) {
437 435
       const extension = extname(this.Avatar.filename)

+ 1
- 1
server/models/video/video-file.ts View File

@@ -99,7 +99,7 @@ export class VideoFileModel extends Model<VideoFileModel> {
99 99
   static doesInfohashExist (infoHash: string) {
100 100
     const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1'
101 101
     const options = {
102
-      type: QueryTypes.SELECT,
102
+      type: QueryTypes.SELECT as QueryTypes.SELECT,
103 103
       bind: { infoHash },
104 104
       raw: true
105 105
     }

+ 1
- 1
server/models/video/video-playlist-element.ts View File

@@ -181,7 +181,7 @@ export class VideoPlaylistElementModel extends Model<VideoPlaylistElementModel>
181 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 185
     return VideoPlaylistElementModel.findByPk(playlistElementId)
186 186
   }
187 187
 

+ 1
- 1
server/models/video/video-share.ts View File

@@ -90,7 +90,7 @@ export class VideoShareModel extends Model<VideoShareModel> {
90 90
   })
91 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 94
     return VideoShareModel.scope(ScopeNames.WITH_ACTOR).findOne({
95 95
       where: {
96 96
         actorId,

+ 1
- 1
server/models/video/video.ts View File

@@ -1608,7 +1608,7 @@ export class VideoModel extends Model<VideoModel> {
1608 1608
     'LIMIT 1'
1609 1609
 
1610 1610
     const options = {
1611
-      type: QueryTypes.SELECT,
1611
+      type: QueryTypes.SELECT as QueryTypes.SELECT,
1612 1612
       bind: { followerActorId, videoId },
1613 1613
       raw: true
1614 1614
     }

+ 5
- 1
tsconfig.json View File

@@ -14,7 +14,11 @@
14 14
       "es2016",
15 15
       "es2017"
16 16
     ],
17
-    "typeRoots": [ "node_modules/@types", "server/typings" ],
17
+    "typeRoots": [
18
+      "node_modules/sitemap/node_modules/@types",
19
+      "node_modules/@types",
20
+      "server/typings"
21
+    ],
18 22
     "baseUrl": "./",
19 23
     "paths": {
20 24
       "@server/*": [ "server/*" ],

+ 1146
- 1356
yarn.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save