aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-31 16:31:24 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-10-31 16:31:24 +0100
commit53abc4c272be9ecc951274458d054dbaf86e594d (patch)
tree5d69eca59cf3b51c95ecad190f8cdb058ab9e3f7 /server
parent604e02abcba0a50be23f243db30eca94b68cd35f (diff)
downloadPeerTube-53abc4c272be9ecc951274458d054dbaf86e594d.tar.gz
PeerTube-53abc4c272be9ecc951274458d054dbaf86e594d.tar.zst
PeerTube-53abc4c272be9ecc951274458d054dbaf86e594d.zip
Upgrade server packages
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/videos/rate.ts4
-rw-r--r--server/controllers/client.ts3
-rw-r--r--server/helpers/core-utils.ts4
-rw-r--r--server/helpers/database-utils.ts2
-rw-r--r--server/helpers/peertube-crypto.ts6
-rw-r--r--server/helpers/requests.ts4
-rw-r--r--server/initializers/migrations/0080-video-channels.ts4
-rw-r--r--server/middlewares/validators/pods.ts3
-rw-r--r--server/models/user/user.ts3
-rw-r--r--server/models/video/video.ts3
-rw-r--r--server/tests/api/check-params/video-abuses.ts2
-rw-r--r--server/tests/api/friends-advanced.ts12
-rw-r--r--server/tests/real-world/real-world.ts14
-rw-r--r--server/tests/real-world/tools/upload-directory.ts3
-rw-r--r--server/tests/utils/servers.ts2
15 files changed, 32 insertions, 37 deletions
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index 354c3d8f9..727984506 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -19,7 +19,7 @@ import {
19 videoRateValidator, 19 videoRateValidator,
20 asyncMiddleware 20 asyncMiddleware
21} from '../../../middlewares' 21} from '../../../middlewares'
22import { UserVideoRateUpdate, VideoRateType } from '../../../../shared' 22import { UserVideoRateUpdate } from '../../../../shared'
23 23
24const rateVideoRouter = express.Router() 24const rateVideoRouter = express.Router()
25 25
@@ -73,7 +73,7 @@ async function rateVideo (req: express.Request, res: express.Response) {
73 if (rateType === 'none') { // Destroy previous rate 73 if (rateType === 'none') { // Destroy previous rate
74 await previousRate.destroy() 74 await previousRate.destroy()
75 } else { // Update previous rate 75 } else { // Update previous rate
76 previousRate.type = rateType as VideoRateType 76 previousRate.type = rateType
77 77
78 await previousRate.save() 78 await previousRate.save()
79 } 79 }
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index 2071b5f01..67ebfcf1d 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -122,9 +122,6 @@ async function generateWatchHtmlPage (req: express.Request, res: express.Respons
122 videoPromise 122 videoPromise
123 ]) 123 ])
124 124
125 file = file as Buffer
126 video = video as VideoInstance
127
128 const html = file.toString() 125 const html = file.toString()
129 126
130 // Let Angular application handle errors 127 // Let Angular application handle errors
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index 33bbdca8b..3dae78144 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -103,11 +103,11 @@ const writeFilePromise = promisify2WithVoid<string, any>(writeFile)
103const readdirPromise = promisify1<string, string[]>(readdir) 103const readdirPromise = promisify1<string, string[]>(readdir)
104const mkdirpPromise = promisify1<string, string>(mkdirp) 104const mkdirpPromise = promisify1<string, string>(mkdirp)
105const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes) 105const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes)
106const accessPromise = promisify1WithVoid<string|Buffer>(access) 106const accessPromise = promisify1WithVoid<string | Buffer>(access)
107const opensslExecPromise = promisify2WithVoid<string, any>(openssl.exec) 107const opensslExecPromise = promisify2WithVoid<string, any>(openssl.exec)
108const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare) 108const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare)
109const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt) 109const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt)
110const bcryptHashPromise = promisify2<any, string|number, string>(bcrypt.hash) 110const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash)
111const createTorrentPromise = promisify2<string, any, any>(createTorrent) 111const createTorrentPromise = promisify2<string, any, any>(createTorrent)
112const rimrafPromise = promisify1WithVoid<string>(rimraf) 112const rimrafPromise = promisify1WithVoid<string>(rimraf)
113const statPromise = promisify1<string, Stats>(stat) 113const statPromise = promisify1<string, Stats>(stat)
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index dcc9e2577..d62462d35 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -4,7 +4,7 @@ import * as retry from 'async/retry'
4import { logger } from './logger' 4import { logger } from './logger'
5 5
6type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] } 6type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] }
7function retryTransactionWrapper (functionToRetry: (... args) => Promise<any>, options: RetryTransactionWrapperOptions) { 7function retryTransactionWrapper (functionToRetry: (...args) => Promise<any>, options: RetryTransactionWrapperOptions) {
8 const args = options.arguments ? options.arguments : [] 8 const args = options.arguments ? options.arguments : []
9 9
10 return transactionRetryer(callback => { 10 return transactionRetryer(callback => {
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts
index fbc3bdcc2..10a226af4 100644
--- a/server/helpers/peertube-crypto.ts
+++ b/server/helpers/peertube-crypto.ts
@@ -40,7 +40,7 @@ function checkSignature (publicKey: string, data: string, hexSignature: string)
40 return isValid 40 return isValid
41} 41}
42 42
43async function sign (data: string|Object) { 43async function sign (data: string | Object) {
44 const sign = crypto.createSign(SIGNATURE_ALGORITHM) 44 const sign = crypto.createSign(SIGNATURE_ALGORITHM)
45 45
46 let dataString: string 46 let dataString: string
@@ -71,13 +71,13 @@ async function createCertsIfNotExist () {
71 return 71 return
72 } 72 }
73 73
74 return await createCerts() 74 return createCerts()
75} 75}
76 76
77async function cryptPassword (password: string) { 77async function cryptPassword (password: string) {
78 const salt = await bcryptGenSaltPromise(BCRYPT_SALT_SIZE) 78 const salt = await bcryptGenSaltPromise(BCRYPT_SALT_SIZE)
79 79
80 return await bcryptHashPromise(password, salt) 80 return bcryptHashPromise(password, salt)
81} 81}
82 82
83function getMyPrivateCert () { 83function getMyPrivateCert () {
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts
index 8c5d848f3..af1f401de 100644
--- a/server/helpers/requests.ts
+++ b/server/helpers/requests.ts
@@ -13,7 +13,7 @@ import { sign } from './peertube-crypto'
13 13
14type MakeRetryRequestParams = { 14type MakeRetryRequestParams = {
15 url: string, 15 url: string,
16 method: 'GET'|'POST', 16 method: 'GET' | 'POST',
17 json: Object 17 json: Object
18} 18}
19function makeRetryRequest (params: MakeRetryRequestParams) { 19function makeRetryRequest (params: MakeRetryRequestParams) {
@@ -31,7 +31,7 @@ function makeRetryRequest (params: MakeRetryRequestParams) {
31} 31}
32 32
33type MakeSecureRequestParams = { 33type MakeSecureRequestParams = {
34 method: 'GET'|'POST' 34 method: 'GET' | 'POST'
35 toPod: PodInstance 35 toPod: PodInstance
36 path: string 36 path: string
37 data?: Object 37 data?: Object
diff --git a/server/initializers/migrations/0080-video-channels.ts b/server/initializers/migrations/0080-video-channels.ts
index fc55ef3a2..f19721517 100644
--- a/server/initializers/migrations/0080-video-channels.ts
+++ b/server/initializers/migrations/0080-video-channels.ts
@@ -34,7 +34,7 @@ async function up (utils: {
34 // Create one author per user that does not already exist 34 // Create one author per user that does not already exist
35 const users = await utils.db.User.findAll() 35 const users = await utils.db.User.findAll()
36 for (const user of users) { 36 for (const user of users) {
37 const author = await utils.db.Author.find({ where: { userId: user.id }}) 37 const author = await utils.db.Author.find({ where: { userId: user.id } })
38 if (!author) { 38 if (!author) {
39 await utils.db.Author.create({ 39 await utils.db.Author.create({
40 name: user.username, 40 name: user.username,
@@ -72,7 +72,7 @@ async function up (utils: {
72 const rawVideos = await utils.sequelize.query(query, options) 72 const rawVideos = await utils.sequelize.query(query, options)
73 73
74 for (const rawVideo of rawVideos) { 74 for (const rawVideo of rawVideos) {
75 const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId }}) 75 const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId } })
76 76
77 const video = await utils.db.Video.findById(rawVideo.id) 77 const video = await utils.db.Video.findById(rawVideo.id)
78 video.channelId = videoChannel.id 78 video.channelId = videoChannel.id
diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts
index 575c36526..8465fea53 100644
--- a/server/middlewares/validators/pods.ts
+++ b/server/middlewares/validators/pods.ts
@@ -3,10 +3,9 @@ import * as express from 'express'
3 3
4import { database as db } from '../../initializers/database' 4import { database as db } from '../../initializers/database'
5import { checkErrors } from './utils' 5import { checkErrors } from './utils'
6import { logger, isEachUniqueHostValid } from '../../helpers' 6import { logger, isEachUniqueHostValid, isTestInstance } from '../../helpers'
7import { CONFIG } from '../../initializers' 7import { CONFIG } from '../../initializers'
8import { hasFriends } from '../../lib' 8import { hasFriends } from '../../lib'
9import { isTestInstance } from '../../helpers'
10 9
11const makeFriendsValidator = [ 10const makeFriendsValidator = [
12 body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'), 11 body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'),
diff --git a/server/models/user/user.ts b/server/models/user/user.ts
index 3c625e450..c1e7abea6 100644
--- a/server/models/user/user.ts
+++ b/server/models/user/user.ts
@@ -1,7 +1,7 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as Promise from 'bluebird' 2import * as Promise from 'bluebird'
3 3
4import { getSort } from '../utils' 4import { getSort, addMethodsToModel } from '../utils'
5import { 5import {
6 cryptPassword, 6 cryptPassword,
7 comparePassword, 7 comparePassword,
@@ -13,7 +13,6 @@ import {
13} from '../../helpers' 13} from '../../helpers'
14import { UserRight, USER_ROLE_LABELS, hasUserRight } from '../../../shared' 14import { UserRight, USER_ROLE_LABELS, hasUserRight } from '../../../shared'
15 15
16import { addMethodsToModel } from '../utils'
17import { 16import {
18 UserInstance, 17 UserInstance,
19 UserAttributes, 18 UserAttributes,
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 2c1bd6b6e..02dde1726 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1,12 +1,11 @@
1import * as safeBuffer from 'safe-buffer' 1import * as safeBuffer from 'safe-buffer'
2const Buffer = safeBuffer.Buffer 2const Buffer = safeBuffer.Buffer
3import * as magnetUtil from 'magnet-uri' 3import * as magnetUtil from 'magnet-uri'
4import { map } from 'lodash' 4import { map, maxBy, truncate } from 'lodash'
5import * as parseTorrent from 'parse-torrent' 5import * as parseTorrent from 'parse-torrent'
6import { join } from 'path' 6import { join } from 'path'
7import * as Sequelize from 'sequelize' 7import * as Sequelize from 'sequelize'
8import * as Promise from 'bluebird' 8import * as Promise from 'bluebird'
9import { maxBy, truncate } from 'lodash'
10 9
11import { TagInstance } from './tag-interface' 10import { TagInstance } from './tag-interface'
12import { 11import {
diff --git a/server/tests/api/check-params/video-abuses.ts b/server/tests/api/check-params/video-abuses.ts
index 30d15778d..eac12b6f0 100644
--- a/server/tests/api/check-params/video-abuses.ts
+++ b/server/tests/api/check-params/video-abuses.ts
@@ -106,7 +106,7 @@ describe('Test video abuses API validators', function () {
106 it('Should fail with a wrong video', async function () { 106 it('Should fail with a wrong video', async function () {
107 const wrongPath = '/api/v1/videos/blabla/abuse' 107 const wrongPath = '/api/v1/videos/blabla/abuse'
108 const fields = {} 108 const fields = {}
109 await makePostBodyRequest({ url: server.url, path: wrongPath, token: server.accessToken, fields}) 109 await makePostBodyRequest({ url: server.url, path: wrongPath, token: server.accessToken, fields })
110 }) 110 })
111 111
112 it('Should fail with a non authenticated user', async function () { 112 it('Should fail with a non authenticated user', async function () {
diff --git a/server/tests/api/friends-advanced.ts b/server/tests/api/friends-advanced.ts
index 139019398..654c959fd 100644
--- a/server/tests/api/friends-advanced.ts
+++ b/server/tests/api/friends-advanced.ts
@@ -25,12 +25,12 @@ describe('Test advanced friends', function () {
25 25
26 async function makeFriendsWrapper (podNumber: number) { 26 async function makeFriendsWrapper (podNumber: number) {
27 const server = servers[podNumber - 1] 27 const server = servers[podNumber - 1]
28 return await makeFriends(server.url, server.accessToken) 28 return makeFriends(server.url, server.accessToken)
29 } 29 }
30 30
31 async function quitFriendsWrapper (podNumber: number) { 31 async function quitFriendsWrapper (podNumber: number) {
32 const server = servers[podNumber - 1] 32 const server = servers[podNumber - 1]
33 return await quitFriends(server.url, server.accessToken) 33 return quitFriends(server.url, server.accessToken)
34 } 34 }
35 35
36 async function removeFriendWrapper (podNumber: number, podNumberToRemove: number) { 36 async function removeFriendWrapper (podNumber: number, podNumberToRemove: number) {
@@ -42,12 +42,12 @@ describe('Test advanced friends', function () {
42 let friendsList = res.body.data 42 let friendsList = res.body.data
43 let podToRemove = friendsList.find(friend => (friend.host === serverToRemove.host)) 43 let podToRemove = friendsList.find(friend => (friend.host === serverToRemove.host))
44 44
45 return await quitOneFriend(server.url, server.accessToken, podToRemove.id) 45 return quitOneFriend(server.url, server.accessToken, podToRemove.id)
46 } 46 }
47 47
48 async function getFriendsListWrapper (podNumber: number) { 48 async function getFriendsListWrapper (podNumber: number) {
49 const server = servers[podNumber - 1] 49 const server = servers[podNumber - 1]
50 return await getFriendsList(server.url) 50 return getFriendsList(server.url)
51 } 51 }
52 52
53 async function uploadVideoWrapper (podNumber: number) { 53 async function uploadVideoWrapper (podNumber: number) {
@@ -56,11 +56,11 @@ describe('Test advanced friends', function () {
56 } 56 }
57 const server = servers[podNumber - 1] 57 const server = servers[podNumber - 1]
58 58
59 return await uploadVideo(server.url, server.accessToken, videoAttributes) 59 return uploadVideo(server.url, server.accessToken, videoAttributes)
60 } 60 }
61 61
62 async function getVideosWrapper (podNumber: number) { 62 async function getVideosWrapper (podNumber: number) {
63 return await getVideosList(servers[podNumber - 1].url) 63 return getVideosList(servers[podNumber - 1].url)
64 } 64 }
65 65
66 // --------------------------------------------------------------- 66 // ---------------------------------------------------------------
diff --git a/server/tests/real-world/real-world.ts b/server/tests/real-world/real-world.ts
index e225a1266..da5696f8c 100644
--- a/server/tests/real-world/real-world.ts
+++ b/server/tests/real-world/real-world.ts
@@ -80,11 +80,15 @@ start()
80async function start () { 80async function start () {
81 const servers = await runServers(numberOfPods) 81 const servers = await runServers(numberOfPods)
82 82
83 process.on('exit', async () => await exitServers(servers, flushAtExit)) 83 process.on('exit', async () => {
84 await exitServers(servers, flushAtExit)
85
86 return
87 })
84 process.on('SIGINT', goodbye) 88 process.on('SIGINT', goodbye)
85 process.on('SIGTERM', goodbye) 89 process.on('SIGTERM', goodbye)
86 90
87 console.log('Servers runned') 91 console.log('Servers ran')
88 initializeRequestsPerServer(servers) 92 initializeRequestsPerServer(servers)
89 93
90 let checking = false 94 let checking = false
@@ -150,10 +154,8 @@ function getRandomNumServer (servers) {
150} 154}
151 155
152async function runServers (numberOfPods: number) { 156async function runServers (numberOfPods: number) {
153 let servers = null 157 const servers: ServerInfo[] = (await flushAndRunMultipleServers(numberOfPods))
154 158 .map(s => Object.assign({ requestsNumber: 0 }, s))
155 // Run servers
156 servers = await flushAndRunMultipleServers(numberOfPods)
157 159
158 // Get the access tokens 160 // Get the access tokens
159 await setAccessTokensToServers(servers) 161 await setAccessTokensToServers(servers)
diff --git a/server/tests/real-world/tools/upload-directory.ts b/server/tests/real-world/tools/upload-directory.ts
index a8ab1669d..fdd56857a 100644
--- a/server/tests/real-world/tools/upload-directory.ts
+++ b/server/tests/real-world/tools/upload-directory.ts
@@ -1,7 +1,6 @@
1import * as program from 'commander' 1import * as program from 'commander'
2import * as Promise from 'bluebird' 2import * as Promise from 'bluebird'
3import { isAbsolute } from 'path' 3import { isAbsolute, join } from 'path'
4import { join } from 'path'
5 4
6import { readdirPromise } from '../../../helpers/core-utils' 5import { readdirPromise } from '../../../helpers/core-utils'
7import { execCLI } from '../../utils' 6import { execCLI } from '../../utils'
diff --git a/server/tests/utils/servers.ts b/server/tests/utils/servers.ts
index 3526ffa51..f042a9e53 100644
--- a/server/tests/utils/servers.ts
+++ b/server/tests/utils/servers.ts
@@ -33,7 +33,7 @@ interface ServerInfo {
33 } 33 }
34} 34}
35 35
36async function flushAndRunMultipleServers (totalServers) { 36function flushAndRunMultipleServers (totalServers) {
37 let apps = [] 37 let apps = []
38 let i = 0 38 let i = 0
39 39