aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-27 14:32:44 +0200
committerChocobozzz <me@florianbigard.com>2021-08-27 15:12:22 +0200
commit41fb13c330de629df2d23379209e79c7af0f2e9a (patch)
tree73bc5a90566406b3910f142beae2a879c1e4265d /server/lib
parent40e7ed0714f96c01e16de3ac971a4b28116294e1 (diff)
downloadPeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.gz
PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.zst
PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.zip
esModuleInterop to true
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/actors/webfinger.ts2
-rw-r--r--server/lib/activitypub/crawl.ts6
-rw-r--r--server/lib/activitypub/playlists/create-update.ts6
-rw-r--r--server/lib/activitypub/share.ts4
-rw-r--r--server/lib/activitypub/video-comments.ts4
-rw-r--r--server/lib/activitypub/video-rates.ts4
-rw-r--r--server/lib/activitypub/videos/shared/object-to-model-attributes.ts2
-rw-r--r--server/lib/auth/oauth-model.ts2
-rw-r--r--server/lib/auth/oauth.ts2
-rw-r--r--server/lib/auth/tokens-cache.ts2
-rw-r--r--server/lib/client-html.ts2
-rw-r--r--server/lib/files-cache/abstract-video-static-file-cache.ts2
-rw-r--r--server/lib/job-queue/handlers/activitypub-cleaner.ts12
-rw-r--r--server/lib/job-queue/handlers/activitypub-follow.ts4
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-broadcast.ts8
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-fetcher.ts4
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-unicast.ts4
-rw-r--r--server/lib/job-queue/handlers/activitypub-refresher.ts4
-rw-r--r--server/lib/job-queue/handlers/actor-keys.ts4
-rw-r--r--server/lib/job-queue/handlers/email.ts6
-rw-r--r--server/lib/job-queue/handlers/move-to-object-storage.ts4
-rw-r--r--server/lib/job-queue/handlers/video-file-import.ts4
-rw-r--r--server/lib/job-queue/handlers/video-import.ts8
-rw-r--r--server/lib/job-queue/handlers/video-live-ending.ts4
-rw-r--r--server/lib/job-queue/handlers/video-redundancy.ts6
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts14
-rw-r--r--server/lib/job-queue/job-queue.ts14
-rw-r--r--server/lib/live/shared/muxing-session.ts14
-rw-r--r--server/lib/local-actor.ts2
-rw-r--r--server/lib/peertube-socket.ts14
-rw-r--r--server/lib/plugins/hooks.ts2
-rw-r--r--server/lib/plugins/plugin-helpers-builder.ts2
-rw-r--r--server/lib/plugins/plugin-manager.ts2
-rw-r--r--server/lib/plugins/register-helpers.ts2
-rw-r--r--server/lib/redis.ts2
-rw-r--r--server/lib/schedulers/abstract-scheduler.ts2
-rw-r--r--server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts4
-rw-r--r--server/lib/search.ts2
-rw-r--r--server/lib/signup.ts22
-rw-r--r--server/lib/stat-manager.ts6
40 files changed, 107 insertions, 107 deletions
diff --git a/server/lib/activitypub/actors/webfinger.ts b/server/lib/activitypub/actors/webfinger.ts
index 1c7ec4717..5532f05bd 100644
--- a/server/lib/activitypub/actors/webfinger.ts
+++ b/server/lib/activitypub/actors/webfinger.ts
@@ -1,4 +1,4 @@
1import * as WebFinger from 'webfinger.js' 1import WebFinger from 'webfinger.js'
2import { isProdInstance } from '@server/helpers/core-utils' 2import { isProdInstance } from '@server/helpers/core-utils'
3import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' 3import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
4import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants' 4import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants'
diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts
index 28ff5225a..336129b82 100644
--- a/server/lib/activitypub/crawl.ts
+++ b/server/lib/activitypub/crawl.ts
@@ -1,13 +1,13 @@
1import { retryTransactionWrapper } from '@server/helpers/database-utils' 1import Bluebird from 'bluebird'
2import * as Bluebird from 'bluebird'
3import { URL } from 'url' 2import { URL } from 'url'
3import { retryTransactionWrapper } from '@server/helpers/database-utils'
4import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' 4import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
5import { logger } from '../../helpers/logger' 5import { logger } from '../../helpers/logger'
6import { doJSONRequest } from '../../helpers/requests' 6import { doJSONRequest } from '../../helpers/requests'
7import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants' 7import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants'
8 8
9type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) 9type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>)
10type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) 10type CleanerFunction = (startedDate: Date) => Promise<any>
11 11
12async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) { 12async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) {
13 let url = argUrl 13 let url = argUrl
diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/lib/activitypub/playlists/create-update.ts
index ea3e61ac5..b152d709c 100644
--- a/server/lib/activitypub/playlists/create-update.ts
+++ b/server/lib/activitypub/playlists/create-update.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import { getAPId } from '@server/helpers/activitypub' 2import { getAPId } from '@server/helpers/activitypub'
3import { isArray } from '@server/helpers/custom-validators/misc' 3import { isArray } from '@server/helpers/custom-validators/misc'
4import { logger, loggerTagsFactory } from '@server/helpers/logger' 4import { logger, loggerTagsFactory } from '@server/helpers/logger'
@@ -24,7 +24,7 @@ import {
24const lTags = loggerTagsFactory('ap', 'video-playlist') 24const lTags = loggerTagsFactory('ap', 'video-playlist')
25 25
26async function createAccountPlaylists (playlistUrls: string[]) { 26async function createAccountPlaylists (playlistUrls: string[]) {
27 await Bluebird.map(playlistUrls, async playlistUrl => { 27 await map(playlistUrls, async playlistUrl => {
28 try { 28 try {
29 const exists = await VideoPlaylistModel.doesPlaylistExist(playlistUrl) 29 const exists = await VideoPlaylistModel.doesPlaylistExist(playlistUrl)
30 if (exists === true) return 30 if (exists === true) return
@@ -140,7 +140,7 @@ async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MV
140async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) { 140async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) {
141 const elementsToCreate: FilteredModelAttributes<VideoPlaylistElementModel>[] = [] 141 const elementsToCreate: FilteredModelAttributes<VideoPlaylistElementModel>[] = []
142 142
143 await Bluebird.map(elementUrls, async elementUrl => { 143 await map(elementUrls, async elementUrl => {
144 try { 144 try {
145 const { elementObject } = await fetchRemotePlaylistElement(elementUrl) 145 const { elementObject } = await fetchRemotePlaylistElement(elementUrl)
146 146
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts
index 1ff01a175..b18761174 100644
--- a/server/lib/activitypub/share.ts
+++ b/server/lib/activitypub/share.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import { Transaction } from 'sequelize' 2import { Transaction } from 'sequelize'
3import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
4import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' 4import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
@@ -38,7 +38,7 @@ async function changeVideoChannelShare (
38} 38}
39 39
40async function addVideoShares (shareUrls: string[], video: MVideoId) { 40async function addVideoShares (shareUrls: string[], video: MVideoId) {
41 await Bluebird.map(shareUrls, async shareUrl => { 41 await map(shareUrls, async shareUrl => {
42 try { 42 try {
43 await addVideoShare(shareUrl, video) 43 await addVideoShare(shareUrl, video)
44 } catch (err) { 44 } catch (err) {
diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts
index 6b7f9504f..2a14790fe 100644
--- a/server/lib/activitypub/video-comments.ts
+++ b/server/lib/activitypub/video-comments.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import { checkUrlsSameHost } from '../../helpers/activitypub' 2import { checkUrlsSameHost } from '../../helpers/activitypub'
3import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' 3import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
@@ -18,7 +18,7 @@ type ResolveThreadParams = {
18type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }> 18type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }>
19 19
20async function addVideoComments (commentUrls: string[]) { 20async function addVideoComments (commentUrls: string[]) {
21 return Bluebird.map(commentUrls, async commentUrl => { 21 return map(commentUrls, async commentUrl => {
22 try { 22 try {
23 await resolveThread({ url: commentUrl, isVideo: false }) 23 await resolveThread({ url: commentUrl, isVideo: false })
24 } catch (err) { 24 } catch (err) {
diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts
index 9fb97ef84..04aa5eae9 100644
--- a/server/lib/activitypub/video-rates.ts
+++ b/server/lib/activitypub/video-rates.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import { Transaction } from 'sequelize' 2import { Transaction } from 'sequelize'
3import { doJSONRequest } from '@server/helpers/requests' 3import { doJSONRequest } from '@server/helpers/requests'
4import { VideoRateType } from '../../../shared/models/videos' 4import { VideoRateType } from '../../../shared/models/videos'
@@ -15,7 +15,7 @@ import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlBy
15const lTags = loggerTagsFactory('ap', 'video-rate', 'create') 15const lTags = loggerTagsFactory('ap', 'video-rate', 'create')
16 16
17async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) { 17async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) {
18 await Bluebird.map(ratesUrl, async rateUrl => { 18 await map(ratesUrl, async rateUrl => {
19 try { 19 try {
20 await createRate(rateUrl, video, rate) 20 await createRate(rateUrl, video, rate)
21 } catch (err) { 21 } catch (err) {
diff --git a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
index bd9ed45a9..62354ab56 100644
--- a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
+++ b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
@@ -1,5 +1,5 @@
1import { maxBy, minBy } from 'lodash' 1import { maxBy, minBy } from 'lodash'
2import * as magnetUtil from 'magnet-uri' 2import magnetUtil from 'magnet-uri'
3import { basename } from 'path' 3import { basename } from 'path'
4import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos' 4import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos'
5import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos' 5import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos'
diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts
index ae728d080..f2ef0a78a 100644
--- a/server/lib/auth/oauth-model.ts
+++ b/server/lib/auth/oauth-model.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { AccessDeniedError } from 'oauth2-server' 2import { AccessDeniedError } from 'oauth2-server'
3import { PluginManager } from '@server/lib/plugins/plugin-manager' 3import { PluginManager } from '@server/lib/plugins/plugin-manager'
4import { ActorModel } from '@server/models/actor/actor' 4import { ActorModel } from '@server/models/actor/actor'
diff --git a/server/lib/auth/oauth.ts b/server/lib/auth/oauth.ts
index a97681c86..497773536 100644
--- a/server/lib/auth/oauth.ts
+++ b/server/lib/auth/oauth.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { 2import {
3 InvalidClientError, 3 InvalidClientError,
4 InvalidGrantError, 4 InvalidGrantError,
diff --git a/server/lib/auth/tokens-cache.ts b/server/lib/auth/tokens-cache.ts
index b027ce69a..410708a35 100644
--- a/server/lib/auth/tokens-cache.ts
+++ b/server/lib/auth/tokens-cache.ts
@@ -1,4 +1,4 @@
1import * as LRUCache from 'lru-cache' 1import LRUCache from 'lru-cache'
2import { MOAuthTokenUser } from '@server/types/models' 2import { MOAuthTokenUser } from '@server/types/models'
3import { LRU_CACHE } from '../../initializers/constants' 3import { LRU_CACHE } from '../../initializers/constants'
4 4
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index e093d35f7..3b0a68f4d 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { readFile } from 'fs-extra' 2import { readFile } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import validator from 'validator' 4import validator from 'validator'
diff --git a/server/lib/files-cache/abstract-video-static-file-cache.ts b/server/lib/files-cache/abstract-video-static-file-cache.ts
index af66689a0..a7ac88525 100644
--- a/server/lib/files-cache/abstract-video-static-file-cache.ts
+++ b/server/lib/files-cache/abstract-video-static-file-cache.ts
@@ -1,6 +1,6 @@
1import { remove } from 'fs-extra' 1import { remove } from 'fs-extra'
2import { logger } from '../../helpers/logger' 2import { logger } from '../../helpers/logger'
3import * as memoizee from 'memoizee' 3import memoizee from 'memoizee'
4 4
5type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined 5type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined
6 6
diff --git a/server/lib/job-queue/handlers/activitypub-cleaner.ts b/server/lib/job-queue/handlers/activitypub-cleaner.ts
index 56e2b0ceb..d5e4508fe 100644
--- a/server/lib/job-queue/handlers/activitypub-cleaner.ts
+++ b/server/lib/job-queue/handlers/activitypub-cleaner.ts
@@ -1,5 +1,5 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import * as Bull from 'bull' 2import { Job } from 'bull'
3import { checkUrlsSameHost } from '@server/helpers/activitypub' 3import { checkUrlsSameHost } from '@server/helpers/activitypub'
4import { 4import {
5 isAnnounceActivityValid, 5 isAnnounceActivityValid,
@@ -18,14 +18,14 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat
18 18
19// Job to clean remote interactions off local videos 19// Job to clean remote interactions off local videos
20 20
21async function processActivityPubCleaner (_job: Bull.Job) { 21async function processActivityPubCleaner (_job: Job) {
22 logger.info('Processing ActivityPub cleaner.') 22 logger.info('Processing ActivityPub cleaner.')
23 23
24 { 24 {
25 const rateUrls = await AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos() 25 const rateUrls = await AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos()
26 const { bodyValidator, deleter, updater } = rateOptionsFactory() 26 const { bodyValidator, deleter, updater } = rateOptionsFactory()
27 27
28 await Bluebird.map(rateUrls, async rateUrl => { 28 await map(rateUrls, async rateUrl => {
29 try { 29 try {
30 const result = await updateObjectIfNeeded(rateUrl, bodyValidator, updater, deleter) 30 const result = await updateObjectIfNeeded(rateUrl, bodyValidator, updater, deleter)
31 31
@@ -44,7 +44,7 @@ async function processActivityPubCleaner (_job: Bull.Job) {
44 const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos() 44 const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos()
45 const { bodyValidator, deleter, updater } = shareOptionsFactory() 45 const { bodyValidator, deleter, updater } = shareOptionsFactory()
46 46
47 await Bluebird.map(shareUrls, async shareUrl => { 47 await map(shareUrls, async shareUrl => {
48 try { 48 try {
49 await updateObjectIfNeeded(shareUrl, bodyValidator, updater, deleter) 49 await updateObjectIfNeeded(shareUrl, bodyValidator, updater, deleter)
50 } catch (err) { 50 } catch (err) {
@@ -57,7 +57,7 @@ async function processActivityPubCleaner (_job: Bull.Job) {
57 const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos() 57 const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos()
58 const { bodyValidator, deleter, updater } = commentOptionsFactory() 58 const { bodyValidator, deleter, updater } = commentOptionsFactory()
59 59
60 await Bluebird.map(commentUrls, async commentUrl => { 60 await map(commentUrls, async commentUrl => {
61 try { 61 try {
62 await updateObjectIfNeeded(commentUrl, bodyValidator, updater, deleter) 62 await updateObjectIfNeeded(commentUrl, bodyValidator, updater, deleter)
63 } catch (err) { 63 } catch (err) {
diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts
index f896d7af4..91e3d33c6 100644
--- a/server/lib/job-queue/handlers/activitypub-follow.ts
+++ b/server/lib/job-queue/handlers/activitypub-follow.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url' 2import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url'
3import { ActivitypubFollowPayload } from '@shared/models' 3import { ActivitypubFollowPayload } from '@shared/models'
4import { sanitizeHost } from '../../../helpers/core-utils' 4import { sanitizeHost } from '../../../helpers/core-utils'
@@ -13,7 +13,7 @@ import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../activi
13import { sendFollow } from '../../activitypub/send' 13import { sendFollow } from '../../activitypub/send'
14import { Notifier } from '../../notifier' 14import { Notifier } from '../../notifier'
15 15
16async function processActivityPubFollow (job: Bull.Job) { 16async function processActivityPubFollow (job: Job) {
17 const payload = job.data as ActivitypubFollowPayload 17 const payload = job.data as ActivitypubFollowPayload
18 const host = payload.host 18 const host = payload.host
19 19
diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
index d4b328635..9b0bb6574 100644
--- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
@@ -1,5 +1,5 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import * as Bull from 'bull' 2import { Job } from 'bull'
3import { ActivitypubHttpBroadcastPayload } from '@shared/models' 3import { ActivitypubHttpBroadcastPayload } from '@shared/models'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { doRequest } from '../../../helpers/requests' 5import { doRequest } from '../../../helpers/requests'
@@ -7,7 +7,7 @@ import { BROADCAST_CONCURRENCY } from '../../../initializers/constants'
7import { ActorFollowScoreCache } from '../../files-cache' 7import { ActorFollowScoreCache } from '../../files-cache'
8import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' 8import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
9 9
10async function processActivityPubHttpBroadcast (job: Bull.Job) { 10async function processActivityPubHttpBroadcast (job: Job) {
11 logger.info('Processing ActivityPub broadcast in job %d.', job.id) 11 logger.info('Processing ActivityPub broadcast in job %d.', job.id)
12 12
13 const payload = job.data as ActivitypubHttpBroadcastPayload 13 const payload = job.data as ActivitypubHttpBroadcastPayload
@@ -25,7 +25,7 @@ async function processActivityPubHttpBroadcast (job: Bull.Job) {
25 const badUrls: string[] = [] 25 const badUrls: string[] = []
26 const goodUrls: string[] = [] 26 const goodUrls: string[] = []
27 27
28 await Bluebird.map(payload.uris, uri => { 28 await map(payload.uris, uri => {
29 return doRequest(uri, options) 29 return doRequest(uri, options)
30 .then(() => goodUrls.push(uri)) 30 .then(() => goodUrls.push(uri))
31 .catch(() => badUrls.push(uri)) 31 .catch(() => badUrls.push(uri))
diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
index ab9675cae..46016a0a7 100644
--- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' 2import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 4import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
@@ -13,7 +13,7 @@ import { addVideoShares } from '../../activitypub/share'
13import { addVideoComments } from '../../activitypub/video-comments' 13import { addVideoComments } from '../../activitypub/video-comments'
14import { createRates } from '../../activitypub/video-rates' 14import { createRates } from '../../activitypub/video-rates'
15 15
16async function processActivityPubHttpFetcher (job: Bull.Job) { 16async function processActivityPubHttpFetcher (job: Job) {
17 logger.info('Processing ActivityPub fetcher in job %d.', job.id) 17 logger.info('Processing ActivityPub fetcher in job %d.', job.id)
18 18
19 const payload = job.data as ActivitypubHttpFetcherPayload 19 const payload = job.data as ActivitypubHttpFetcherPayload
diff --git a/server/lib/job-queue/handlers/activitypub-http-unicast.ts b/server/lib/job-queue/handlers/activitypub-http-unicast.ts
index 9e561c6b7..9be50837f 100644
--- a/server/lib/job-queue/handlers/activitypub-http-unicast.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-unicast.ts
@@ -1,11 +1,11 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { ActivitypubHttpUnicastPayload } from '@shared/models' 2import { ActivitypubHttpUnicastPayload } from '@shared/models'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { doRequest } from '../../../helpers/requests' 4import { doRequest } from '../../../helpers/requests'
5import { ActorFollowScoreCache } from '../../files-cache' 5import { ActorFollowScoreCache } from '../../files-cache'
6import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' 6import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
7 7
8async function processActivityPubHttpUnicast (job: Bull.Job) { 8async function processActivityPubHttpUnicast (job: Job) {
9 logger.info('Processing ActivityPub unicast in job %d.', job.id) 9 logger.info('Processing ActivityPub unicast in job %d.', job.id)
10 10
11 const payload = job.data as ActivitypubHttpUnicastPayload 11 const payload = job.data as ActivitypubHttpUnicastPayload
diff --git a/server/lib/job-queue/handlers/activitypub-refresher.ts b/server/lib/job-queue/handlers/activitypub-refresher.ts
index d97e50ebc..5037992d2 100644
--- a/server/lib/job-queue/handlers/activitypub-refresher.ts
+++ b/server/lib/job-queue/handlers/activitypub-refresher.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists' 2import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists'
3import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos' 3import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos'
4import { loadVideoByUrl } from '@server/lib/model-loaders' 4import { loadVideoByUrl } from '@server/lib/model-loaders'
@@ -8,7 +8,7 @@ import { ActorModel } from '../../../models/actor/actor'
8import { VideoPlaylistModel } from '../../../models/video/video-playlist' 8import { VideoPlaylistModel } from '../../../models/video/video-playlist'
9import { refreshActorIfNeeded } from '../../activitypub/actors' 9import { refreshActorIfNeeded } from '../../activitypub/actors'
10 10
11async function refreshAPObject (job: Bull.Job) { 11async function refreshAPObject (job: Job) {
12 const payload = job.data as RefreshPayload 12 const payload = job.data as RefreshPayload
13 13
14 logger.info('Processing AP refresher in job %d for %s.', job.id, payload.url) 14 logger.info('Processing AP refresher in job %d for %s.', job.id, payload.url)
diff --git a/server/lib/job-queue/handlers/actor-keys.ts b/server/lib/job-queue/handlers/actor-keys.ts
index 60ac61afd..9d5a65376 100644
--- a/server/lib/job-queue/handlers/actor-keys.ts
+++ b/server/lib/job-queue/handlers/actor-keys.ts
@@ -1,10 +1,10 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors' 2import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors'
3import { ActorModel } from '@server/models/actor/actor' 3import { ActorModel } from '@server/models/actor/actor'
4import { ActorKeysPayload } from '@shared/models' 4import { ActorKeysPayload } from '@shared/models'
5import { logger } from '../../../helpers/logger' 5import { logger } from '../../../helpers/logger'
6 6
7async function processActorKeys (job: Bull.Job) { 7async function processActorKeys (job: Job) {
8 const payload = job.data as ActorKeysPayload 8 const payload = job.data as ActorKeysPayload
9 logger.info('Processing actor keys in job %d.', job.id) 9 logger.info('Processing actor keys in job %d.', job.id)
10 10
diff --git a/server/lib/job-queue/handlers/email.ts b/server/lib/job-queue/handlers/email.ts
index 3157731e2..6fc1caa84 100644
--- a/server/lib/job-queue/handlers/email.ts
+++ b/server/lib/job-queue/handlers/email.ts
@@ -1,9 +1,9 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { EmailPayload } from '@shared/models'
2import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
3import { Emailer } from '../../emailer' 4import { Emailer } from '../../emailer'
4import { EmailPayload } from '@shared/models'
5 5
6async function processEmail (job: Bull.Job) { 6async function processEmail (job: Job) {
7 const payload = job.data as EmailPayload 7 const payload = job.data as EmailPayload
8 logger.info('Processing email in job %d.', job.id) 8 logger.info('Processing email in job %d.', job.id)
9 9
diff --git a/server/lib/job-queue/handlers/move-to-object-storage.ts b/server/lib/job-queue/handlers/move-to-object-storage.ts
index f3b8726eb..0bebc0fc2 100644
--- a/server/lib/job-queue/handlers/move-to-object-storage.ts
+++ b/server/lib/job-queue/handlers/move-to-object-storage.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { remove } from 'fs-extra' 2import { remove } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import { logger } from '@server/helpers/logger' 4import { logger } from '@server/helpers/logger'
@@ -12,7 +12,7 @@ import { VideoJobInfoModel } from '@server/models/video/video-job-info'
12import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' 12import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models'
13import { MoveObjectStoragePayload, VideoStorage } from '../../../../shared' 13import { MoveObjectStoragePayload, VideoStorage } from '../../../../shared'
14 14
15export async function processMoveToObjectStorage (job: Bull.Job) { 15export async function processMoveToObjectStorage (job: Job) {
16 const payload = job.data as MoveObjectStoragePayload 16 const payload = job.data as MoveObjectStoragePayload
17 logger.info('Moving video %s in job %d.', payload.videoUUID, job.id) 17 logger.info('Moving video %s in job %d.', payload.videoUUID, job.id)
18 18
diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts
index e8ee1f759..e6c918e6c 100644
--- a/server/lib/job-queue/handlers/video-file-import.ts
+++ b/server/lib/job-queue/handlers/video-file-import.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { copy, stat } from 'fs-extra' 2import { copy, stat } from 'fs-extra'
3import { getLowercaseExtension } from '@server/helpers/core-utils' 3import { getLowercaseExtension } from '@server/helpers/core-utils'
4import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' 4import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
@@ -16,7 +16,7 @@ import { VideoModel } from '../../../models/video/video'
16import { VideoFileModel } from '../../../models/video/video-file' 16import { VideoFileModel } from '../../../models/video/video-file'
17import { createHlsJobIfEnabled } from './video-transcoding' 17import { createHlsJobIfEnabled } from './video-transcoding'
18 18
19async function processVideoFileImport (job: Bull.Job) { 19async function processVideoFileImport (job: Job) {
20 const payload = job.data as VideoFileImportPayload 20 const payload = job.data as VideoFileImportPayload
21 logger.info('Processing video file import in job %d.', job.id) 21 logger.info('Processing video file import in job %d.', job.id)
22 22
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts
index a5fa204f5..bdbf07a06 100644
--- a/server/lib/job-queue/handlers/video-import.ts
+++ b/server/lib/job-queue/handlers/video-import.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { move, remove, stat } from 'fs-extra' 2import { move, remove, stat } from 'fs-extra'
3import { getLowercaseExtension } from '@server/helpers/core-utils' 3import { getLowercaseExtension } from '@server/helpers/core-utils'
4import { retryTransactionWrapper } from '@server/helpers/database-utils' 4import { retryTransactionWrapper } from '@server/helpers/database-utils'
@@ -37,7 +37,7 @@ import { federateVideoIfNeeded } from '../../activitypub/videos'
37import { Notifier } from '../../notifier' 37import { Notifier } from '../../notifier'
38import { generateVideoMiniature } from '../../thumbnail' 38import { generateVideoMiniature } from '../../thumbnail'
39 39
40async function processVideoImport (job: Bull.Job) { 40async function processVideoImport (job: Job) {
41 const payload = job.data as VideoImportPayload 41 const payload = job.data as VideoImportPayload
42 42
43 if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload) 43 if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload)
@@ -52,7 +52,7 @@ export {
52 52
53// --------------------------------------------------------------------------- 53// ---------------------------------------------------------------------------
54 54
55async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentPayload) { 55async function processTorrentImport (job: Job, payload: VideoImportTorrentPayload) {
56 logger.info('Processing torrent video import in job %d.', job.id) 56 logger.info('Processing torrent video import in job %d.', job.id)
57 57
58 const videoImport = await getVideoImportOrDie(payload.videoImportId) 58 const videoImport = await getVideoImportOrDie(payload.videoImportId)
@@ -68,7 +68,7 @@ async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentP
68 return processFile(() => downloadWebTorrentVideo(target, VIDEO_IMPORT_TIMEOUT), videoImport, options) 68 return processFile(() => downloadWebTorrentVideo(target, VIDEO_IMPORT_TIMEOUT), videoImport, options)
69} 69}
70 70
71async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutubeDLPayload) { 71async function processYoutubeDLImport (job: Job, payload: VideoImportYoutubeDLPayload) {
72 logger.info('Processing youtubeDL video import in job %d.', job.id) 72 logger.info('Processing youtubeDL video import in job %d.', job.id)
73 73
74 const videoImport = await getVideoImportOrDie(payload.videoImportId) 74 const videoImport = await getVideoImportOrDie(payload.videoImportId)
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts
index 9ccf724c2..a04cfa2c9 100644
--- a/server/lib/job-queue/handlers/video-live-ending.ts
+++ b/server/lib/job-queue/handlers/video-live-ending.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { pathExists, readdir, remove } from 'fs-extra' 2import { pathExists, readdir, remove } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils' 4import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils'
@@ -17,7 +17,7 @@ import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models'
17import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' 17import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
18import { logger } from '../../../helpers/logger' 18import { logger } from '../../../helpers/logger'
19 19
20async function processVideoLiveEnding (job: Bull.Job) { 20async function processVideoLiveEnding (job: Job) {
21 const payload = job.data as VideoLiveEndingPayload 21 const payload = job.data as VideoLiveEndingPayload
22 22
23 function logError () { 23 function logError () {
diff --git a/server/lib/job-queue/handlers/video-redundancy.ts b/server/lib/job-queue/handlers/video-redundancy.ts
index 6296dab05..9cb7a6589 100644
--- a/server/lib/job-queue/handlers/video-redundancy.ts
+++ b/server/lib/job-queue/handlers/video-redundancy.ts
@@ -1,9 +1,9 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { logger } from '../../../helpers/logger'
3import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler' 2import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler'
4import { VideoRedundancyPayload } from '@shared/models' 3import { VideoRedundancyPayload } from '@shared/models'
4import { logger } from '../../../helpers/logger'
5 5
6async function processVideoRedundancy (job: Bull.Job) { 6async function processVideoRedundancy (job: Job) {
7 const payload = job.data as VideoRedundancyPayload 7 const payload = job.data as VideoRedundancyPayload
8 logger.info('Processing video redundancy in job %d.', job.id) 8 logger.info('Processing video redundancy in job %d.', job.id)
9 9
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 5a93c4ed1..20880cdc1 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' 2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils'
3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' 3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video'
4import { VideoPathManager } from '@server/lib/video-path-manager' 4import { VideoPathManager } from '@server/lib/video-path-manager'
@@ -25,7 +25,7 @@ import {
25 transcodeNewWebTorrentResolution 25 transcodeNewWebTorrentResolution
26} from '../../transcoding/video-transcoding' 26} from '../../transcoding/video-transcoding'
27 27
28type HandlerFunction = (job: Bull.Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void> 28type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void>
29 29
30const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = { 30const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = {
31 'new-resolution-to-hls': handleHLSJob, 31 'new-resolution-to-hls': handleHLSJob,
@@ -36,7 +36,7 @@ const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } =
36 36
37const lTags = loggerTagsFactory('transcoding') 37const lTags = loggerTagsFactory('transcoding')
38 38
39async function processVideoTranscoding (job: Bull.Job) { 39async function processVideoTranscoding (job: Job) {
40 const payload = job.data as VideoTranscodingPayload 40 const payload = job.data as VideoTranscodingPayload
41 logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID)) 41 logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID))
42 42
@@ -64,7 +64,7 @@ async function processVideoTranscoding (job: Bull.Job) {
64// Job handlers 64// Job handlers
65// --------------------------------------------------------------------------- 65// ---------------------------------------------------------------------------
66 66
67async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) { 67async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) {
68 logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid)) 68 logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid))
69 69
70 const videoFileInput = payload.copyCodecs 70 const videoFileInput = payload.copyCodecs
@@ -90,7 +90,7 @@ async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, vide
90} 90}
91 91
92async function handleNewWebTorrentResolutionJob ( 92async function handleNewWebTorrentResolutionJob (
93 job: Bull.Job, 93 job: Job,
94 payload: NewResolutionTranscodingPayload, 94 payload: NewResolutionTranscodingPayload,
95 video: MVideoFullLight, 95 video: MVideoFullLight,
96 user: MUserId 96 user: MUserId
@@ -104,7 +104,7 @@ async function handleNewWebTorrentResolutionJob (
104 await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload) 104 await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload)
105} 105}
106 106
107async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { 107async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
108 logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid)) 108 logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid))
109 109
110 await mergeAudioVideofile(video, payload.resolution, job) 110 await mergeAudioVideofile(video, payload.resolution, job)
@@ -114,7 +114,7 @@ async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudio
114 await retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user) 114 await retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user)
115} 115}
116 116
117async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { 117async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
118 logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid)) 118 logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid))
119 119
120 const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job) 120 const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job)
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts
index 7a3a1bf82..4cda12b57 100644
--- a/server/lib/job-queue/job-queue.ts
+++ b/server/lib/job-queue/job-queue.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import Bull, { Job, JobOptions, Queue } from 'bull'
2import { jobStates } from '@server/helpers/custom-validators/jobs' 2import { jobStates } from '@server/helpers/custom-validators/jobs'
3import { CONFIG } from '@server/initializers/config' 3import { CONFIG } from '@server/initializers/config'
4import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy' 4import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy'
@@ -30,12 +30,12 @@ import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unica
30import { refreshAPObject } from './handlers/activitypub-refresher' 30import { refreshAPObject } from './handlers/activitypub-refresher'
31import { processActorKeys } from './handlers/actor-keys' 31import { processActorKeys } from './handlers/actor-keys'
32import { processEmail } from './handlers/email' 32import { processEmail } from './handlers/email'
33import { processMoveToObjectStorage } from './handlers/move-to-object-storage'
33import { processVideoFileImport } from './handlers/video-file-import' 34import { processVideoFileImport } from './handlers/video-file-import'
34import { processVideoImport } from './handlers/video-import' 35import { processVideoImport } from './handlers/video-import'
35import { processVideoLiveEnding } from './handlers/video-live-ending' 36import { processVideoLiveEnding } from './handlers/video-live-ending'
36import { processVideoTranscoding } from './handlers/video-transcoding' 37import { processVideoTranscoding } from './handlers/video-transcoding'
37import { processVideosViews } from './handlers/video-views' 38import { processVideosViews } from './handlers/video-views'
38import { processMoveToObjectStorage } from './handlers/move-to-object-storage'
39 39
40type CreateJobArgument = 40type CreateJobArgument =
41 { type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } | 41 { type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } |
@@ -59,7 +59,7 @@ export type CreateJobOptions = {
59 priority?: number 59 priority?: number
60} 60}
61 61
62const handlers: { [id in JobType]: (job: Bull.Job) => Promise<any> } = { 62const handlers: { [id in JobType]: (job: Job) => Promise<any> } = {
63 'activitypub-http-broadcast': processActivityPubHttpBroadcast, 63 'activitypub-http-broadcast': processActivityPubHttpBroadcast,
64 'activitypub-http-unicast': processActivityPubHttpUnicast, 64 'activitypub-http-unicast': processActivityPubHttpUnicast,
65 'activitypub-http-fetcher': processActivityPubHttpFetcher, 65 'activitypub-http-fetcher': processActivityPubHttpFetcher,
@@ -99,7 +99,7 @@ class JobQueue {
99 99
100 private static instance: JobQueue 100 private static instance: JobQueue
101 101
102 private queues: { [id in JobType]?: Bull.Queue } = {} 102 private queues: { [id in JobType]?: Queue } = {}
103 private initialized = false 103 private initialized = false
104 private jobRedisPrefix: string 104 private jobRedisPrefix: string
105 105
@@ -160,7 +160,7 @@ class JobQueue {
160 return 160 return
161 } 161 }
162 162
163 const jobArgs: Bull.JobOptions = { 163 const jobArgs: JobOptions = {
164 backoff: { delay: 60 * 1000, type: 'exponential' }, 164 backoff: { delay: 60 * 1000, type: 'exponential' },
165 attempts: JOB_ATTEMPTS[obj.type], 165 attempts: JOB_ATTEMPTS[obj.type],
166 timeout: JOB_TTL[obj.type], 166 timeout: JOB_TTL[obj.type],
@@ -177,11 +177,11 @@ class JobQueue {
177 count: number 177 count: number
178 asc?: boolean 178 asc?: boolean
179 jobType: JobType 179 jobType: JobType
180 }): Promise<Bull.Job[]> { 180 }): Promise<Job[]> {
181 const { state, start, count, asc, jobType } = options 181 const { state, start, count, asc, jobType } = options
182 182
183 const states = state ? [ state ] : jobStates 183 const states = state ? [ state ] : jobStates
184 let results: Bull.Job[] = [] 184 let results: Job[] = []
185 185
186 const filteredJobTypes = this.filterJobTypes(jobType) 186 const filteredJobTypes = this.filterJobTypes(jobType)
187 187
diff --git a/server/lib/live/shared/muxing-session.ts b/server/lib/live/shared/muxing-session.ts
index 0c9fb0cb6..a6907142d 100644
--- a/server/lib/live/shared/muxing-session.ts
+++ b/server/lib/live/shared/muxing-session.ts
@@ -1,6 +1,6 @@
1 1
2import * as Bluebird from 'bluebird' 2import { mapSeries } from 'bluebird'
3import * as chokidar from 'chokidar' 3import { FSWatcher, watch } from 'chokidar'
4import { FfmpegCommand } from 'fluent-ffmpeg' 4import { FfmpegCommand } from 'fluent-ffmpeg'
5import { appendFile, ensureDir, readFile, stat } from 'fs-extra' 5import { appendFile, ensureDir, readFile, stat } from 'fs-extra'
6import { basename, join } from 'path' 6import { basename, join } from 'path'
@@ -67,8 +67,8 @@ class MuxingSession extends EventEmitter {
67 67
68 private segmentsToProcessPerPlaylist: { [playlistId: string]: string[] } = {} 68 private segmentsToProcessPerPlaylist: { [playlistId: string]: string[] } = {}
69 69
70 private tsWatcher: chokidar.FSWatcher 70 private tsWatcher: FSWatcher
71 private masterWatcher: chokidar.FSWatcher 71 private masterWatcher: FSWatcher
72 72
73 private readonly isAbleToUploadVideoWithCache = memoizee((userId: number) => { 73 private readonly isAbleToUploadVideoWithCache = memoizee((userId: number) => {
74 return isAbleToUploadVideo(userId, 1000) 74 return isAbleToUploadVideo(userId, 1000)
@@ -197,7 +197,7 @@ class MuxingSession extends EventEmitter {
197 } 197 }
198 198
199 private watchMasterFile (outPath: string) { 199 private watchMasterFile (outPath: string) {
200 this.masterWatcher = chokidar.watch(outPath + '/' + this.streamingPlaylist.playlistFilename) 200 this.masterWatcher = watch(outPath + '/' + this.streamingPlaylist.playlistFilename)
201 201
202 this.masterWatcher.on('add', () => { 202 this.masterWatcher.on('add', () => {
203 this.emit('master-playlist-created', { videoId: this.videoId }) 203 this.emit('master-playlist-created', { videoId: this.videoId })
@@ -210,7 +210,7 @@ class MuxingSession extends EventEmitter {
210 private watchTSFiles (outPath: string) { 210 private watchTSFiles (outPath: string) {
211 const startStreamDateTime = new Date().getTime() 211 const startStreamDateTime = new Date().getTime()
212 212
213 this.tsWatcher = chokidar.watch(outPath + '/*.ts') 213 this.tsWatcher = watch(outPath + '/*.ts')
214 214
215 const playlistIdMatcher = /^([\d+])-/ 215 const playlistIdMatcher = /^([\d+])-/
216 216
@@ -306,7 +306,7 @@ class MuxingSession extends EventEmitter {
306 } 306 }
307 307
308 private processSegments (hlsVideoPath: string, segmentPaths: string[]) { 308 private processSegments (hlsVideoPath: string, segmentPaths: string[]) {
309 Bluebird.mapSeries(segmentPaths, async previousSegment => { 309 mapSeries(segmentPaths, async previousSegment => {
310 // Add sha hash of previous segments, because ffmpeg should have finished generating them 310 // Add sha hash of previous segments, because ffmpeg should have finished generating them
311 await LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment) 311 await LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment)
312 312
diff --git a/server/lib/local-actor.ts b/server/lib/local-actor.ts
index 77667f6b0..821a92b91 100644
--- a/server/lib/local-actor.ts
+++ b/server/lib/local-actor.ts
@@ -1,6 +1,6 @@
1import 'multer' 1import 'multer'
2import { queue } from 'async' 2import { queue } from 'async'
3import * as LRUCache from 'lru-cache' 3import LRUCache from 'lru-cache'
4import { join } from 'path' 4import { join } from 'path'
5import { getLowercaseExtension } from '@server/helpers/core-utils' 5import { getLowercaseExtension } from '@server/helpers/core-utils'
6import { buildUUID } from '@server/helpers/uuid' 6import { buildUUID } from '@server/helpers/uuid'
diff --git a/server/lib/peertube-socket.ts b/server/lib/peertube-socket.ts
index 0740e378e..901435dea 100644
--- a/server/lib/peertube-socket.ts
+++ b/server/lib/peertube-socket.ts
@@ -1,23 +1,23 @@
1import { Server } from 'http' 1import { Server as HTTPServer } from 'http'
2import * as SocketIO from 'socket.io' 2import { Namespace, Server as SocketServer, Socket } from 'socket.io'
3import { isIdValid } from '@server/helpers/custom-validators/misc'
3import { MVideo } from '@server/types/models' 4import { MVideo } from '@server/types/models'
4import { UserNotificationModelForApi } from '@server/types/models/user' 5import { UserNotificationModelForApi } from '@server/types/models/user'
5import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' 6import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models'
6import { logger } from '../helpers/logger' 7import { logger } from '../helpers/logger'
7import { authenticateSocket } from '../middlewares' 8import { authenticateSocket } from '../middlewares'
8import { isIdValid } from '@server/helpers/custom-validators/misc'
9 9
10class PeerTubeSocket { 10class PeerTubeSocket {
11 11
12 private static instance: PeerTubeSocket 12 private static instance: PeerTubeSocket
13 13
14 private userNotificationSockets: { [ userId: number ]: SocketIO.Socket[] } = {} 14 private userNotificationSockets: { [ userId: number ]: Socket[] } = {}
15 private liveVideosNamespace: SocketIO.Namespace 15 private liveVideosNamespace: Namespace
16 16
17 private constructor () {} 17 private constructor () {}
18 18
19 init (server: Server) { 19 init (server: HTTPServer) {
20 const io = new SocketIO.Server(server) 20 const io = new SocketServer(server)
21 21
22 io.of('/user-notifications') 22 io.of('/user-notifications')
23 .use(authenticateSocket) 23 .use(authenticateSocket)
diff --git a/server/lib/plugins/hooks.ts b/server/lib/plugins/hooks.ts
index 5e97b52a0..327aaece2 100644
--- a/server/lib/plugins/hooks.ts
+++ b/server/lib/plugins/hooks.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import Bluebird from 'bluebird'
2import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models' 2import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { PluginManager } from './plugin-manager' 4import { PluginManager } from './plugin-manager'
diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.ts
index 8487672ba..e26776f45 100644
--- a/server/lib/plugins/plugin-helpers-builder.ts
+++ b/server/lib/plugins/plugin-helpers-builder.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { join } from 'path' 2import { join } from 'path'
3import { buildLogger } from '@server/helpers/logger' 3import { buildLogger } from '@server/helpers/logger'
4import { CONFIG } from '@server/initializers/config' 4import { CONFIG } from '@server/initializers/config'
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index 6599bccca..d4d2a7edc 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -1,5 +1,5 @@
1import decache from 'decache' 1import decache from 'decache'
2import * as express from 'express' 2import express from 'express'
3import { createReadStream, createWriteStream } from 'fs' 3import { createReadStream, createWriteStream } from 'fs'
4import { ensureDir, outputFile, readJSON } from 'fs-extra' 4import { ensureDir, outputFile, readJSON } from 'fs-extra'
5import { basename, join } from 'path' 5import { basename, join } from 'path'
diff --git a/server/lib/plugins/register-helpers.ts b/server/lib/plugins/register-helpers.ts
index af533effd..acca9309a 100644
--- a/server/lib/plugins/register-helpers.ts
+++ b/server/lib/plugins/register-helpers.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { logger } from '@server/helpers/logger' 2import { logger } from '@server/helpers/logger'
3import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth' 3import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth'
4import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory' 4import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory'
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index 62641e313..d1d88d853 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { createClient, RedisClient } from 'redis' 2import { createClient, RedisClient } from 'redis'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4import { generateRandomString } from '../helpers/utils' 4import { generateRandomString } from '../helpers/utils'
diff --git a/server/lib/schedulers/abstract-scheduler.ts b/server/lib/schedulers/abstract-scheduler.ts
index 0e6088911..f3d51a22e 100644
--- a/server/lib/schedulers/abstract-scheduler.ts
+++ b/server/lib/schedulers/abstract-scheduler.ts
@@ -1,5 +1,5 @@
1import Bluebird from 'bluebird'
1import { logger } from '../../helpers/logger' 2import { logger } from '../../helpers/logger'
2import * as Bluebird from 'bluebird'
3 3
4export abstract class AbstractScheduler { 4export abstract class AbstractScheduler {
5 5
diff --git a/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts b/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts
index 1acea7998..099fa5651 100644
--- a/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts
+++ b/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts
@@ -1,4 +1,4 @@
1import * as bluebird from 'bluebird' 1import { map } from 'bluebird'
2import { readdir, remove, stat } from 'fs-extra' 2import { readdir, remove, stat } from 'fs-extra'
3import { logger, loggerTagsFactory } from '@server/helpers/logger' 3import { logger, loggerTagsFactory } from '@server/helpers/logger'
4import { getResumableUploadPath } from '@server/helpers/upload' 4import { getResumableUploadPath } from '@server/helpers/upload'
@@ -32,7 +32,7 @@ export class RemoveDanglingResumableUploadsScheduler extends AbstractScheduler {
32 logger.debug('Reading resumable video upload folder %s with %d files', path, metafiles.length, lTags()) 32 logger.debug('Reading resumable video upload folder %s with %d files', path, metafiles.length, lTags())
33 33
34 try { 34 try {
35 await bluebird.map(metafiles, metafile => { 35 await map(metafiles, metafile => {
36 return this.deleteIfOlderThan(metafile, this.lastExecutionTimeMs) 36 return this.deleteIfOlderThan(metafile, this.lastExecutionTimeMs)
37 }, { concurrency: 5 }) 37 }, { concurrency: 5 })
38 } catch (error) { 38 } catch (error) {
diff --git a/server/lib/search.ts b/server/lib/search.ts
index b643a4055..2f4c5eed9 100644
--- a/server/lib/search.ts
+++ b/server/lib/search.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { CONFIG } from '@server/initializers/config' 2import { CONFIG } from '@server/initializers/config'
3import { AccountBlocklistModel } from '@server/models/account/account-blocklist' 3import { AccountBlocklistModel } from '@server/models/account/account-blocklist'
4import { getServerActor } from '@server/models/application/application' 4import { getServerActor } from '@server/models/application/application'
diff --git a/server/lib/signup.ts b/server/lib/signup.ts
index 8fa81e601..3c1397a12 100644
--- a/server/lib/signup.ts
+++ b/server/lib/signup.ts
@@ -1,6 +1,6 @@
1import { UserModel } from '../models/user/user' 1import { IPv4, IPv6, parse, subnetMatch } from 'ipaddr.js'
2import * as ipaddr from 'ipaddr.js'
3import { CONFIG } from '../initializers/config' 2import { CONFIG } from '../initializers/config'
3import { UserModel } from '../models/user/user'
4 4
5const isCidr = require('is-cidr') 5const isCidr = require('is-cidr')
6 6
@@ -22,7 +22,7 @@ async function isSignupAllowed (): Promise<{ allowed: boolean, errorMessage?: st
22function isSignupAllowedForCurrentIP (ip: string) { 22function isSignupAllowedForCurrentIP (ip: string) {
23 if (!ip) return false 23 if (!ip) return false
24 24
25 const addr = ipaddr.parse(ip) 25 const addr = parse(ip)
26 const excludeList = [ 'blacklist' ] 26 const excludeList = [ 'blacklist' ]
27 let matched = '' 27 let matched = ''
28 28
@@ -32,23 +32,23 @@ function isSignupAllowedForCurrentIP (ip: string) {
32 } 32 }
33 33
34 if (addr.kind() === 'ipv4') { 34 if (addr.kind() === 'ipv4') {
35 const addrV4 = ipaddr.IPv4.parse(ip) 35 const addrV4 = IPv4.parse(ip)
36 const rangeList = { 36 const rangeList = {
37 whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v4(cidr)) 37 whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v4(cidr))
38 .map(cidr => ipaddr.IPv4.parseCIDR(cidr)), 38 .map(cidr => IPv4.parseCIDR(cidr)),
39 blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v4(cidr)) 39 blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v4(cidr))
40 .map(cidr => ipaddr.IPv4.parseCIDR(cidr)) 40 .map(cidr => IPv4.parseCIDR(cidr))
41 } 41 }
42 matched = ipaddr.subnetMatch(addrV4, rangeList, 'unknown') 42 matched = subnetMatch(addrV4, rangeList, 'unknown')
43 } else if (addr.kind() === 'ipv6') { 43 } else if (addr.kind() === 'ipv6') {
44 const addrV6 = ipaddr.IPv6.parse(ip) 44 const addrV6 = IPv6.parse(ip)
45 const rangeList = { 45 const rangeList = {
46 whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v6(cidr)) 46 whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v6(cidr))
47 .map(cidr => ipaddr.IPv6.parseCIDR(cidr)), 47 .map(cidr => IPv6.parseCIDR(cidr)),
48 blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v6(cidr)) 48 blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v6(cidr))
49 .map(cidr => ipaddr.IPv6.parseCIDR(cidr)) 49 .map(cidr => IPv6.parseCIDR(cidr))
50 } 50 }
51 matched = ipaddr.subnetMatch(addrV6, rangeList, 'unknown') 51 matched = subnetMatch(addrV6, rangeList, 'unknown')
52 } 52 }
53 53
54 return !excludeList.includes(matched) 54 return !excludeList.includes(matched)
diff --git a/server/lib/stat-manager.ts b/server/lib/stat-manager.ts
index 3c5e0a93e..03063793d 100644
--- a/server/lib/stat-manager.ts
+++ b/server/lib/stat-manager.ts
@@ -1,14 +1,14 @@
1import { mapSeries } from 'bluebird'
1import { CONFIG } from '@server/initializers/config' 2import { CONFIG } from '@server/initializers/config'
2import { UserModel } from '@server/models/user/user'
3import { ActorFollowModel } from '@server/models/actor/actor-follow' 3import { ActorFollowModel } from '@server/models/actor/actor-follow'
4import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' 4import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
5import { UserModel } from '@server/models/user/user'
5import { VideoModel } from '@server/models/video/video' 6import { VideoModel } from '@server/models/video/video'
6import { VideoChannelModel } from '@server/models/video/video-channel' 7import { VideoChannelModel } from '@server/models/video/video-channel'
7import { VideoCommentModel } from '@server/models/video/video-comment' 8import { VideoCommentModel } from '@server/models/video/video-comment'
8import { VideoFileModel } from '@server/models/video/video-file' 9import { VideoFileModel } from '@server/models/video/video-file'
9import { VideoPlaylistModel } from '@server/models/video/video-playlist' 10import { VideoPlaylistModel } from '@server/models/video/video-playlist'
10import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models' 11import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models'
11import * as Bluebird from 'bluebird'
12 12
13class StatsManager { 13class StatsManager {
14 14
@@ -107,7 +107,7 @@ class StatsManager {
107 107
108 strategies.push({ strategy: 'manual', size: null }) 108 strategies.push({ strategy: 'manual', size: null })
109 109
110 return Bluebird.mapSeries(strategies, r => { 110 return mapSeries(strategies, r => {
111 return VideoRedundancyModel.getStats(r.strategy) 111 return VideoRedundancyModel.getStats(r.strategy)
112 .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size })) 112 .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size }))
113 }) 113 })