diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-05-22 20:58:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-05-25 17:32:16 +0200 |
commit | e02643f32e4c97ca307f8fc5b69be79c40d70a3b (patch) | |
tree | b7f6269913cd5a0e4f26a9461a043deb0c168be0 /server/lib | |
parent | 65fcc3119c334b75dd13bcfdebf186afdc580a8f (diff) | |
download | PeerTube-e02643f32e4c97ca307f8fc5b69be79c40d70a3b.tar.gz PeerTube-e02643f32e4c97ca307f8fc5b69be79c40d70a3b.tar.zst PeerTube-e02643f32e4c97ca307f8fc5b69be79c40d70a3b.zip |
Type models
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/friends.ts | 6 | ||||
-rw-r--r-- | server/lib/jobs/handlers/video-transcoder.ts | 2 | ||||
-rw-r--r-- | server/lib/jobs/job-scheduler.ts | 6 | ||||
-rw-r--r-- | server/lib/oauth-model.ts | 4 | ||||
-rw-r--r-- | server/lib/request/base-request-scheduler.ts | 4 | ||||
-rw-r--r-- | server/lib/request/request-scheduler.ts | 9 | ||||
-rw-r--r-- | server/lib/request/request-video-event-scheduler.ts | 2 | ||||
-rw-r--r-- | server/lib/request/request-video-qadu-scheduler.ts | 2 |
8 files changed, 18 insertions, 17 deletions
diff --git a/server/lib/friends.ts b/server/lib/friends.ts index b32783019..08b776e83 100644 --- a/server/lib/friends.ts +++ b/server/lib/friends.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { each, eachLimit, eachSeries, series, waterfall } from 'async' | 1 | import { each, eachLimit, eachSeries, series, waterfall } from 'async' |
2 | import request = require('request') | 2 | import request = require('request') |
3 | 3 | ||
4 | const db = require('../initializers/database') | 4 | import { database as db } from '../initializers/database' |
5 | import { | 5 | import { |
6 | API_VERSION, | 6 | API_VERSION, |
7 | CONFIG, | 7 | CONFIG, |
@@ -329,7 +329,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) { | |||
329 | // Flush pool requests | 329 | // Flush pool requests |
330 | requestScheduler.forceSend() | 330 | requestScheduler.forceSend() |
331 | 331 | ||
332 | eachLimit(podsList, REQUESTS_IN_PARALLEL, function (pod: any, callbackEach) { | 332 | eachLimit(podsList, REQUESTS_IN_PARALLEL, function (pod: { host: string }, callbackEach) { |
333 | const params = { | 333 | const params = { |
334 | url: REMOTE_SCHEME.HTTP + '://' + pod.host + '/api/' + API_VERSION + '/pods/', | 334 | url: REMOTE_SCHEME.HTTP + '://' + pod.host + '/api/' + API_VERSION + '/pods/', |
335 | method: 'POST', | 335 | method: 'POST', |
@@ -340,7 +340,7 @@ function makeRequestsToWinningPods (cert, podsList, callback) { | |||
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | makeRetryRequest(params, function (err, res, body) { | 343 | makeRetryRequest(params, function (err, res, body: { cert: string, email: string }) { |
344 | if (err) { | 344 | if (err) { |
345 | logger.error('Error with adding %s pod.', pod.host, { error: err }) | 345 | logger.error('Error with adding %s pod.', pod.host, { error: err }) |
346 | // Don't break the process | 346 | // Don't break the process |
diff --git a/server/lib/jobs/handlers/video-transcoder.ts b/server/lib/jobs/handlers/video-transcoder.ts index 35db5fb96..43599356a 100644 --- a/server/lib/jobs/handlers/video-transcoder.ts +++ b/server/lib/jobs/handlers/video-transcoder.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | const db = require('../../../initializers/database') | 1 | import { database as db } from '../../../initializers/database' |
2 | import { logger } from '../../../helpers' | 2 | import { logger } from '../../../helpers' |
3 | import { addVideoToFriends } from '../../../lib' | 3 | import { addVideoToFriends } from '../../../lib' |
4 | 4 | ||
diff --git a/server/lib/jobs/job-scheduler.ts b/server/lib/jobs/job-scheduler.ts index 7b8c6faf9..ad5f7f6d9 100644 --- a/server/lib/jobs/job-scheduler.ts +++ b/server/lib/jobs/job-scheduler.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { forever, queue } from 'async' | 1 | import { forever, queue } from 'async' |
2 | 2 | ||
3 | const db = require('../../initializers/database') | 3 | import { database as db } from '../../initializers/database' |
4 | import { | 4 | import { |
5 | JOBS_FETCHING_INTERVAL, | 5 | JOBS_FETCHING_INTERVAL, |
6 | JOBS_FETCH_LIMIT_PER_CYCLE, | 6 | JOBS_FETCH_LIMIT_PER_CYCLE, |
@@ -24,7 +24,7 @@ class JobScheduler { | |||
24 | 24 | ||
25 | logger.info('Jobs scheduler activated.') | 25 | logger.info('Jobs scheduler activated.') |
26 | 26 | ||
27 | const jobsQueue = queue(this.processJob) | 27 | const jobsQueue = queue(this.processJob.bind(this)) |
28 | 28 | ||
29 | // Finish processing jobs from a previous start | 29 | // Finish processing jobs from a previous start |
30 | const state = JOB_STATES.PROCESSING | 30 | const state = JOB_STATES.PROCESSING |
@@ -58,7 +58,7 @@ class JobScheduler { | |||
58 | }) | 58 | }) |
59 | } | 59 | } |
60 | 60 | ||
61 | createJob (transaction, handlerName, handlerInputData, callback) { | 61 | createJob (transaction, handlerName: string, handlerInputData: object, callback) { |
62 | const createQuery = { | 62 | const createQuery = { |
63 | state: JOB_STATES.PENDING, | 63 | state: JOB_STATES.PENDING, |
64 | handlerName, | 64 | handlerName, |
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts index 00b1afcf5..3bdf0f478 100644 --- a/server/lib/oauth-model.ts +++ b/server/lib/oauth-model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | const db = require('../initializers/database') | 1 | import { database as db } from '../initializers/database' |
2 | import { logger } from '../helpers' | 2 | import { logger } from '../helpers' |
3 | 3 | ||
4 | // --------------------------------------------------------------------------- | 4 | // --------------------------------------------------------------------------- |
@@ -72,7 +72,7 @@ function saveToken (token, client, user) { | |||
72 | userId: user.id | 72 | userId: user.id |
73 | } | 73 | } |
74 | 74 | ||
75 | return db.OAuthToken.create(tokenToCreate).then(function (tokenCreated) { | 75 | return db.OAuthToken.create(tokenToCreate).then(function (tokenCreated: any) { |
76 | tokenCreated.client = client | 76 | tokenCreated.client = client |
77 | tokenCreated.user = user | 77 | tokenCreated.user = user |
78 | 78 | ||
diff --git a/server/lib/request/base-request-scheduler.ts b/server/lib/request/base-request-scheduler.ts index 7fc88b5f1..b7ef6abf9 100644 --- a/server/lib/request/base-request-scheduler.ts +++ b/server/lib/request/base-request-scheduler.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { eachLimit } from 'async/eachLimit' | 1 | import * as eachLimit from 'async/eachLimit' |
2 | 2 | ||
3 | const db = require('../../initializers/database') | 3 | import { database as db } from '../../initializers/database' |
4 | import { logger, makeSecureRequest } from '../../helpers' | 4 | import { logger, makeSecureRequest } from '../../helpers' |
5 | import { | 5 | import { |
6 | API_VERSION, | 6 | API_VERSION, |
diff --git a/server/lib/request/request-scheduler.ts b/server/lib/request/request-scheduler.ts index 2006a6f03..26ffbfb86 100644 --- a/server/lib/request/request-scheduler.ts +++ b/server/lib/request/request-scheduler.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | const db = require('../../initializers/database') | 1 | import { database as db } from '../../initializers/database' |
2 | import { BaseRequestScheduler } from './base-request-scheduler' | 2 | import { BaseRequestScheduler } from './base-request-scheduler' |
3 | import { logger } from '../../helpers' | 3 | import { logger } from '../../helpers' |
4 | import { | 4 | import { |
@@ -59,13 +59,14 @@ class RequestScheduler extends BaseRequestScheduler { | |||
59 | const toIds = options.toIds | 59 | const toIds = options.toIds |
60 | const transaction = options.transaction | 60 | const transaction = options.transaction |
61 | 61 | ||
62 | const pods = [] | 62 | // TODO: check the setPods works |
63 | const podIds = [] | ||
63 | 64 | ||
64 | // If there are no destination pods abort | 65 | // If there are no destination pods abort |
65 | if (toIds.length === 0) return callback(null) | 66 | if (toIds.length === 0) return callback(null) |
66 | 67 | ||
67 | toIds.forEach(toPod => { | 68 | toIds.forEach(toPod => { |
68 | pods.push(db.Pod.build({ id: toPod })) | 69 | podIds.push(toPod) |
69 | }) | 70 | }) |
70 | 71 | ||
71 | const createQuery = { | 72 | const createQuery = { |
@@ -83,7 +84,7 @@ class RequestScheduler extends BaseRequestScheduler { | |||
83 | return db.Request.create(createQuery, dbRequestOptions).asCallback((err, request) => { | 84 | return db.Request.create(createQuery, dbRequestOptions).asCallback((err, request) => { |
84 | if (err) return callback(err) | 85 | if (err) return callback(err) |
85 | 86 | ||
86 | return request.setPods(pods, dbRequestOptions).asCallback(callback) | 87 | return request.setPods(podIds, dbRequestOptions).asCallback(callback) |
87 | }) | 88 | }) |
88 | } | 89 | } |
89 | 90 | ||
diff --git a/server/lib/request/request-video-event-scheduler.ts b/server/lib/request/request-video-event-scheduler.ts index 6e5306c7d..bde50b1d3 100644 --- a/server/lib/request/request-video-event-scheduler.ts +++ b/server/lib/request/request-video-event-scheduler.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | const db = require('../../initializers/database') | 1 | import { database as db } from '../../initializers/database' |
2 | import { BaseRequestScheduler } from './base-request-scheduler' | 2 | import { BaseRequestScheduler } from './base-request-scheduler' |
3 | import { | 3 | import { |
4 | REQUESTS_VIDEO_EVENT_LIMIT_PODS, | 4 | REQUESTS_VIDEO_EVENT_LIMIT_PODS, |
diff --git a/server/lib/request/request-video-qadu-scheduler.ts b/server/lib/request/request-video-qadu-scheduler.ts index d81822723..dab526088 100644 --- a/server/lib/request/request-video-qadu-scheduler.ts +++ b/server/lib/request/request-video-qadu-scheduler.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | const db = require('../../initializers/database') | 1 | import { database as db } from '../../initializers/database' |
2 | import { BaseRequestScheduler } from './base-request-scheduler' | 2 | import { BaseRequestScheduler } from './base-request-scheduler' |
3 | import { logger } from '../../helpers' | 3 | import { logger } from '../../helpers' |
4 | import { | 4 | import { |