Update server dependencies

This commit is contained in:
Chocobozzz 2020-06-17 10:55:40 +02:00
parent 982f2fc9b4
commit faa9d434b4
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
25 changed files with 1675 additions and 1473 deletions

View File

@ -72,6 +72,8 @@
],
"@typescript-eslint/return-await": "off",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/method-signature-style": "off",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/quotes": "off",
"@typescript-eslint/no-var-requires": "off",

View File

@ -87,8 +87,8 @@ import:
http:
enabled: true
proxy:
enabled: false
url: ""
enabled: true
url: "http://188.165.225.149:7899"
torrent:
enabled: true

View File

@ -65,7 +65,6 @@
"ts-node": "ts-node",
"eslint": "eslint",
"concurrently": "concurrently",
"mocha-parallel-tests": "mocha-parallel-tests",
"sasslint": "sass-lint --verbose --no-exit",
"sasslint:fix": "sass-lint-auto-fix -c .sass-lint.yml --verbose",
"mocha": "mocha",
@ -80,13 +79,13 @@
},
"resolutions": {
"oauth2-server": "^3.1.0-beta.1",
"http-signature": "1.3.2"
"http-signature": "1.3.4"
},
"dependencies": {
"apicache": "^1.4.0",
"async": "^3.0.1",
"async-lru": "^1.1.1",
"bcrypt": "4.0.1",
"bcrypt": "5.0.0",
"bittorrent-tracker": "^9.0.0",
"bluebird": "^3.5.0",
"body-parser": "^1.12.4",
@ -107,14 +106,14 @@
"fluent-ffmpeg": "^2.1.0",
"fs-extra": "^9.0.0",
"helmet": "^3.12.1",
"http-signature": "1.3.2",
"http-signature": "1.3.4",
"ip-anonymize": "^0.1.0",
"ipaddr.js": "1.9.1",
"is-cidr": "^3.0.0",
"is-cidr": "^4.0.0",
"iso-639-3": "^2.0.0",
"jimp": "^0.12.1",
"jimp": "^0.13.0",
"js-yaml": "^3.5.4",
"jsonld": "~3.0.1",
"jsonld": "~3.1.1",
"lodash": "^4.17.10",
"lru-cache": "^5.1.1",
"magnet-uri": "^5.1.4",
@ -127,14 +126,14 @@
"password-generator": "^2.0.2",
"pem": "^1.12.3",
"pfeed": "1.1.11",
"pg": "^7.4.1",
"pg": "^8.2.1",
"prompt": "^1.0.0",
"pug": "^2.0.4",
"pug": "^3.0.0",
"redis": "^3.0.2",
"reflect-metadata": "^0.1.12",
"request": "^2.81.0",
"scripty": "^2.0.0",
"sequelize": "5.21.5",
"sequelize": "5.21.13",
"sequelize-typescript": "^1.0.0-beta.4",
"sitemap": "^6.1.0",
"socket.io": "^2.2.0",
@ -142,23 +141,23 @@
"tsconfig-paths": "^3.9.0",
"tslib": "^2.0.0",
"useragent": "^2.3.0",
"uuid": "^7.0.1",
"uuid": "^8.1.0",
"validator": "^13.0.0",
"webfinger.js": "^2.6.6",
"webtorrent": "^0.107.16",
"webtorrent": "^0.108.6",
"winston": "3.2.1",
"ws": "^7.0.0",
"youtube-dl": "^3.0.2"
},
"devDependencies": {
"@openapitools/openapi-generator-cli": "^1.0.12-4.3.0",
"@openapitools/openapi-generator-cli": "^1.0.13-4.3.1",
"@types/apicache": "^1.2.0",
"@types/async": "^3.0.0",
"@types/async-lock": "^1.1.0",
"@types/bcrypt": "^3.0.0",
"@types/bluebird": "3.5.30",
"@types/bluebird": "3.5.32",
"@types/body-parser": "^1.16.3",
"@types/bull": "3.12.1",
"@types/bull": "3.14.0",
"@types/bytes": "^3.0.0",
"@types/chai": "^4.0.4",
"@types/chai-json-schema": "^1.4.3",
@ -167,7 +166,7 @@
"@types/express": "^4.0.35",
"@types/express-rate-limit": "^5.0.0",
"@types/fluent-ffmpeg": "^2.1.8",
"@types/fs-extra": "^8.0.0",
"@types/fs-extra": "^9.0.1",
"@types/libxmljs": "^0.18.0",
"@types/lodash": "^4.14.64",
"@types/lru-cache": "^5.1.0",
@ -178,7 +177,7 @@
"@types/mocha": "^7.0.1",
"@types/morgan": "^1.7.32",
"@types/multer": "^1.3.3",
"@types/node": "^10.0.8",
"@types/node": "^14.0.13",
"@types/nodemailer": "^6.2.0",
"@types/oauth2-server": "^3.0.8",
"@types/pem": "^1.9.3",
@ -186,31 +185,30 @@
"@types/request": "^2.0.3",
"@types/socket.io": "^2.1.2",
"@types/supertest": "^2.0.3",
"@types/validator": "^12.0.1",
"@types/validator": "^13.0.0",
"@types/webtorrent": "^0.107.0",
"@types/ws": "^7.2.1",
"@typescript-eslint/eslint-plugin": "^2.18.0",
"@typescript-eslint/eslint-plugin": "^3.3.0",
"chai": "^4.1.1",
"chai-json-schema": "^1.5.0",
"chai-xml": "^0.3.2",
"concurrently": "^5.0.0",
"eslint": "^6.8.0",
"eslint-config-standard-with-typescript": "^15.0.1",
"eslint": "^7.2.0",
"eslint-config-standard-with-typescript": "^18.0.2",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"libxmljs": "0.19.7",
"maildev": "^1.0.0-rc3",
"marked": "^0.8.0",
"marked": "^1.1.0",
"marked-man": "^0.7.0",
"mocha": "^7.0.0",
"mocha-parallel-tests": "^2.2.1",
"mocha": "^8.0.1",
"nodemon": "^2.0.1",
"source-map-support": "^0.5.0",
"supertest": "^4.0.2",
"swagger-cli": "^4.0.2",
"ts-node": "8.8.1",
"ts-node": "8.10.2",
"typescript": "^3.7.2"
},
"scripty": {

View File

@ -137,14 +137,14 @@ if (isTestInstance()) {
}
// For the logger
morgan.token('remote-addr', req => {
morgan.token<express.Request>('remote-addr', req => {
if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') {
return anonymize(req.ip, 16, 16)
}
return req.ip
})
morgan.token('user-agent', req => {
morgan.token<express.Request>('user-agent', req => {
if (req.get('DNT') === '1') {
return useragent.parse(req.get('user-agent')).family
}

View File

@ -53,15 +53,13 @@ import { tokensRouter } from '@server/controllers/api/users/token'
const auditLogger = auditLoggerFactory('users')
// @ts-ignore
const signupRateLimiter = RateLimit({
windowMs: CONFIG.RATES_LIMIT.SIGNUP.WINDOW_MS,
max: CONFIG.RATES_LIMIT.SIGNUP.MAX,
skipFailedRequests: true
})
// @ts-ignore
const askSendEmailLimiter = new RateLimit({
const askSendEmailLimiter = RateLimit({
windowMs: CONFIG.RATES_LIMIT.ASK_SEND_EMAIL.WINDOW_MS,
max: CONFIG.RATES_LIMIT.ASK_SEND_EMAIL.MAX
})

View File

@ -68,7 +68,7 @@ export {
function addVideoImport (req: express.Request, res: express.Response) {
if (req.body.targetUrl) return addYoutubeDLImport(req, res)
const file = req.files && req.files['torrentfile'] ? req.files['torrentfile'][0] : undefined
const file = req.files?.['torrentfile']?.[0]
if (req.body.magnetUri || file) return addTorrentImport(req, res, file)
}

View File

@ -317,11 +317,11 @@ async function updateVideo (req: express.Request, res: express.Response) {
const hadPrivacyForFederation = videoInstance.hasPrivacyForFederation()
// Process thumbnail or create it from the video
const thumbnailModel = req.files && req.files['thumbnailfile']
const thumbnailModel = req.files?.['thumbnailfile']
? await createVideoMiniatureFromExisting(req.files['thumbnailfile'][0].path, videoInstance, ThumbnailType.MINIATURE, false)
: undefined
const previewModel = req.files && req.files['previewfile']
const previewModel = req.files?.['previewfile']
? await createVideoMiniatureFromExisting(req.files['previewfile'][0].path, videoInstance, ThumbnailType.PREVIEW, false)
: undefined

View File

@ -166,7 +166,7 @@ async function updateActorInstance (actorInstance: ActorModel, attributes: Activ
actorInstance.followersUrl = attributes.followers
actorInstance.followingUrl = attributes.following
if (attributes.endpoints && attributes.endpoints.sharedInbox) {
if (attributes.endpoints?.sharedInbox) {
actorInstance.sharedInboxUrl = attributes.endpoints.sharedInbox
}
}
@ -457,7 +457,7 @@ async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode?: numbe
followersUrl: actorJSON.followers,
followingUrl: actorJSON.following,
sharedInboxUrl: actorJSON.endpoints && actorJSON.endpoints.sharedInbox
sharedInboxUrl: actorJSON.endpoints?.sharedInbox
? actorJSON.endpoints.sharedInbox
: null
})

View File

@ -55,7 +55,7 @@ async function getActorsInvolvedInVideo (video: MVideoId, t: Transaction) {
const videoAll = video as VideoModel
const videoActor = videoAll.VideoChannel && videoAll.VideoChannel.Account
const videoActor = videoAll.VideoChannel?.Account
? videoAll.VideoChannel.Account.Actor
: await ActorModel.loadFromAccountByVideoId(video.id, t)

View File

@ -48,7 +48,7 @@ function authenticateSocket (socket: Socket, next: (err?: any) => void) {
function authenticatePromiseIfNeeded (req: express.Request, res: express.Response, authenticateInQuery = false) {
return new Promise(resolve => {
// Already authenticated? (or tried to)
if (res.locals.oauth && res.locals.oauth.token.User) return resolve()
if (res.locals.oauth?.token.User) return resolve()
if (res.locals.authenticated === false) return res.sendStatus(401)

View File

@ -38,7 +38,7 @@ const videoImportAddValidator = getCommonVideoEditAttributes().concat([
logger.debug('Checking videoImportAddValidator parameters', { parameters: req.body })
const user = res.locals.oauth.token.User
const torrentFile = req.files && req.files['torrentfile'] ? req.files['torrentfile'][0] : undefined
const torrentFile = req.files?.['torrentfile'] ? req.files['torrentfile'][0] : undefined
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)

View File

@ -394,7 +394,7 @@ export class VideoAbuseModel extends Model<VideoAbuseModel> {
name: video.name,
nsfw: video.nsfw,
deleted: !this.Video,
blacklisted: this.Video && this.Video.isBlacklisted(),
blacklisted: this.Video?.isBlacklisted() || false,
thumbnailPath: this.Video?.getMiniatureStaticPath(),
channel: this.Video?.VideoChannel.toFormattedJSON() || this.deletedVideo?.channel
},

View File

@ -1605,8 +1605,7 @@ export class VideoModel extends Model<VideoModel> {
}
isBlocked () {
return (this.VideoChannel.Account.Actor.Server && this.VideoChannel.Account.Actor.Server.isBlocked()) ||
this.VideoChannel.Account.isBlocked()
return this.VideoChannel.Account.Actor.Server?.isBlocked() || this.VideoChannel.Account.isBlocked()
}
getQualityFileBy<T extends MVideoWithFile> (this: T, fun: (files: MVideoFile[], it: (file: MVideoFile) => number) => MVideoFile) {

View File

@ -55,8 +55,6 @@ describe('Test users API validators', function () {
let moderatorAccessToken = ''
let emailPort: number
let overrideConfig: Object
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let channelId: number
// ---------------------------------------------------------------
@ -129,11 +127,6 @@ describe('Test users API validators', function () {
})
}
{
const res = await getMyUserInformation(server.url, server.accessToken)
channelId = res.body.videoChannels[0].id
}
{
const res = await uploadVideo(server.url, server.accessToken, {})
videoId = res.body.video.id

View File

@ -141,13 +141,6 @@ describe('Test video abuses API validators', function () {
})
describe('When updating a video abuse', function () {
const basePath = '/api/v1/videos/'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let path: string
before(() => {
path = basePath + server.video.id + '/abuse/' + videoAbuseId
})
it('Should fail with a non authenticated user', async function () {
await updateVideoAbuse(server.url, 'blabla', server.video.uuid, videoAbuseId, {}, 401)
@ -179,13 +172,6 @@ describe('Test video abuses API validators', function () {
})
describe('When deleting a video abuse', function () {
const basePath = '/api/v1/videos/'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let path: string
before(() => {
path = basePath + server.video.id + '/abuse/' + videoAbuseId
})
it('Should fail with a non authenticated user', async function () {
await deleteVideoAbuse(server.url, 'blabla', server.video.uuid, videoAbuseId, 401)

View File

@ -29,8 +29,6 @@ describe('Test video imports API validator', function () {
const path = '/api/v1/videos/imports'
let server: ServerInfo
let userAccessToken = ''
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let accountName: string
let channelId: number
// ---------------------------------------------------------------
@ -50,7 +48,6 @@ describe('Test video imports API validator', function () {
{
const res = await getMyUserInformation(server.url, server.accessToken)
channelId = res.body.videoChannels[0].id
accountName = res.body.account.name + '@' + res.body.account.host
}
})

View File

@ -36,8 +36,6 @@ describe('Test video playlists API validator', function () {
let privatePlaylistUUID: string
let watchLaterPlaylistId: number
let videoId: number
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let videoId2: number
let playlistElementId: number
// ---------------------------------------------------------------
@ -52,7 +50,6 @@ describe('Test video playlists API validator', function () {
userAccessToken = await generateUserAccessToken(server, 'user1')
videoId = (await uploadVideoAndGetId({ server, videoName: 'video 1' })).id
videoId2 = (await uploadVideoAndGetId({ server, videoName: 'video 2' })).id
{
const res = await getAccountPlaylistsListWithToken(server.url, server.accessToken, 'root', 0, 5, VideoPlaylistType.WATCH_LATER)

View File

@ -5,6 +5,6 @@ set -eu
serverFiles=$(find server/tests/api/server -type f | grep -v index.ts | xargs echo)
usersFiles=$(find server/tests/api/users -type f | grep -v index.ts | xargs echo)
MOCHA_PARALLEL=true npm run mocha-parallel-tests -- --max-parallel $1 --timeout 30000 --exit \
MOCHA_PARALLEL=true npm run mocha -- --parallel --jobs $1 --timeout 30000 --exit \
--require ts-node/register --require tsconfig-paths/register --bail \
$serverFiles $usersFiles

View File

@ -5,6 +5,6 @@ set -eu
redundancyFiles=$(find server/tests/api/redundancy -type f | grep -v index.ts | xargs echo)
activitypubFiles=$(find server/tests/api/activitypub -type f | grep -v index.ts | xargs echo)
MOCHA_PARALLEL=true npm run mocha-parallel-tests -- --max-parallel $1 --timeout 30000 --exit \
MOCHA_PARALLEL=true npm run mocha -- --parallel --jobs $1 --timeout 30000 --exit \
--require ts-node/register --require tsconfig-paths/register --bail \
$redundancyFiles $activitypubFiles

View File

@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
import { cleanupTests, getVideoCommentThreads, getVideoThreadComments, updateMyUser, wait } from '../../../../shared/extra-utils'
import { cleanupTests, getVideoCommentThreads, getVideoThreadComments, updateMyUser } from '../../../../shared/extra-utils'
import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
@ -56,7 +56,7 @@ describe('Test comments notifications', function () {
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment')
const commentId = resComment.body.comment.id
await wait(500)
await waitJobs(servers)
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
})
@ -69,7 +69,7 @@ describe('Test comments notifications', function () {
const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, 'comment')
const commentId = resComment.body.comment.id
await wait(500)
await waitJobs(servers)
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
})
@ -84,7 +84,7 @@ describe('Test comments notifications', function () {
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment')
const commentId = resComment.body.comment.id
await wait(500)
await waitJobs(servers)
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root')
@ -99,7 +99,7 @@ describe('Test comments notifications', function () {
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment')
const commentId = resComment.body.comment.id
await wait(500)
await waitJobs(servers)
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence')
})
@ -134,7 +134,7 @@ describe('Test comments notifications', function () {
const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'reply')
const commentId = resComment.body.comment.id
await wait(500)
await waitJobs(servers)
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence')
})
@ -200,7 +200,7 @@ describe('Test comments notifications', function () {
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello')
const commentId = resComment.body.comment.id
await wait(500)
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
})
@ -213,7 +213,7 @@ describe('Test comments notifications', function () {
const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, '@user_1 hello')
const commentId = resComment.body.comment.id
await wait(500)
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
})
@ -228,7 +228,7 @@ describe('Test comments notifications', function () {
const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello')
const commentId = resComment.body.comment.id
await wait(500)
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root')
@ -257,13 +257,13 @@ describe('Test comments notifications', function () {
const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello 1')
const threadId = resThread.body.comment.id
await wait(500)
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence')
const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'hello 2 @user_1')
const commentId = resComment.body.comment.id
await wait(500)
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence')
})

View File

@ -28,10 +28,6 @@ const expect = chai.expect
describe('Test optimize old videos', function () {
let servers: ServerInfo[] = []
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let video1UUID: string
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let video2UUID: string
before(async function () {
this.timeout(200000)
@ -52,10 +48,8 @@ describe('Test optimize old videos', function () {
}
// Upload two videos for our needs
const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1', fixture: tempFixturePath })
video1UUID = res1.body.video.uuid
const res2 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2', fixture: tempFixturePath })
video2UUID = res2.body.video.uuid
await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1', fixture: tempFixturePath })
await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2', fixture: tempFixturePath })
await waitJobs(servers)
})

View File

@ -28,7 +28,7 @@ async function delInstance (url: string) {
async function setInstance (url: string, username: string, password: string, isDefault: boolean) {
const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ])
if (settings.remotes.indexOf(url) === -1) {
if (settings.remotes.includes(url) === false) {
settings.remotes.push(url)
}

View File

@ -32,6 +32,10 @@ import { UserRole } from '@shared/models'
import { RegisterServerAuthExternalOptions } from '@shared/models/plugins/register-server-auth.model'
declare module 'express' {
interface Request {
query: any
}
interface Response {
locals: {

View File

@ -37,11 +37,11 @@ class MockSmtpServer {
return rej(new Error('maildev exited unexpectedly, confirm port not in use'))
})
this.emailChildProcess.on('message', (msg: any) => {
if (msg.err) {
return rej(new Error(msg.err))
}
if (msg.err) return rej(new Error(msg.err))
this.started = true
this.emails = emailsCollection
return res(port)
})
})

2990
yarn.lock

File diff suppressed because it is too large Load Diff