From 41fb13c330de629df2d23379209e79c7af0f2e9a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Aug 2021 14:32:44 +0200 Subject: esModuleInterop to true --- server/lib/activitypub/actors/webfinger.ts | 2 +- server/lib/activitypub/crawl.ts | 6 +++--- server/lib/activitypub/playlists/create-update.ts | 6 +++--- server/lib/activitypub/share.ts | 4 ++-- server/lib/activitypub/video-comments.ts | 4 ++-- server/lib/activitypub/video-rates.ts | 4 ++-- .../videos/shared/object-to-model-attributes.ts | 2 +- server/lib/auth/oauth-model.ts | 2 +- server/lib/auth/oauth.ts | 2 +- server/lib/auth/tokens-cache.ts | 2 +- server/lib/client-html.ts | 2 +- .../abstract-video-static-file-cache.ts | 2 +- .../lib/job-queue/handlers/activitypub-cleaner.ts | 12 ++++++------ .../lib/job-queue/handlers/activitypub-follow.ts | 4 ++-- .../handlers/activitypub-http-broadcast.ts | 8 ++++---- .../job-queue/handlers/activitypub-http-fetcher.ts | 4 ++-- .../job-queue/handlers/activitypub-http-unicast.ts | 4 ++-- .../job-queue/handlers/activitypub-refresher.ts | 4 ++-- server/lib/job-queue/handlers/actor-keys.ts | 4 ++-- server/lib/job-queue/handlers/email.ts | 6 +++--- .../job-queue/handlers/move-to-object-storage.ts | 4 ++-- server/lib/job-queue/handlers/video-file-import.ts | 4 ++-- server/lib/job-queue/handlers/video-import.ts | 8 ++++---- server/lib/job-queue/handlers/video-live-ending.ts | 4 ++-- server/lib/job-queue/handlers/video-redundancy.ts | 6 +++--- server/lib/job-queue/handlers/video-transcoding.ts | 14 +++++++------- server/lib/job-queue/job-queue.ts | 14 +++++++------- server/lib/live/shared/muxing-session.ts | 14 +++++++------- server/lib/local-actor.ts | 2 +- server/lib/peertube-socket.ts | 14 +++++++------- server/lib/plugins/hooks.ts | 2 +- server/lib/plugins/plugin-helpers-builder.ts | 2 +- server/lib/plugins/plugin-manager.ts | 2 +- server/lib/plugins/register-helpers.ts | 2 +- server/lib/redis.ts | 2 +- server/lib/schedulers/abstract-scheduler.ts | 2 +- .../remove-dangling-resumable-uploads-scheduler.ts | 4 ++-- server/lib/search.ts | 2 +- server/lib/signup.ts | 22 +++++++++++----------- server/lib/stat-manager.ts | 6 +++--- 40 files changed, 107 insertions(+), 107 deletions(-) (limited to 'server/lib') 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 @@ -import * as WebFinger from 'webfinger.js' +import WebFinger from 'webfinger.js' import { isProdInstance } from '@server/helpers/core-utils' import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' 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 @@ -import { retryTransactionWrapper } from '@server/helpers/database-utils' -import * as Bluebird from 'bluebird' +import Bluebird from 'bluebird' import { URL } from 'url' +import { retryTransactionWrapper } from '@server/helpers/database-utils' import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' import { logger } from '../../helpers/logger' import { doJSONRequest } from '../../helpers/requests' import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants' type HandlerFunction = (items: T[]) => (Promise | Bluebird) -type CleanerFunction = (startedDate: Date) => (Promise | Bluebird) +type CleanerFunction = (startedDate: Date) => Promise async function crawlCollectionPage (argUrl: string, handler: HandlerFunction, cleaner?: CleanerFunction) { 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 @@ -import * as Bluebird from 'bluebird' +import { map } from 'bluebird' import { getAPId } from '@server/helpers/activitypub' import { isArray } from '@server/helpers/custom-validators/misc' import { logger, loggerTagsFactory } from '@server/helpers/logger' @@ -24,7 +24,7 @@ import { const lTags = loggerTagsFactory('ap', 'video-playlist') async function createAccountPlaylists (playlistUrls: string[]) { - await Bluebird.map(playlistUrls, async playlistUrl => { + await map(playlistUrls, async playlistUrl => { try { const exists = await VideoPlaylistModel.doesPlaylistExist(playlistUrl) if (exists === true) return @@ -140,7 +140,7 @@ async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MV async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) { const elementsToCreate: FilteredModelAttributes[] = [] - await Bluebird.map(elementUrls, async elementUrl => { + await map(elementUrls, async elementUrl => { try { const { elementObject } = await fetchRemotePlaylistElement(elementUrl) 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 @@ -import * as Bluebird from 'bluebird' +import { map } from 'bluebird' import { Transaction } from 'sequelize' import { getServerActor } from '@server/models/application/application' import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' @@ -38,7 +38,7 @@ async function changeVideoChannelShare ( } async function addVideoShares (shareUrls: string[], video: MVideoId) { - await Bluebird.map(shareUrls, async shareUrl => { + await map(shareUrls, async shareUrl => { try { await addVideoShare(shareUrl, video) } 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 @@ -import * as Bluebird from 'bluebird' +import { map } from 'bluebird' import { checkUrlsSameHost } from '../../helpers/activitypub' import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' import { logger } from '../../helpers/logger' @@ -18,7 +18,7 @@ type ResolveThreadParams = { type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }> async function addVideoComments (commentUrls: string[]) { - return Bluebird.map(commentUrls, async commentUrl => { + return map(commentUrls, async commentUrl => { try { await resolveThread({ url: commentUrl, isVideo: false }) } 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 @@ -import * as Bluebird from 'bluebird' +import { map } from 'bluebird' import { Transaction } from 'sequelize' import { doJSONRequest } from '@server/helpers/requests' import { VideoRateType } from '../../../shared/models/videos' @@ -15,7 +15,7 @@ import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlBy const lTags = loggerTagsFactory('ap', 'video-rate', 'create') async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) { - await Bluebird.map(ratesUrl, async rateUrl => { + await map(ratesUrl, async rateUrl => { try { await createRate(rateUrl, video, rate) } 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 @@ import { maxBy, minBy } from 'lodash' -import * as magnetUtil from 'magnet-uri' +import magnetUtil from 'magnet-uri' import { basename } from 'path' import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos' 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 @@ -import * as express from 'express' +import express from 'express' import { AccessDeniedError } from 'oauth2-server' import { PluginManager } from '@server/lib/plugins/plugin-manager' 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 @@ -import * as express from 'express' +import express from 'express' import { InvalidClientError, 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 @@ -import * as LRUCache from 'lru-cache' +import LRUCache from 'lru-cache' import { MOAuthTokenUser } from '@server/types/models' import { LRU_CACHE } from '../../initializers/constants' 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 @@ -import * as express from 'express' +import express from 'express' import { readFile } from 'fs-extra' import { join } from 'path' 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 @@ import { remove } from 'fs-extra' import { logger } from '../../helpers/logger' -import * as memoizee from 'memoizee' +import memoizee from 'memoizee' type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined 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 @@ -import * as Bluebird from 'bluebird' -import * as Bull from 'bull' +import { map } from 'bluebird' +import { Job } from 'bull' import { checkUrlsSameHost } from '@server/helpers/activitypub' import { isAnnounceActivityValid, @@ -18,14 +18,14 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat // Job to clean remote interactions off local videos -async function processActivityPubCleaner (_job: Bull.Job) { +async function processActivityPubCleaner (_job: Job) { logger.info('Processing ActivityPub cleaner.') { const rateUrls = await AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos() const { bodyValidator, deleter, updater } = rateOptionsFactory() - await Bluebird.map(rateUrls, async rateUrl => { + await map(rateUrls, async rateUrl => { try { const result = await updateObjectIfNeeded(rateUrl, bodyValidator, updater, deleter) @@ -44,7 +44,7 @@ async function processActivityPubCleaner (_job: Bull.Job) { const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos() const { bodyValidator, deleter, updater } = shareOptionsFactory() - await Bluebird.map(shareUrls, async shareUrl => { + await map(shareUrls, async shareUrl => { try { await updateObjectIfNeeded(shareUrl, bodyValidator, updater, deleter) } catch (err) { @@ -57,7 +57,7 @@ async function processActivityPubCleaner (_job: Bull.Job) { const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos() const { bodyValidator, deleter, updater } = commentOptionsFactory() - await Bluebird.map(commentUrls, async commentUrl => { + await map(commentUrls, async commentUrl => { try { await updateObjectIfNeeded(commentUrl, bodyValidator, updater, deleter) } 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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url' import { ActivitypubFollowPayload } from '@shared/models' import { sanitizeHost } from '../../../helpers/core-utils' @@ -13,7 +13,7 @@ import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../activi import { sendFollow } from '../../activitypub/send' import { Notifier } from '../../notifier' -async function processActivityPubFollow (job: Bull.Job) { +async function processActivityPubFollow (job: Job) { const payload = job.data as ActivitypubFollowPayload const host = payload.host 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 @@ -import * as Bluebird from 'bluebird' -import * as Bull from 'bull' +import { map } from 'bluebird' +import { Job } from 'bull' import { ActivitypubHttpBroadcastPayload } from '@shared/models' import { logger } from '../../../helpers/logger' import { doRequest } from '../../../helpers/requests' @@ -7,7 +7,7 @@ import { BROADCAST_CONCURRENCY } from '../../../initializers/constants' import { ActorFollowScoreCache } from '../../files-cache' import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' -async function processActivityPubHttpBroadcast (job: Bull.Job) { +async function processActivityPubHttpBroadcast (job: Job) { logger.info('Processing ActivityPub broadcast in job %d.', job.id) const payload = job.data as ActivitypubHttpBroadcastPayload @@ -25,7 +25,7 @@ async function processActivityPubHttpBroadcast (job: Bull.Job) { const badUrls: string[] = [] const goodUrls: string[] = [] - await Bluebird.map(payload.uris, uri => { + await map(payload.uris, uri => { return doRequest(uri, options) .then(() => goodUrls.push(uri)) .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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' import { logger } from '../../../helpers/logger' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' @@ -13,7 +13,7 @@ import { addVideoShares } from '../../activitypub/share' import { addVideoComments } from '../../activitypub/video-comments' import { createRates } from '../../activitypub/video-rates' -async function processActivityPubHttpFetcher (job: Bull.Job) { +async function processActivityPubHttpFetcher (job: Job) { logger.info('Processing ActivityPub fetcher in job %d.', job.id) 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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { ActivitypubHttpUnicastPayload } from '@shared/models' import { logger } from '../../../helpers/logger' import { doRequest } from '../../../helpers/requests' import { ActorFollowScoreCache } from '../../files-cache' import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' -async function processActivityPubHttpUnicast (job: Bull.Job) { +async function processActivityPubHttpUnicast (job: Job) { logger.info('Processing ActivityPub unicast in job %d.', job.id) 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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists' import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos' import { loadVideoByUrl } from '@server/lib/model-loaders' @@ -8,7 +8,7 @@ import { ActorModel } from '../../../models/actor/actor' import { VideoPlaylistModel } from '../../../models/video/video-playlist' import { refreshActorIfNeeded } from '../../activitypub/actors' -async function refreshAPObject (job: Bull.Job) { +async function refreshAPObject (job: Job) { const payload = job.data as RefreshPayload 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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors' import { ActorModel } from '@server/models/actor/actor' import { ActorKeysPayload } from '@shared/models' import { logger } from '../../../helpers/logger' -async function processActorKeys (job: Bull.Job) { +async function processActorKeys (job: Job) { const payload = job.data as ActorKeysPayload logger.info('Processing actor keys in job %d.', job.id) 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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' +import { EmailPayload } from '@shared/models' import { logger } from '../../../helpers/logger' import { Emailer } from '../../emailer' -import { EmailPayload } from '@shared/models' -async function processEmail (job: Bull.Job) { +async function processEmail (job: Job) { const payload = job.data as EmailPayload logger.info('Processing email in job %d.', job.id) 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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { remove } from 'fs-extra' import { join } from 'path' import { logger } from '@server/helpers/logger' @@ -12,7 +12,7 @@ import { VideoJobInfoModel } from '@server/models/video/video-job-info' import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' import { MoveObjectStoragePayload, VideoStorage } from '../../../../shared' -export async function processMoveToObjectStorage (job: Bull.Job) { +export async function processMoveToObjectStorage (job: Job) { const payload = job.data as MoveObjectStoragePayload logger.info('Moving video %s in job %d.', payload.videoUUID, job.id) 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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { copy, stat } from 'fs-extra' import { getLowercaseExtension } from '@server/helpers/core-utils' import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' @@ -16,7 +16,7 @@ import { VideoModel } from '../../../models/video/video' import { VideoFileModel } from '../../../models/video/video-file' import { createHlsJobIfEnabled } from './video-transcoding' -async function processVideoFileImport (job: Bull.Job) { +async function processVideoFileImport (job: Job) { const payload = job.data as VideoFileImportPayload logger.info('Processing video file import in job %d.', job.id) 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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { move, remove, stat } from 'fs-extra' import { getLowercaseExtension } from '@server/helpers/core-utils' import { retryTransactionWrapper } from '@server/helpers/database-utils' @@ -37,7 +37,7 @@ import { federateVideoIfNeeded } from '../../activitypub/videos' import { Notifier } from '../../notifier' import { generateVideoMiniature } from '../../thumbnail' -async function processVideoImport (job: Bull.Job) { +async function processVideoImport (job: Job) { const payload = job.data as VideoImportPayload if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload) @@ -52,7 +52,7 @@ export { // --------------------------------------------------------------------------- -async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentPayload) { +async function processTorrentImport (job: Job, payload: VideoImportTorrentPayload) { logger.info('Processing torrent video import in job %d.', job.id) const videoImport = await getVideoImportOrDie(payload.videoImportId) @@ -68,7 +68,7 @@ async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentP return processFile(() => downloadWebTorrentVideo(target, VIDEO_IMPORT_TIMEOUT), videoImport, options) } -async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutubeDLPayload) { +async function processYoutubeDLImport (job: Job, payload: VideoImportYoutubeDLPayload) { logger.info('Processing youtubeDL video import in job %d.', job.id) 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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { pathExists, readdir, remove } from 'fs-extra' import { join } from 'path' import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils' @@ -17,7 +17,7 @@ import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models' import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' import { logger } from '../../../helpers/logger' -async function processVideoLiveEnding (job: Bull.Job) { +async function processVideoLiveEnding (job: Job) { const payload = job.data as VideoLiveEndingPayload 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 @@ -import * as Bull from 'bull' -import { logger } from '../../../helpers/logger' +import { Job } from 'bull' import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler' import { VideoRedundancyPayload } from '@shared/models' +import { logger } from '../../../helpers/logger' -async function processVideoRedundancy (job: Bull.Job) { +async function processVideoRedundancy (job: Job) { const payload = job.data as VideoRedundancyPayload logger.info('Processing video redundancy in job %d.', job.id) 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 @@ -import * as Bull from 'bull' +import { Job } from 'bull' import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' import { VideoPathManager } from '@server/lib/video-path-manager' @@ -25,7 +25,7 @@ import { transcodeNewWebTorrentResolution } from '../../transcoding/video-transcoding' -type HandlerFunction = (job: Bull.Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise +type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = { 'new-resolution-to-hls': handleHLSJob, @@ -36,7 +36,7 @@ const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = const lTags = loggerTagsFactory('transcoding') -async function processVideoTranscoding (job: Bull.Job) { +async function processVideoTranscoding (job: Job) { const payload = job.data as VideoTranscodingPayload logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID)) @@ -64,7 +64,7 @@ async function processVideoTranscoding (job: Bull.Job) { // Job handlers // --------------------------------------------------------------------------- -async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) { +async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) { logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid)) const videoFileInput = payload.copyCodecs @@ -90,7 +90,7 @@ async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, vide } async function handleNewWebTorrentResolutionJob ( - job: Bull.Job, + job: Job, payload: NewResolutionTranscodingPayload, video: MVideoFullLight, user: MUserId @@ -104,7 +104,7 @@ async function handleNewWebTorrentResolutionJob ( await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload) } -async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { +async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid)) await mergeAudioVideofile(video, payload.resolution, job) @@ -114,7 +114,7 @@ async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudio await retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user) } -async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { +async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid)) 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 @@ -import * as Bull from 'bull' +import Bull, { Job, JobOptions, Queue } from 'bull' import { jobStates } from '@server/helpers/custom-validators/jobs' import { CONFIG } from '@server/initializers/config' import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy' @@ -30,12 +30,12 @@ import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unica import { refreshAPObject } from './handlers/activitypub-refresher' import { processActorKeys } from './handlers/actor-keys' import { processEmail } from './handlers/email' +import { processMoveToObjectStorage } from './handlers/move-to-object-storage' import { processVideoFileImport } from './handlers/video-file-import' import { processVideoImport } from './handlers/video-import' import { processVideoLiveEnding } from './handlers/video-live-ending' import { processVideoTranscoding } from './handlers/video-transcoding' import { processVideosViews } from './handlers/video-views' -import { processMoveToObjectStorage } from './handlers/move-to-object-storage' type CreateJobArgument = { type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } | @@ -59,7 +59,7 @@ export type CreateJobOptions = { priority?: number } -const handlers: { [id in JobType]: (job: Bull.Job) => Promise } = { +const handlers: { [id in JobType]: (job: Job) => Promise } = { 'activitypub-http-broadcast': processActivityPubHttpBroadcast, 'activitypub-http-unicast': processActivityPubHttpUnicast, 'activitypub-http-fetcher': processActivityPubHttpFetcher, @@ -99,7 +99,7 @@ class JobQueue { private static instance: JobQueue - private queues: { [id in JobType]?: Bull.Queue } = {} + private queues: { [id in JobType]?: Queue } = {} private initialized = false private jobRedisPrefix: string @@ -160,7 +160,7 @@ class JobQueue { return } - const jobArgs: Bull.JobOptions = { + const jobArgs: JobOptions = { backoff: { delay: 60 * 1000, type: 'exponential' }, attempts: JOB_ATTEMPTS[obj.type], timeout: JOB_TTL[obj.type], @@ -177,11 +177,11 @@ class JobQueue { count: number asc?: boolean jobType: JobType - }): Promise { + }): Promise { const { state, start, count, asc, jobType } = options const states = state ? [ state ] : jobStates - let results: Bull.Job[] = [] + let results: Job[] = [] const filteredJobTypes = this.filterJobTypes(jobType) 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 @@ -import * as Bluebird from 'bluebird' -import * as chokidar from 'chokidar' +import { mapSeries } from 'bluebird' +import { FSWatcher, watch } from 'chokidar' import { FfmpegCommand } from 'fluent-ffmpeg' import { appendFile, ensureDir, readFile, stat } from 'fs-extra' import { basename, join } from 'path' @@ -67,8 +67,8 @@ class MuxingSession extends EventEmitter { private segmentsToProcessPerPlaylist: { [playlistId: string]: string[] } = {} - private tsWatcher: chokidar.FSWatcher - private masterWatcher: chokidar.FSWatcher + private tsWatcher: FSWatcher + private masterWatcher: FSWatcher private readonly isAbleToUploadVideoWithCache = memoizee((userId: number) => { return isAbleToUploadVideo(userId, 1000) @@ -197,7 +197,7 @@ class MuxingSession extends EventEmitter { } private watchMasterFile (outPath: string) { - this.masterWatcher = chokidar.watch(outPath + '/' + this.streamingPlaylist.playlistFilename) + this.masterWatcher = watch(outPath + '/' + this.streamingPlaylist.playlistFilename) this.masterWatcher.on('add', () => { this.emit('master-playlist-created', { videoId: this.videoId }) @@ -210,7 +210,7 @@ class MuxingSession extends EventEmitter { private watchTSFiles (outPath: string) { const startStreamDateTime = new Date().getTime() - this.tsWatcher = chokidar.watch(outPath + '/*.ts') + this.tsWatcher = watch(outPath + '/*.ts') const playlistIdMatcher = /^([\d+])-/ @@ -306,7 +306,7 @@ class MuxingSession extends EventEmitter { } private processSegments (hlsVideoPath: string, segmentPaths: string[]) { - Bluebird.mapSeries(segmentPaths, async previousSegment => { + mapSeries(segmentPaths, async previousSegment => { // Add sha hash of previous segments, because ffmpeg should have finished generating them await LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment) 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 @@ import 'multer' import { queue } from 'async' -import * as LRUCache from 'lru-cache' +import LRUCache from 'lru-cache' import { join } from 'path' import { getLowercaseExtension } from '@server/helpers/core-utils' 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 @@ -import { Server } from 'http' -import * as SocketIO from 'socket.io' +import { Server as HTTPServer } from 'http' +import { Namespace, Server as SocketServer, Socket } from 'socket.io' +import { isIdValid } from '@server/helpers/custom-validators/misc' import { MVideo } from '@server/types/models' import { UserNotificationModelForApi } from '@server/types/models/user' import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' import { logger } from '../helpers/logger' import { authenticateSocket } from '../middlewares' -import { isIdValid } from '@server/helpers/custom-validators/misc' class PeerTubeSocket { private static instance: PeerTubeSocket - private userNotificationSockets: { [ userId: number ]: SocketIO.Socket[] } = {} - private liveVideosNamespace: SocketIO.Namespace + private userNotificationSockets: { [ userId: number ]: Socket[] } = {} + private liveVideosNamespace: Namespace private constructor () {} - init (server: Server) { - const io = new SocketIO.Server(server) + init (server: HTTPServer) { + const io = new SocketServer(server) io.of('/user-notifications') .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 @@ -import * as Bluebird from 'bluebird' +import Bluebird from 'bluebird' import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models' import { logger } from '../../helpers/logger' 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 @@ -import * as express from 'express' +import express from 'express' import { join } from 'path' import { buildLogger } from '@server/helpers/logger' 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 @@ import decache from 'decache' -import * as express from 'express' +import express from 'express' import { createReadStream, createWriteStream } from 'fs' import { ensureDir, outputFile, readJSON } from 'fs-extra' 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 @@ -import * as express from 'express' +import express from 'express' import { logger } from '@server/helpers/logger' import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth' 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 @@ -import * as express from 'express' +import express from 'express' import { createClient, RedisClient } from 'redis' import { logger } from '../helpers/logger' 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 @@ +import Bluebird from 'bluebird' import { logger } from '../../helpers/logger' -import * as Bluebird from 'bluebird' export abstract class AbstractScheduler { 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 @@ -import * as bluebird from 'bluebird' +import { map } from 'bluebird' import { readdir, remove, stat } from 'fs-extra' import { logger, loggerTagsFactory } from '@server/helpers/logger' import { getResumableUploadPath } from '@server/helpers/upload' @@ -32,7 +32,7 @@ export class RemoveDanglingResumableUploadsScheduler extends AbstractScheduler { logger.debug('Reading resumable video upload folder %s with %d files', path, metafiles.length, lTags()) try { - await bluebird.map(metafiles, metafile => { + await map(metafiles, metafile => { return this.deleteIfOlderThan(metafile, this.lastExecutionTimeMs) }, { concurrency: 5 }) } 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 @@ -import * as express from 'express' +import express from 'express' import { CONFIG } from '@server/initializers/config' import { AccountBlocklistModel } from '@server/models/account/account-blocklist' 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 @@ -import { UserModel } from '../models/user/user' -import * as ipaddr from 'ipaddr.js' +import { IPv4, IPv6, parse, subnetMatch } from 'ipaddr.js' import { CONFIG } from '../initializers/config' +import { UserModel } from '../models/user/user' const isCidr = require('is-cidr') @@ -22,7 +22,7 @@ async function isSignupAllowed (): Promise<{ allowed: boolean, errorMessage?: st function isSignupAllowedForCurrentIP (ip: string) { if (!ip) return false - const addr = ipaddr.parse(ip) + const addr = parse(ip) const excludeList = [ 'blacklist' ] let matched = '' @@ -32,23 +32,23 @@ function isSignupAllowedForCurrentIP (ip: string) { } if (addr.kind() === 'ipv4') { - const addrV4 = ipaddr.IPv4.parse(ip) + const addrV4 = IPv4.parse(ip) const rangeList = { whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v4(cidr)) - .map(cidr => ipaddr.IPv4.parseCIDR(cidr)), + .map(cidr => IPv4.parseCIDR(cidr)), blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v4(cidr)) - .map(cidr => ipaddr.IPv4.parseCIDR(cidr)) + .map(cidr => IPv4.parseCIDR(cidr)) } - matched = ipaddr.subnetMatch(addrV4, rangeList, 'unknown') + matched = subnetMatch(addrV4, rangeList, 'unknown') } else if (addr.kind() === 'ipv6') { - const addrV6 = ipaddr.IPv6.parse(ip) + const addrV6 = IPv6.parse(ip) const rangeList = { whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v6(cidr)) - .map(cidr => ipaddr.IPv6.parseCIDR(cidr)), + .map(cidr => IPv6.parseCIDR(cidr)), blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v6(cidr)) - .map(cidr => ipaddr.IPv6.parseCIDR(cidr)) + .map(cidr => IPv6.parseCIDR(cidr)) } - matched = ipaddr.subnetMatch(addrV6, rangeList, 'unknown') + matched = subnetMatch(addrV6, rangeList, 'unknown') } 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 @@ +import { mapSeries } from 'bluebird' import { CONFIG } from '@server/initializers/config' -import { UserModel } from '@server/models/user/user' import { ActorFollowModel } from '@server/models/actor/actor-follow' import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' +import { UserModel } from '@server/models/user/user' import { VideoModel } from '@server/models/video/video' import { VideoChannelModel } from '@server/models/video/video-channel' import { VideoCommentModel } from '@server/models/video/video-comment' import { VideoFileModel } from '@server/models/video/video-file' import { VideoPlaylistModel } from '@server/models/video/video-playlist' import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models' -import * as Bluebird from 'bluebird' class StatsManager { @@ -107,7 +107,7 @@ class StatsManager { strategies.push({ strategy: 'manual', size: null }) - return Bluebird.mapSeries(strategies, r => { + return mapSeries(strategies, r => { return VideoRedundancyModel.getStats(r.strategy) .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size })) }) -- cgit v1.2.3