diff options
Diffstat (limited to 'server/lib')
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 @@ | |||
1 | import * as WebFinger from 'webfinger.js' | 1 | import WebFinger from 'webfinger.js' |
2 | import { isProdInstance } from '@server/helpers/core-utils' | 2 | import { isProdInstance } from '@server/helpers/core-utils' |
3 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' | 3 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' |
4 | import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants' | 4 | import { 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 @@ | |||
1 | import { retryTransactionWrapper } from '@server/helpers/database-utils' | 1 | import Bluebird from 'bluebird' |
2 | import * as Bluebird from 'bluebird' | ||
3 | import { URL } from 'url' | 2 | import { URL } from 'url' |
3 | import { retryTransactionWrapper } from '@server/helpers/database-utils' | ||
4 | import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' | 4 | import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' |
5 | import { logger } from '../../helpers/logger' | 5 | import { logger } from '../../helpers/logger' |
6 | import { doJSONRequest } from '../../helpers/requests' | 6 | import { doJSONRequest } from '../../helpers/requests' |
7 | import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants' | 7 | import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants' |
8 | 8 | ||
9 | type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) | 9 | type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) |
10 | type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) | 10 | type CleanerFunction = (startedDate: Date) => Promise<any> |
11 | 11 | ||
12 | async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) { | 12 | async 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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { getAPId } from '@server/helpers/activitypub' | 2 | import { getAPId } from '@server/helpers/activitypub' |
3 | import { isArray } from '@server/helpers/custom-validators/misc' | 3 | import { isArray } from '@server/helpers/custom-validators/misc' |
4 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 4 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
@@ -24,7 +24,7 @@ import { | |||
24 | const lTags = loggerTagsFactory('ap', 'video-playlist') | 24 | const lTags = loggerTagsFactory('ap', 'video-playlist') |
25 | 25 | ||
26 | async function createAccountPlaylists (playlistUrls: string[]) { | 26 | async 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 | |||
140 | async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) { | 140 | async 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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { Transaction } from 'sequelize' | 2 | import { Transaction } from 'sequelize' |
3 | import { getServerActor } from '@server/models/application/application' | 3 | import { getServerActor } from '@server/models/application/application' |
4 | import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' | 4 | import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' |
@@ -38,7 +38,7 @@ async function changeVideoChannelShare ( | |||
38 | } | 38 | } |
39 | 39 | ||
40 | async function addVideoShares (shareUrls: string[], video: MVideoId) { | 40 | async 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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { checkUrlsSameHost } from '../../helpers/activitypub' | 2 | import { checkUrlsSameHost } from '../../helpers/activitypub' |
3 | import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' | 3 | import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' |
4 | import { logger } from '../../helpers/logger' | 4 | import { logger } from '../../helpers/logger' |
@@ -18,7 +18,7 @@ type ResolveThreadParams = { | |||
18 | type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }> | 18 | type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }> |
19 | 19 | ||
20 | async function addVideoComments (commentUrls: string[]) { | 20 | async 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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { Transaction } from 'sequelize' | 2 | import { Transaction } from 'sequelize' |
3 | import { doJSONRequest } from '@server/helpers/requests' | 3 | import { doJSONRequest } from '@server/helpers/requests' |
4 | import { VideoRateType } from '../../../shared/models/videos' | 4 | import { VideoRateType } from '../../../shared/models/videos' |
@@ -15,7 +15,7 @@ import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlBy | |||
15 | const lTags = loggerTagsFactory('ap', 'video-rate', 'create') | 15 | const lTags = loggerTagsFactory('ap', 'video-rate', 'create') |
16 | 16 | ||
17 | async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) { | 17 | async 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 @@ | |||
1 | import { maxBy, minBy } from 'lodash' | 1 | import { maxBy, minBy } from 'lodash' |
2 | import * as magnetUtil from 'magnet-uri' | 2 | import magnetUtil from 'magnet-uri' |
3 | import { basename } from 'path' | 3 | import { basename } from 'path' |
4 | import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos' | 4 | import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos' |
5 | import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { AccessDeniedError } from 'oauth2-server' | 2 | import { AccessDeniedError } from 'oauth2-server' |
3 | import { PluginManager } from '@server/lib/plugins/plugin-manager' | 3 | import { PluginManager } from '@server/lib/plugins/plugin-manager' |
4 | import { ActorModel } from '@server/models/actor/actor' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { | 2 | import { |
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 @@ | |||
1 | import * as LRUCache from 'lru-cache' | 1 | import LRUCache from 'lru-cache' |
2 | import { MOAuthTokenUser } from '@server/types/models' | 2 | import { MOAuthTokenUser } from '@server/types/models' |
3 | import { LRU_CACHE } from '../../initializers/constants' | 3 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { readFile } from 'fs-extra' | 2 | import { readFile } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import validator from 'validator' | 4 | import 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 @@ | |||
1 | import { remove } from 'fs-extra' | 1 | import { remove } from 'fs-extra' |
2 | import { logger } from '../../helpers/logger' | 2 | import { logger } from '../../helpers/logger' |
3 | import * as memoizee from 'memoizee' | 3 | import memoizee from 'memoizee' |
4 | 4 | ||
5 | type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined | 5 | type 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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import * as Bull from 'bull' | 2 | import { Job } from 'bull' |
3 | import { checkUrlsSameHost } from '@server/helpers/activitypub' | 3 | import { checkUrlsSameHost } from '@server/helpers/activitypub' |
4 | import { | 4 | import { |
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 | ||
21 | async function processActivityPubCleaner (_job: Bull.Job) { | 21 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url' | 2 | import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url' |
3 | import { ActivitypubFollowPayload } from '@shared/models' | 3 | import { ActivitypubFollowPayload } from '@shared/models' |
4 | import { sanitizeHost } from '../../../helpers/core-utils' | 4 | import { sanitizeHost } from '../../../helpers/core-utils' |
@@ -13,7 +13,7 @@ import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../activi | |||
13 | import { sendFollow } from '../../activitypub/send' | 13 | import { sendFollow } from '../../activitypub/send' |
14 | import { Notifier } from '../../notifier' | 14 | import { Notifier } from '../../notifier' |
15 | 15 | ||
16 | async function processActivityPubFollow (job: Bull.Job) { | 16 | async 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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import * as Bull from 'bull' | 2 | import { Job } from 'bull' |
3 | import { ActivitypubHttpBroadcastPayload } from '@shared/models' | 3 | import { ActivitypubHttpBroadcastPayload } from '@shared/models' |
4 | import { logger } from '../../../helpers/logger' | 4 | import { logger } from '../../../helpers/logger' |
5 | import { doRequest } from '../../../helpers/requests' | 5 | import { doRequest } from '../../../helpers/requests' |
@@ -7,7 +7,7 @@ import { BROADCAST_CONCURRENCY } from '../../../initializers/constants' | |||
7 | import { ActorFollowScoreCache } from '../../files-cache' | 7 | import { ActorFollowScoreCache } from '../../files-cache' |
8 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' | 8 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' |
9 | 9 | ||
10 | async function processActivityPubHttpBroadcast (job: Bull.Job) { | 10 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' | 2 | import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 4 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
@@ -13,7 +13,7 @@ import { addVideoShares } from '../../activitypub/share' | |||
13 | import { addVideoComments } from '../../activitypub/video-comments' | 13 | import { addVideoComments } from '../../activitypub/video-comments' |
14 | import { createRates } from '../../activitypub/video-rates' | 14 | import { createRates } from '../../activitypub/video-rates' |
15 | 15 | ||
16 | async function processActivityPubHttpFetcher (job: Bull.Job) { | 16 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { ActivitypubHttpUnicastPayload } from '@shared/models' | 2 | import { ActivitypubHttpUnicastPayload } from '@shared/models' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { doRequest } from '../../../helpers/requests' | 4 | import { doRequest } from '../../../helpers/requests' |
5 | import { ActorFollowScoreCache } from '../../files-cache' | 5 | import { ActorFollowScoreCache } from '../../files-cache' |
6 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' | 6 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' |
7 | 7 | ||
8 | async function processActivityPubHttpUnicast (job: Bull.Job) { | 8 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists' | 2 | import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists' |
3 | import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos' | 3 | import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos' |
4 | import { loadVideoByUrl } from '@server/lib/model-loaders' | 4 | import { loadVideoByUrl } from '@server/lib/model-loaders' |
@@ -8,7 +8,7 @@ import { ActorModel } from '../../../models/actor/actor' | |||
8 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | 8 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' |
9 | import { refreshActorIfNeeded } from '../../activitypub/actors' | 9 | import { refreshActorIfNeeded } from '../../activitypub/actors' |
10 | 10 | ||
11 | async function refreshAPObject (job: Bull.Job) { | 11 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors' | 2 | import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors' |
3 | import { ActorModel } from '@server/models/actor/actor' | 3 | import { ActorModel } from '@server/models/actor/actor' |
4 | import { ActorKeysPayload } from '@shared/models' | 4 | import { ActorKeysPayload } from '@shared/models' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
6 | 6 | ||
7 | async function processActorKeys (job: Bull.Job) { | 7 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { EmailPayload } from '@shared/models' | ||
2 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
3 | import { Emailer } from '../../emailer' | 4 | import { Emailer } from '../../emailer' |
4 | import { EmailPayload } from '@shared/models' | ||
5 | 5 | ||
6 | async function processEmail (job: Bull.Job) { | 6 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { remove } from 'fs-extra' | 2 | import { remove } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { logger } from '@server/helpers/logger' | 4 | import { logger } from '@server/helpers/logger' |
@@ -12,7 +12,7 @@ import { VideoJobInfoModel } from '@server/models/video/video-job-info' | |||
12 | import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' | 12 | import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' |
13 | import { MoveObjectStoragePayload, VideoStorage } from '../../../../shared' | 13 | import { MoveObjectStoragePayload, VideoStorage } from '../../../../shared' |
14 | 14 | ||
15 | export async function processMoveToObjectStorage (job: Bull.Job) { | 15 | export 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { copy, stat } from 'fs-extra' | 2 | import { copy, stat } from 'fs-extra' |
3 | import { getLowercaseExtension } from '@server/helpers/core-utils' | 3 | import { getLowercaseExtension } from '@server/helpers/core-utils' |
4 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 4 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
@@ -16,7 +16,7 @@ import { VideoModel } from '../../../models/video/video' | |||
16 | import { VideoFileModel } from '../../../models/video/video-file' | 16 | import { VideoFileModel } from '../../../models/video/video-file' |
17 | import { createHlsJobIfEnabled } from './video-transcoding' | 17 | import { createHlsJobIfEnabled } from './video-transcoding' |
18 | 18 | ||
19 | async function processVideoFileImport (job: Bull.Job) { | 19 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { move, remove, stat } from 'fs-extra' | 2 | import { move, remove, stat } from 'fs-extra' |
3 | import { getLowercaseExtension } from '@server/helpers/core-utils' | 3 | import { getLowercaseExtension } from '@server/helpers/core-utils' |
4 | import { retryTransactionWrapper } from '@server/helpers/database-utils' | 4 | import { retryTransactionWrapper } from '@server/helpers/database-utils' |
@@ -37,7 +37,7 @@ import { federateVideoIfNeeded } from '../../activitypub/videos' | |||
37 | import { Notifier } from '../../notifier' | 37 | import { Notifier } from '../../notifier' |
38 | import { generateVideoMiniature } from '../../thumbnail' | 38 | import { generateVideoMiniature } from '../../thumbnail' |
39 | 39 | ||
40 | async function processVideoImport (job: Bull.Job) { | 40 | async 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 | ||
55 | async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentPayload) { | 55 | async 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 | ||
71 | async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutubeDLPayload) { | 71 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { pathExists, readdir, remove } from 'fs-extra' | 2 | import { pathExists, readdir, remove } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils' | 4 | import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils' |
@@ -17,7 +17,7 @@ import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models' | |||
17 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' | 17 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' |
18 | import { logger } from '../../../helpers/logger' | 18 | import { logger } from '../../../helpers/logger' |
19 | 19 | ||
20 | async function processVideoLiveEnding (job: Bull.Job) { | 20 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { logger } from '../../../helpers/logger' | ||
3 | import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler' | 2 | import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler' |
4 | import { VideoRedundancyPayload } from '@shared/models' | 3 | import { VideoRedundancyPayload } from '@shared/models' |
4 | import { logger } from '../../../helpers/logger' | ||
5 | 5 | ||
6 | async function processVideoRedundancy (job: Bull.Job) { | 6 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' | 2 | import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' |
3 | import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' | 3 | import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' |
4 | import { VideoPathManager } from '@server/lib/video-path-manager' | 4 | import { 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 | ||
28 | type HandlerFunction = (job: Bull.Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void> | 28 | type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void> |
29 | 29 | ||
30 | const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = { | 30 | const 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 | ||
37 | const lTags = loggerTagsFactory('transcoding') | 37 | const lTags = loggerTagsFactory('transcoding') |
38 | 38 | ||
39 | async function processVideoTranscoding (job: Bull.Job) { | 39 | async 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 | ||
67 | async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) { | 67 | async 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 | ||
92 | async function handleNewWebTorrentResolutionJob ( | 92 | async 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 | ||
107 | async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { | 107 | async 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 | ||
117 | async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { | 117 | async 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 @@ | |||
1 | import * as Bull from 'bull' | 1 | import Bull, { Job, JobOptions, Queue } from 'bull' |
2 | import { jobStates } from '@server/helpers/custom-validators/jobs' | 2 | import { jobStates } from '@server/helpers/custom-validators/jobs' |
3 | import { CONFIG } from '@server/initializers/config' | 3 | import { CONFIG } from '@server/initializers/config' |
4 | import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy' | 4 | import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy' |
@@ -30,12 +30,12 @@ import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unica | |||
30 | import { refreshAPObject } from './handlers/activitypub-refresher' | 30 | import { refreshAPObject } from './handlers/activitypub-refresher' |
31 | import { processActorKeys } from './handlers/actor-keys' | 31 | import { processActorKeys } from './handlers/actor-keys' |
32 | import { processEmail } from './handlers/email' | 32 | import { processEmail } from './handlers/email' |
33 | import { processMoveToObjectStorage } from './handlers/move-to-object-storage' | ||
33 | import { processVideoFileImport } from './handlers/video-file-import' | 34 | import { processVideoFileImport } from './handlers/video-file-import' |
34 | import { processVideoImport } from './handlers/video-import' | 35 | import { processVideoImport } from './handlers/video-import' |
35 | import { processVideoLiveEnding } from './handlers/video-live-ending' | 36 | import { processVideoLiveEnding } from './handlers/video-live-ending' |
36 | import { processVideoTranscoding } from './handlers/video-transcoding' | 37 | import { processVideoTranscoding } from './handlers/video-transcoding' |
37 | import { processVideosViews } from './handlers/video-views' | 38 | import { processVideosViews } from './handlers/video-views' |
38 | import { processMoveToObjectStorage } from './handlers/move-to-object-storage' | ||
39 | 39 | ||
40 | type CreateJobArgument = | 40 | type 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 | ||
62 | const handlers: { [id in JobType]: (job: Bull.Job) => Promise<any> } = { | 62 | const 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 | ||
2 | import * as Bluebird from 'bluebird' | 2 | import { mapSeries } from 'bluebird' |
3 | import * as chokidar from 'chokidar' | 3 | import { FSWatcher, watch } from 'chokidar' |
4 | import { FfmpegCommand } from 'fluent-ffmpeg' | 4 | import { FfmpegCommand } from 'fluent-ffmpeg' |
5 | import { appendFile, ensureDir, readFile, stat } from 'fs-extra' | 5 | import { appendFile, ensureDir, readFile, stat } from 'fs-extra' |
6 | import { basename, join } from 'path' | 6 | import { 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 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import { queue } from 'async' | 2 | import { queue } from 'async' |
3 | import * as LRUCache from 'lru-cache' | 3 | import LRUCache from 'lru-cache' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { getLowercaseExtension } from '@server/helpers/core-utils' | 5 | import { getLowercaseExtension } from '@server/helpers/core-utils' |
6 | import { buildUUID } from '@server/helpers/uuid' | 6 | import { 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 @@ | |||
1 | import { Server } from 'http' | 1 | import { Server as HTTPServer } from 'http' |
2 | import * as SocketIO from 'socket.io' | 2 | import { Namespace, Server as SocketServer, Socket } from 'socket.io' |
3 | import { isIdValid } from '@server/helpers/custom-validators/misc' | ||
3 | import { MVideo } from '@server/types/models' | 4 | import { MVideo } from '@server/types/models' |
4 | import { UserNotificationModelForApi } from '@server/types/models/user' | 5 | import { UserNotificationModelForApi } from '@server/types/models/user' |
5 | import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' | 6 | import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' |
6 | import { logger } from '../helpers/logger' | 7 | import { logger } from '../helpers/logger' |
7 | import { authenticateSocket } from '../middlewares' | 8 | import { authenticateSocket } from '../middlewares' |
8 | import { isIdValid } from '@server/helpers/custom-validators/misc' | ||
9 | 9 | ||
10 | class PeerTubeSocket { | 10 | class 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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import Bluebird from 'bluebird' |
2 | import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models' | 2 | import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { PluginManager } from './plugin-manager' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { buildLogger } from '@server/helpers/logger' | 3 | import { buildLogger } from '@server/helpers/logger' |
4 | import { CONFIG } from '@server/initializers/config' | 4 | import { 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 @@ | |||
1 | import decache from 'decache' | 1 | import decache from 'decache' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { createReadStream, createWriteStream } from 'fs' | 3 | import { createReadStream, createWriteStream } from 'fs' |
4 | import { ensureDir, outputFile, readJSON } from 'fs-extra' | 4 | import { ensureDir, outputFile, readJSON } from 'fs-extra' |
5 | import { basename, join } from 'path' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { logger } from '@server/helpers/logger' | 2 | import { logger } from '@server/helpers/logger' |
3 | import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth' | 3 | import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth' |
4 | import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { createClient, RedisClient } from 'redis' | 2 | import { createClient, RedisClient } from 'redis' |
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | import { generateRandomString } from '../helpers/utils' | 4 | import { 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 @@ | |||
1 | import Bluebird from 'bluebird' | ||
1 | import { logger } from '../../helpers/logger' | 2 | import { logger } from '../../helpers/logger' |
2 | import * as Bluebird from 'bluebird' | ||
3 | 3 | ||
4 | export abstract class AbstractScheduler { | 4 | export 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 @@ | |||
1 | import * as bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { readdir, remove, stat } from 'fs-extra' | 2 | import { readdir, remove, stat } from 'fs-extra' |
3 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 3 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
4 | import { getResumableUploadPath } from '@server/helpers/upload' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { CONFIG } from '@server/initializers/config' | 2 | import { CONFIG } from '@server/initializers/config' |
3 | import { AccountBlocklistModel } from '@server/models/account/account-blocklist' | 3 | import { AccountBlocklistModel } from '@server/models/account/account-blocklist' |
4 | import { getServerActor } from '@server/models/application/application' | 4 | import { 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 @@ | |||
1 | import { UserModel } from '../models/user/user' | 1 | import { IPv4, IPv6, parse, subnetMatch } from 'ipaddr.js' |
2 | import * as ipaddr from 'ipaddr.js' | ||
3 | import { CONFIG } from '../initializers/config' | 2 | import { CONFIG } from '../initializers/config' |
3 | import { UserModel } from '../models/user/user' | ||
4 | 4 | ||
5 | const isCidr = require('is-cidr') | 5 | const isCidr = require('is-cidr') |
6 | 6 | ||
@@ -22,7 +22,7 @@ async function isSignupAllowed (): Promise<{ allowed: boolean, errorMessage?: st | |||
22 | function isSignupAllowedForCurrentIP (ip: string) { | 22 | function 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 @@ | |||
1 | import { mapSeries } from 'bluebird' | ||
1 | import { CONFIG } from '@server/initializers/config' | 2 | import { CONFIG } from '@server/initializers/config' |
2 | import { UserModel } from '@server/models/user/user' | ||
3 | import { ActorFollowModel } from '@server/models/actor/actor-follow' | 3 | import { ActorFollowModel } from '@server/models/actor/actor-follow' |
4 | import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' | 4 | import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' |
5 | import { UserModel } from '@server/models/user/user' | ||
5 | import { VideoModel } from '@server/models/video/video' | 6 | import { VideoModel } from '@server/models/video/video' |
6 | import { VideoChannelModel } from '@server/models/video/video-channel' | 7 | import { VideoChannelModel } from '@server/models/video/video-channel' |
7 | import { VideoCommentModel } from '@server/models/video/video-comment' | 8 | import { VideoCommentModel } from '@server/models/video/video-comment' |
8 | import { VideoFileModel } from '@server/models/video/video-file' | 9 | import { VideoFileModel } from '@server/models/video/video-file' |
9 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' | 10 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' |
10 | import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models' | 11 | import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models' |
11 | import * as Bluebird from 'bluebird' | ||
12 | 12 | ||
13 | class StatsManager { | 13 | class 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 | }) |