aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/activitypub/client.ts4
-rw-r--r--server/controllers/activitypub/inbox.ts2
-rw-r--r--server/controllers/activitypub/index.ts2
-rw-r--r--server/controllers/activitypub/outbox.ts2
-rw-r--r--server/controllers/activitypub/utils.ts2
-rw-r--r--server/controllers/api/abuse.ts2
-rw-r--r--server/controllers/api/accounts.ts2
-rw-r--r--server/controllers/api/bulk.ts2
-rw-r--r--server/controllers/api/config.ts2
-rw-r--r--server/controllers/api/custom-page.ts2
-rw-r--r--server/controllers/api/index.ts6
-rw-r--r--server/controllers/api/jobs.ts2
-rw-r--r--server/controllers/api/oauth-clients.ts2
-rw-r--r--server/controllers/api/overviews.ts4
-rw-r--r--server/controllers/api/plugins.ts2
-rw-r--r--server/controllers/api/search/index.ts2
-rw-r--r--server/controllers/api/search/search-video-channels.ts2
-rw-r--r--server/controllers/api/search/search-video-playlists.ts2
-rw-r--r--server/controllers/api/search/search-videos.ts2
-rw-r--r--server/controllers/api/server/contact.ts2
-rw-r--r--server/controllers/api/server/debug.ts2
-rw-r--r--server/controllers/api/server/follows.ts2
-rw-r--r--server/controllers/api/server/index.ts2
-rw-r--r--server/controllers/api/server/logs.ts2
-rw-r--r--server/controllers/api/server/redundancy.ts2
-rw-r--r--server/controllers/api/server/server-blocklist.ts2
-rw-r--r--server/controllers/api/server/stats.ts2
-rw-r--r--server/controllers/api/users/index.ts4
-rw-r--r--server/controllers/api/users/me.ts2
-rw-r--r--server/controllers/api/users/my-abuses.ts2
-rw-r--r--server/controllers/api/users/my-blocklist.ts2
-rw-r--r--server/controllers/api/users/my-history.ts2
-rw-r--r--server/controllers/api/users/my-notifications.ts2
-rw-r--r--server/controllers/api/users/my-subscriptions.ts2
-rw-r--r--server/controllers/api/users/my-video-playlists.ts2
-rw-r--r--server/controllers/api/users/token.ts4
-rw-r--r--server/controllers/api/video-channel.ts2
-rw-r--r--server/controllers/api/video-playlist.ts2
-rw-r--r--server/controllers/api/videos/blacklist.ts2
-rw-r--r--server/controllers/api/videos/captions.ts2
-rw-r--r--server/controllers/api/videos/comment.ts2
-rw-r--r--server/controllers/api/videos/import.ts10
-rw-r--r--server/controllers/api/videos/index.ts2
-rw-r--r--server/controllers/api/videos/live.ts2
-rw-r--r--server/controllers/api/videos/ownership.ts2
-rw-r--r--server/controllers/api/videos/rate.ts2
-rw-r--r--server/controllers/api/videos/update.ts2
-rw-r--r--server/controllers/api/videos/upload.ts2
-rw-r--r--server/controllers/api/videos/watching.ts2
-rw-r--r--server/controllers/bots.ts2
-rw-r--r--server/controllers/client.ts2
-rw-r--r--server/controllers/download.ts4
-rw-r--r--server/controllers/feeds.ts4
-rw-r--r--server/controllers/lazy-static.ts4
-rw-r--r--server/controllers/live.ts4
-rw-r--r--server/controllers/plugins.ts2
-rw-r--r--server/controllers/services.ts2
-rw-r--r--server/controllers/static.ts4
-rw-r--r--server/controllers/tracker.ts12
-rw-r--r--server/controllers/webfinger.ts4
-rw-r--r--server/helpers/activitypub.ts2
-rw-r--r--server/helpers/audit-logger.ts30
-rw-r--r--server/helpers/captions-utils.ts4
-rw-r--r--server/helpers/core-utils.ts6
-rw-r--r--server/helpers/custom-jsonld-signature.ts5
-rw-r--r--server/helpers/custom-validators/videos.ts2
-rw-r--r--server/helpers/database-utils.ts4
-rw-r--r--server/helpers/express-utils.ts6
-rw-r--r--server/helpers/ffmpeg-utils.ts38
-rw-r--r--server/helpers/ffprobe-utils.ts28
-rw-r--r--server/helpers/image-utils.ts6
-rw-r--r--server/helpers/logger.ts32
-rw-r--r--server/helpers/peertube-crypto.ts20
-rw-r--r--server/helpers/uuid.ts4
-rw-r--r--server/helpers/webtorrent.ts20
-rw-r--r--server/initializers/checker-after-init.ts10
-rw-r--r--server/initializers/checker-before-init.ts5
-rw-r--r--server/initializers/config.ts2
-rw-r--r--server/initializers/installer.ts8
-rw-r--r--server/initializers/migrator.ts10
-rw-r--r--server/lib/activitypub/actors/webfinger.ts2
-rw-r--r--server/lib/activitypub/crawl.ts6
-rw-r--r--server/lib/activitypub/playlists/create-update.ts6
-rw-r--r--server/lib/activitypub/share.ts4
-rw-r--r--server/lib/activitypub/video-comments.ts4
-rw-r--r--server/lib/activitypub/video-rates.ts4
-rw-r--r--server/lib/activitypub/videos/shared/object-to-model-attributes.ts2
-rw-r--r--server/lib/auth/oauth-model.ts2
-rw-r--r--server/lib/auth/oauth.ts2
-rw-r--r--server/lib/auth/tokens-cache.ts2
-rw-r--r--server/lib/client-html.ts2
-rw-r--r--server/lib/files-cache/abstract-video-static-file-cache.ts2
-rw-r--r--server/lib/job-queue/handlers/activitypub-cleaner.ts12
-rw-r--r--server/lib/job-queue/handlers/activitypub-follow.ts4
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-broadcast.ts8
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-fetcher.ts4
-rw-r--r--server/lib/job-queue/handlers/activitypub-http-unicast.ts4
-rw-r--r--server/lib/job-queue/handlers/activitypub-refresher.ts4
-rw-r--r--server/lib/job-queue/handlers/actor-keys.ts4
-rw-r--r--server/lib/job-queue/handlers/email.ts6
-rw-r--r--server/lib/job-queue/handlers/move-to-object-storage.ts4
-rw-r--r--server/lib/job-queue/handlers/video-file-import.ts4
-rw-r--r--server/lib/job-queue/handlers/video-import.ts8
-rw-r--r--server/lib/job-queue/handlers/video-live-ending.ts4
-rw-r--r--server/lib/job-queue/handlers/video-redundancy.ts6
-rw-r--r--server/lib/job-queue/handlers/video-transcoding.ts14
-rw-r--r--server/lib/job-queue/job-queue.ts14
-rw-r--r--server/lib/live/shared/muxing-session.ts14
-rw-r--r--server/lib/local-actor.ts2
-rw-r--r--server/lib/peertube-socket.ts14
-rw-r--r--server/lib/plugins/hooks.ts2
-rw-r--r--server/lib/plugins/plugin-helpers-builder.ts2
-rw-r--r--server/lib/plugins/plugin-manager.ts2
-rw-r--r--server/lib/plugins/register-helpers.ts2
-rw-r--r--server/lib/redis.ts2
-rw-r--r--server/lib/schedulers/abstract-scheduler.ts2
-rw-r--r--server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts4
-rw-r--r--server/lib/search.ts2
-rw-r--r--server/lib/signup.ts22
-rw-r--r--server/lib/stat-manager.ts6
-rw-r--r--server/middlewares/auth.ts2
-rw-r--r--server/middlewares/cache/shared/api-cache.ts2
-rw-r--r--server/middlewares/csp.ts6
-rw-r--r--server/middlewares/doc.ts2
-rw-r--r--server/middlewares/error.ts2
-rw-r--r--server/middlewares/pagination.ts2
-rw-r--r--server/middlewares/servers.ts2
-rw-r--r--server/middlewares/sort.ts2
-rw-r--r--server/middlewares/user-right.ts2
-rw-r--r--server/middlewares/validators/abuse.ts2
-rw-r--r--server/middlewares/validators/account.ts2
-rw-r--r--server/middlewares/validators/activitypub/activity.ts2
-rw-r--r--server/middlewares/validators/activitypub/pagination.ts2
-rw-r--r--server/middlewares/validators/activitypub/signature.ts2
-rw-r--r--server/middlewares/validators/actor-image.ts2
-rw-r--r--server/middlewares/validators/blocklist.ts2
-rw-r--r--server/middlewares/validators/bulk.ts2
-rw-r--r--server/middlewares/validators/config.ts2
-rw-r--r--server/middlewares/validators/feeds.ts2
-rw-r--r--server/middlewares/validators/follows.ts2
-rw-r--r--server/middlewares/validators/jobs.ts2
-rw-r--r--server/middlewares/validators/logs.ts2
-rw-r--r--server/middlewares/validators/oembed.ts2
-rw-r--r--server/middlewares/validators/pagination.ts2
-rw-r--r--server/middlewares/validators/plugins.ts2
-rw-r--r--server/middlewares/validators/redundancy.ts2
-rw-r--r--server/middlewares/validators/search.ts2
-rw-r--r--server/middlewares/validators/server.ts2
-rw-r--r--server/middlewares/validators/shared/utils.ts2
-rw-r--r--server/middlewares/validators/shared/video-channels.ts2
-rw-r--r--server/middlewares/validators/shared/video-comments.ts2
-rw-r--r--server/middlewares/validators/shared/video-imports.ts2
-rw-r--r--server/middlewares/validators/shared/video-ownerships.ts2
-rw-r--r--server/middlewares/validators/shared/video-playlists.ts2
-rw-r--r--server/middlewares/validators/themes.ts2
-rw-r--r--server/middlewares/validators/user-history.ts2
-rw-r--r--server/middlewares/validators/user-notifications.ts2
-rw-r--r--server/middlewares/validators/user-subscriptions.ts2
-rw-r--r--server/middlewares/validators/users.ts2
-rw-r--r--server/middlewares/validators/videos/video-blacklist.ts2
-rw-r--r--server/middlewares/validators/videos/video-captions.ts2
-rw-r--r--server/middlewares/validators/videos/video-channels.ts2
-rw-r--r--server/middlewares/validators/videos/video-comments.ts2
-rw-r--r--server/middlewares/validators/videos/video-imports.ts2
-rw-r--r--server/middlewares/validators/videos/video-live.ts2
-rw-r--r--server/middlewares/validators/videos/video-ownership-changes.ts2
-rw-r--r--server/middlewares/validators/videos/video-playlists.ts2
-rw-r--r--server/middlewares/validators/videos/video-rates.ts2
-rw-r--r--server/middlewares/validators/videos/video-shares.ts2
-rw-r--r--server/middlewares/validators/videos/video-watch.ts2
-rw-r--r--server/middlewares/validators/videos/videos.ts2
-rw-r--r--server/middlewares/validators/webfinger.ts2
-rw-r--r--server/models/application/application.ts2
-rw-r--r--server/models/model-cache.ts3
-rw-r--r--server/models/video/video-comment.ts2
-rw-r--r--server/models/video/video-file.ts2
-rw-r--r--server/models/video/video-streaming-playlist.ts2
-rw-r--r--server/models/video/video-view.ts12
-rw-r--r--server/models/video/video.ts2
-rw-r--r--server/tests/api/redundancy/redundancy.ts2
-rw-r--r--server/tests/api/server/no-client.ts2
-rw-r--r--server/tests/api/server/tracker.ts4
-rw-r--r--server/tests/api/videos/multiple-servers.ts2
-rw-r--r--server/tests/feeds/feeds.ts6
-rw-r--r--server/tools/peertube-auth.ts5
-rw-r--r--server/tools/peertube-import-videos.ts3
-rw-r--r--server/tools/peertube-plugins.ts2
-rw-r--r--server/tools/peertube-redundancy.ts2
-rw-r--r--server/types/plugins/register-server-auth.model.ts2
189 files changed, 392 insertions, 389 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index bef4bc068..c4e3cec6b 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -1,5 +1,5 @@
1import * as cors from 'cors' 1import cors from 'cors'
2import * as express from 'express' 2import express from 'express'
3import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
4import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models' 4import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models'
5import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' 5import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts
index 30662990a..ece4edff0 100644
--- a/server/controllers/activitypub/inbox.ts
+++ b/server/controllers/activitypub/inbox.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { InboxManager } from '@server/lib/activitypub/inbox-manager' 2import { InboxManager } from '@server/lib/activitypub/inbox-manager'
3import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' 3import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared'
4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
diff --git a/server/controllers/activitypub/index.ts b/server/controllers/activitypub/index.ts
index 7e81902af..8c681820a 100644
--- a/server/controllers/activitypub/index.ts
+++ b/server/controllers/activitypub/index.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { activityPubClientRouter } from './client' 2import { activityPubClientRouter } from './client'
3import { inboxRouter } from './inbox' 3import { inboxRouter } from './inbox'
4import { outboxRouter } from './outbox' 4import { outboxRouter } from './outbox'
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts
index 22328da7f..bdf9d138b 100644
--- a/server/controllers/activitypub/outbox.ts
+++ b/server/controllers/activitypub/outbox.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { Activity } from '../../../shared/models/activitypub/activity' 2import { Activity } from '../../../shared/models/activitypub/activity'
3import { VideoPrivacy } from '../../../shared/models/videos' 3import { VideoPrivacy } from '../../../shared/models/videos'
4import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' 4import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
diff --git a/server/controllers/activitypub/utils.ts b/server/controllers/activitypub/utils.ts
index 19bdd58eb..f851ef652 100644
--- a/server/controllers/activitypub/utils.ts
+++ b/server/controllers/activitypub/utils.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2 2
3function activityPubResponse (data: any, res: express.Response) { 3function activityPubResponse (data: any, res: express.Response) {
4 return res.type('application/activity+json; charset=utf-8') 4 return res.type('application/activity+json; charset=utf-8')
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts
index e851365e9..72c418e74 100644
--- a/server/controllers/api/abuse.ts
+++ b/server/controllers/api/abuse.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { logger } from '@server/helpers/logger' 2import { logger } from '@server/helpers/logger'
3import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation' 3import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation'
4import { Notifier } from '@server/lib/notifier' 4import { Notifier } from '@server/lib/notifier'
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
index 55e2aaf62..75679b0f4 100644
--- a/server/controllers/api/accounts.ts
+++ b/server/controllers/api/accounts.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { pickCommonVideoQuery } from '@server/helpers/query' 2import { pickCommonVideoQuery } from '@server/helpers/query'
3import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
4import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 4import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
diff --git a/server/controllers/api/bulk.ts b/server/controllers/api/bulk.ts
index 62121ece5..d27c3c73e 100644
--- a/server/controllers/api/bulk.ts
+++ b/server/controllers/api/bulk.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { removeComment } from '@server/lib/video-comment' 2import { removeComment } from '@server/lib/video-comment'
3import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk' 3import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk'
4import { VideoCommentModel } from '@server/models/video/video-comment' 4import { VideoCommentModel } from '@server/models/video/video-comment'
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index ee733a38c..d542f62aa 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { remove, writeJSON } from 'fs-extra' 2import { remove, writeJSON } from 'fs-extra'
3import { snakeCase } from 'lodash' 3import { snakeCase } from 'lodash'
4import validator from 'validator' 4import validator from 'validator'
diff --git a/server/controllers/api/custom-page.ts b/server/controllers/api/custom-page.ts
index 68d8c2ea4..d1c672f3f 100644
--- a/server/controllers/api/custom-page.ts
+++ b/server/controllers/api/custom-page.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { ServerConfigManager } from '@server/lib/server-config-manager' 2import { ServerConfigManager } from '@server/lib/server-config-manager'
3import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' 3import { ActorCustomPageModel } from '@server/models/account/actor-custom-page'
4import { HttpStatusCode, UserRight } from '@shared/models' 4import { HttpStatusCode, UserRight } from '@shared/models'
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index 93b14dadb..9949b378a 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -1,6 +1,6 @@
1import * as cors from 'cors' 1import cors from 'cors'
2import * as express from 'express' 2import express from 'express'
3import * as RateLimit from 'express-rate-limit' 3import RateLimit from 'express-rate-limit'
4import { HttpStatusCode } from '../../../shared/models' 4import { HttpStatusCode } from '../../../shared/models'
5import { badRequest } from '../../helpers/express-utils' 5import { badRequest } from '../../helpers/express-utils'
6import { CONFIG } from '../../initializers/config' 6import { CONFIG } from '../../initializers/config'
diff --git a/server/controllers/api/jobs.ts b/server/controllers/api/jobs.ts
index 9e333322b..7001674bb 100644
--- a/server/controllers/api/jobs.ts
+++ b/server/controllers/api/jobs.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { ResultList } from '../../../shared' 2import { ResultList } from '../../../shared'
3import { Job, JobState, JobType } from '../../../shared/models' 3import { Job, JobState, JobType } from '../../../shared/models'
4import { UserRight } from '../../../shared/models/users' 4import { UserRight } from '../../../shared/models/users'
diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts
index f95f06864..4990fb0df 100644
--- a/server/controllers/api/oauth-clients.ts
+++ b/server/controllers/api/oauth-clients.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { OAuthClientLocal } from '../../../shared' 2import { OAuthClientLocal } from '../../../shared'
3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts
index 2dfac15ef..5b16232e2 100644
--- a/server/controllers/api/overviews.ts
+++ b/server/controllers/api/overviews.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import express from 'express'
2import * as memoizee from 'memoizee' 2import memoizee from 'memoizee'
3import { logger } from '@server/helpers/logger' 3import { logger } from '@server/helpers/logger'
4import { Hooks } from '@server/lib/plugins/hooks' 4import { Hooks } from '@server/lib/plugins/hooks'
5import { VideoModel } from '@server/models/video/video' 5import { VideoModel } from '@server/models/video/video'
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts
index 3a9ef34e8..2de7fe41f 100644
--- a/server/controllers/api/plugins.ts
+++ b/server/controllers/api/plugins.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { logger } from '@server/helpers/logger' 2import { logger } from '@server/helpers/logger'
3import { getFormattedObjects } from '@server/helpers/utils' 3import { getFormattedObjects } from '@server/helpers/utils'
4import { listAvailablePluginsFromIndex } from '@server/lib/plugins/plugin-index' 4import { listAvailablePluginsFromIndex } from '@server/lib/plugins/plugin-index'
diff --git a/server/controllers/api/search/index.ts b/server/controllers/api/search/index.ts
index 67adbb307..39efc0b10 100644
--- a/server/controllers/api/search/index.ts
+++ b/server/controllers/api/search/index.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { searchChannelsRouter } from './search-video-channels' 2import { searchChannelsRouter } from './search-video-channels'
3import { searchPlaylistsRouter } from './search-video-playlists' 3import { searchPlaylistsRouter } from './search-video-playlists'
4import { searchVideosRouter } from './search-videos' 4import { searchVideosRouter } from './search-videos'
diff --git a/server/controllers/api/search/search-video-channels.ts b/server/controllers/api/search/search-video-channels.ts
index eef222506..25173ac20 100644
--- a/server/controllers/api/search/search-video-channels.ts
+++ b/server/controllers/api/search/search-video-channels.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { sanitizeUrl } from '@server/helpers/core-utils' 2import { sanitizeUrl } from '@server/helpers/core-utils'
3import { pickSearchChannelQuery } from '@server/helpers/query' 3import { pickSearchChannelQuery } from '@server/helpers/query'
4import { doJSONRequest } from '@server/helpers/requests' 4import { doJSONRequest } from '@server/helpers/requests'
diff --git a/server/controllers/api/search/search-video-playlists.ts b/server/controllers/api/search/search-video-playlists.ts
index 0a56f19b7..b28f11c79 100644
--- a/server/controllers/api/search/search-video-playlists.ts
+++ b/server/controllers/api/search/search-video-playlists.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { sanitizeUrl } from '@server/helpers/core-utils' 2import { sanitizeUrl } from '@server/helpers/core-utils'
3import { isUserAbleToSearchRemoteURI } from '@server/helpers/express-utils' 3import { isUserAbleToSearchRemoteURI } from '@server/helpers/express-utils'
4import { logger } from '@server/helpers/logger' 4import { logger } from '@server/helpers/logger'
diff --git a/server/controllers/api/search/search-videos.ts b/server/controllers/api/search/search-videos.ts
index 4a6ce0de4..eb7ce0841 100644
--- a/server/controllers/api/search/search-videos.ts
+++ b/server/controllers/api/search/search-videos.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { sanitizeUrl } from '@server/helpers/core-utils' 2import { sanitizeUrl } from '@server/helpers/core-utils'
3import { pickSearchVideoQuery } from '@server/helpers/query' 3import { pickSearchVideoQuery } from '@server/helpers/query'
4import { doJSONRequest } from '@server/helpers/requests' 4import { doJSONRequest } from '@server/helpers/requests'
diff --git a/server/controllers/api/server/contact.ts b/server/controllers/api/server/contact.ts
index b315e99cf..09ff50f69 100644
--- a/server/controllers/api/server/contact.ts
+++ b/server/controllers/api/server/contact.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 2import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
3import { ContactForm } from '../../../../shared/models/server' 3import { ContactForm } from '../../../../shared/models/server'
4import { Emailer } from '../../../lib/emailer' 4import { Emailer } from '../../../lib/emailer'
diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts
index 0601b89ce..093e6a03c 100644
--- a/server/controllers/api/server/debug.ts
+++ b/server/controllers/api/server/debug.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { InboxManager } from '@server/lib/activitypub/inbox-manager' 2import { InboxManager } from '@server/lib/activitypub/inbox-manager'
3import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' 3import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
4import { Debug, SendDebugCommand } from '@shared/models' 4import { Debug, SendDebugCommand } from '@shared/models'
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index cbe6b7e4f..2e0fd25eb 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { getServerActor } from '@server/models/application/application' 2import { getServerActor } from '@server/models/application/application'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { UserRight } from '../../../../shared/models/users' 4import { UserRight } from '../../../../shared/models/users'
diff --git a/server/controllers/api/server/index.ts b/server/controllers/api/server/index.ts
index 32fefefc0..b20718d09 100644
--- a/server/controllers/api/server/index.ts
+++ b/server/controllers/api/server/index.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { contactRouter } from './contact' 2import { contactRouter } from './contact'
3import { debugRouter } from './debug' 3import { debugRouter } from './debug'
4import { serverFollowsRouter } from './follows' 4import { serverFollowsRouter } from './follows'
diff --git a/server/controllers/api/server/logs.ts b/server/controllers/api/server/logs.ts
index 39eceb654..dfd5491aa 100644
--- a/server/controllers/api/server/logs.ts
+++ b/server/controllers/api/server/logs.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { readdir, readFile } from 'fs-extra' 2import { readdir, readFile } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import { logger, mtimeSortFilesDesc } from '@server/helpers/logger' 4import { logger, mtimeSortFilesDesc } from '@server/helpers/logger'
diff --git a/server/controllers/api/server/redundancy.ts b/server/controllers/api/server/redundancy.ts
index e36c8d2db..9f43d3e4e 100644
--- a/server/controllers/api/server/redundancy.ts
+++ b/server/controllers/api/server/redundancy.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { JobQueue } from '@server/lib/job-queue' 2import { JobQueue } from '@server/lib/job-queue'
3import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' 3import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
4import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 4import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
diff --git a/server/controllers/api/server/server-blocklist.ts b/server/controllers/api/server/server-blocklist.ts
index b3ee50d85..740f95da3 100644
--- a/server/controllers/api/server/server-blocklist.ts
+++ b/server/controllers/api/server/server-blocklist.ts
@@ -1,5 +1,5 @@
1import 'multer' 1import 'multer'
2import * as express from 'express' 2import express from 'express'
3import { logger } from '@server/helpers/logger' 3import { logger } from '@server/helpers/logger'
4import { getServerActor } from '@server/models/application/application' 4import { getServerActor } from '@server/models/application/application'
5import { UserNotificationModel } from '@server/models/user/user-notification' 5import { UserNotificationModel } from '@server/models/user/user-notification'
diff --git a/server/controllers/api/server/stats.ts b/server/controllers/api/server/stats.ts
index 397702548..d661144ca 100644
--- a/server/controllers/api/server/stats.ts
+++ b/server/controllers/api/server/stats.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { StatsManager } from '@server/lib/stat-manager' 2import { StatsManager } from '@server/lib/stat-manager'
3import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' 3import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants'
4import { asyncMiddleware } from '../../../middlewares' 4import { asyncMiddleware } from '../../../middlewares'
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index be800e8b5..bc47e5fec 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import express from 'express'
2import * as RateLimit from 'express-rate-limit' 2import RateLimit from 'express-rate-limit'
3import { tokensRouter } from '@server/controllers/api/users/token' 3import { tokensRouter } from '@server/controllers/api/users/token'
4import { Hooks } from '@server/lib/plugins/hooks' 4import { Hooks } from '@server/lib/plugins/hooks'
5import { OAuthTokenModel } from '@server/models/oauth/oauth-token' 5import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index a98d79218..83b774d3c 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -1,5 +1,5 @@
1import 'multer' 1import 'multer'
2import * as express from 'express' 2import express from 'express'
3import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' 3import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger'
4import { Hooks } from '@server/lib/plugins/hooks' 4import { Hooks } from '@server/lib/plugins/hooks'
5import { AttributesOnly } from '@shared/core-utils' 5import { AttributesOnly } from '@shared/core-utils'
diff --git a/server/controllers/api/users/my-abuses.ts b/server/controllers/api/users/my-abuses.ts
index fcd0ce3fc..103c3d332 100644
--- a/server/controllers/api/users/my-abuses.ts
+++ b/server/controllers/api/users/my-abuses.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { AbuseModel } from '@server/models/abuse/abuse' 2import { AbuseModel } from '@server/models/abuse/abuse'
3import { 3import {
4 abuseListForUserValidator, 4 abuseListForUserValidator,
diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts
index 24fff83e3..0b56645cf 100644
--- a/server/controllers/api/users/my-blocklist.ts
+++ b/server/controllers/api/users/my-blocklist.ts
@@ -1,5 +1,5 @@
1import 'multer' 1import 'multer'
2import * as express from 'express' 2import express from 'express'
3import { logger } from '@server/helpers/logger' 3import { logger } from '@server/helpers/logger'
4import { UserNotificationModel } from '@server/models/user/user-notification' 4import { UserNotificationModel } from '@server/models/user/user-notification'
5import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 5import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts
index a6e723103..2fcb25acf 100644
--- a/server/controllers/api/users/my-history.ts
+++ b/server/controllers/api/users/my-history.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 2import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
3import { getFormattedObjects } from '../../../helpers/utils' 3import { getFormattedObjects } from '../../../helpers/utils'
4import { sequelizeTypescript } from '../../../initializers/database' 4import { sequelizeTypescript } from '../../../initializers/database'
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts
index 3beee07c0..d107a306e 100644
--- a/server/controllers/api/users/my-notifications.ts
+++ b/server/controllers/api/users/my-notifications.ts
@@ -1,5 +1,5 @@
1import 'multer' 1import 'multer'
2import * as express from 'express' 2import express from 'express'
3import { UserNotificationModel } from '@server/models/user/user-notification' 3import { UserNotificationModel } from '@server/models/user/user-notification'
4import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 4import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
5import { UserNotificationSetting } from '../../../../shared/models/users' 5import { UserNotificationSetting } from '../../../../shared/models/users'
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts
index 26a715704..e3c0cf089 100644
--- a/server/controllers/api/users/my-subscriptions.ts
+++ b/server/controllers/api/users/my-subscriptions.ts
@@ -1,5 +1,5 @@
1import 'multer' 1import 'multer'
2import * as express from 'express' 2import express from 'express'
3import { pickCommonVideoQuery } from '@server/helpers/query' 3import { pickCommonVideoQuery } from '@server/helpers/query'
4import { sendUndoFollow } from '@server/lib/activitypub/send' 4import { sendUndoFollow } from '@server/lib/activitypub/send'
5import { VideoChannelModel } from '@server/models/video/video-channel' 5import { VideoChannelModel } from '@server/models/video/video-channel'
diff --git a/server/controllers/api/users/my-video-playlists.ts b/server/controllers/api/users/my-video-playlists.ts
index 76e741ba5..f55ea2ec4 100644
--- a/server/controllers/api/users/my-video-playlists.ts
+++ b/server/controllers/api/users/my-video-playlists.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' 2import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model'
3import { asyncMiddleware, authenticate } from '../../../middlewares' 3import { asyncMiddleware, authenticate } from '../../../middlewares'
4import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists' 4import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists'
diff --git a/server/controllers/api/users/token.ts b/server/controllers/api/users/token.ts
index b405ddbf4..d5dbe921c 100644
--- a/server/controllers/api/users/token.ts
+++ b/server/controllers/api/users/token.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import express from 'express'
2import * as RateLimit from 'express-rate-limit' 2import RateLimit from 'express-rate-limit'
3import { logger } from '@server/helpers/logger' 3import { logger } from '@server/helpers/logger'
4import { buildUUID } from '@server/helpers/uuid' 4import { buildUUID } from '@server/helpers/uuid'
5import { CONFIG } from '@server/initializers/config' 5import { CONFIG } from '@server/initializers/config'
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index a0c6601d9..b79dc5933 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { pickCommonVideoQuery } from '@server/helpers/query' 2import { pickCommonVideoQuery } from '@server/helpers/query'
3import { Hooks } from '@server/lib/plugins/hooks' 3import { Hooks } from '@server/lib/plugins/hooks'
4import { getServerActor } from '@server/models/application/application' 4import { getServerActor } from '@server/models/application/application'
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index 4971d0a77..2f81cf43c 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { join } from 'path' 2import { join } from 'path'
3import { uuidToShort } from '@server/helpers/uuid' 3import { uuidToShort } from '@server/helpers/uuid'
4import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists' 4import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists'
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts
index 6bc768471..de65c74f1 100644
--- a/server/controllers/api/videos/blacklist.ts
+++ b/server/controllers/api/videos/blacklist.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist' 2import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist'
3import { UserRight, VideoBlacklistCreate } from '../../../../shared' 3import { UserRight, VideoBlacklistCreate } from '../../../../shared'
4import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 4import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts
index 4008de60f..2d2213327 100644
--- a/server/controllers/api/videos/captions.ts
+++ b/server/controllers/api/videos/captions.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { MVideoCaption } from '@server/types/models' 2import { MVideoCaption } from '@server/types/models'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' 4import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts
index cb696f652..23bba9089 100644
--- a/server/controllers/api/videos/comment.ts
+++ b/server/controllers/api/videos/comment.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' 2import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' 4import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model'
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index de9a5308a..39fc57788 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import express from 'express'
2import { move, readFile } from 'fs-extra' 2import { move, readFile } from 'fs-extra'
3import * as magnetUtil from 'magnet-uri' 3import { decode } from 'magnet-uri'
4import * as parseTorrent from 'parse-torrent' 4import parseTorrent, { Instance } from 'parse-torrent'
5import { join } from 'path' 5import { join } from 'path'
6import { ServerConfigManager } from '@server/lib/server-config-manager' 6import { ServerConfigManager } from '@server/lib/server-config-manager'
7import { setVideoTags } from '@server/lib/video' 7import { setVideoTags } from '@server/lib/video'
@@ -329,7 +329,7 @@ async function processTorrentOrAbortRequest (req: express.Request, res: express.
329 torrentfile.path = newTorrentPath 329 torrentfile.path = newTorrentPath
330 330
331 const buf = await readFile(torrentfile.path) 331 const buf = await readFile(torrentfile.path)
332 const parsedTorrent = parseTorrent(buf) as parseTorrent.Instance 332 const parsedTorrent = parseTorrent(buf) as Instance
333 333
334 if (parsedTorrent.files.length !== 1) { 334 if (parsedTorrent.files.length !== 1) {
335 cleanUpReqFiles(req) 335 cleanUpReqFiles(req)
@@ -349,7 +349,7 @@ async function processTorrentOrAbortRequest (req: express.Request, res: express.
349 349
350function processMagnetURI (body: VideoImportCreate) { 350function processMagnetURI (body: VideoImportCreate) {
351 const magnetUri = body.magnetUri 351 const magnetUri = body.magnetUri
352 const parsed = magnetUtil.decode(magnetUri) 352 const parsed = decode(magnetUri)
353 353
354 return { 354 return {
355 name: extractNameFromArray(parsed.name), 355 name: extractNameFromArray(parsed.name),
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 10833d48b..c0c77f3f7 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import toInt from 'validator/lib/toInt' 2import toInt from 'validator/lib/toInt'
3import { pickCommonVideoQuery } from '@server/helpers/query' 3import { pickCommonVideoQuery } from '@server/helpers/query'
4import { doJSONRequest } from '@server/helpers/requests' 4import { doJSONRequest } from '@server/helpers/requests'
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts
index 151ff354b..efafe64e9 100644
--- a/server/controllers/api/videos/live.ts
+++ b/server/controllers/api/videos/live.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { createReqFiles } from '@server/helpers/express-utils' 2import { createReqFiles } from '@server/helpers/express-utils'
3import { buildUUID, uuidToShort } from '@server/helpers/uuid' 3import { buildUUID, uuidToShort } from '@server/helpers/uuid'
4import { CONFIG } from '@server/initializers/config' 4import { CONFIG } from '@server/initializers/config'
diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts
index f48acbc68..043861ac3 100644
--- a/server/controllers/api/videos/ownership.ts
+++ b/server/controllers/api/videos/ownership.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { MVideoFullLight } from '@server/types/models' 2import { MVideoFullLight } from '@server/types/models'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos' 4import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos'
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index 96f6cd886..c9cc16644 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { UserVideoRateUpdate } from '../../../../shared' 2import { UserVideoRateUpdate } from '../../../../shared'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts
index 49639060b..a98a3e67c 100644
--- a/server/controllers/api/videos/update.ts
+++ b/server/controllers/api/videos/update.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { Transaction } from 'sequelize/types' 2import { Transaction } from 'sequelize/types'
3import { changeVideoChannelShare } from '@server/lib/activitypub/share' 3import { changeVideoChannelShare } from '@server/lib/activitypub/share'
4import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' 4import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index 5c740c041..7ffda749d 100644
--- a/server/controllers/api/videos/upload.ts
+++ b/server/controllers/api/videos/upload.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { move } from 'fs-extra' 2import { move } from 'fs-extra'
3import { basename } from 'path' 3import { basename } from 'path'
4import { getLowercaseExtension } from '@server/helpers/core-utils' 4import { getLowercaseExtension } from '@server/helpers/core-utils'
diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts
index 05c75e543..e8c28b613 100644
--- a/server/controllers/api/videos/watching.ts
+++ b/server/controllers/api/videos/watching.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { UserWatchingVideo } from '../../../../shared' 2import { UserWatchingVideo } from '../../../../shared'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { 4import {
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts
index de0411608..63db345bf 100644
--- a/server/controllers/bots.ts
+++ b/server/controllers/bots.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { truncate } from 'lodash' 2import { truncate } from 'lodash'
3import { SitemapStream, streamToPromise } from 'sitemap' 3import { SitemapStream, streamToPromise } from 'sitemap'
4import { buildNSFWFilter } from '../helpers/express-utils' 4import { buildNSFWFilter } from '../helpers/express-utils'
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index ba3c54440..d81e35ec3 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { constants, promises as fs } from 'fs' 2import { constants, promises as fs } from 'fs'
3import { readFile } from 'fs-extra' 3import { readFile } from 'fs-extra'
4import { join } from 'path' 4import { join } from 'path'
diff --git a/server/controllers/download.ts b/server/controllers/download.ts
index ffe40d57e..8da710669 100644
--- a/server/controllers/download.ts
+++ b/server/controllers/download.ts
@@ -1,5 +1,5 @@
1import * as cors from 'cors' 1import cors from 'cors'
2import * as express from 'express' 2import express from 'express'
3import { logger } from '@server/helpers/logger' 3import { logger } from '@server/helpers/logger'
4import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' 4import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
5import { Hooks } from '@server/lib/plugins/hooks' 5import { Hooks } from '@server/lib/plugins/hooks'
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts
index 9fa70a7c8..5ac2e43a1 100644
--- a/server/controllers/feeds.ts
+++ b/server/controllers/feeds.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import express from 'express'
2import * as Feed from 'pfeed' 2import Feed from 'pfeed'
3import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils' 3import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils'
4import { VideoFilter } from '../../shared/models/videos/video-query.type' 4import { VideoFilter } from '../../shared/models/videos/video-query.type'
5import { buildNSFWFilter } from '../helpers/express-utils' 5import { buildNSFWFilter } from '../helpers/express-utils'
diff --git a/server/controllers/lazy-static.ts b/server/controllers/lazy-static.ts
index 632e4dcd8..a4076ee56 100644
--- a/server/controllers/lazy-static.ts
+++ b/server/controllers/lazy-static.ts
@@ -1,5 +1,5 @@
1import * as cors from 'cors' 1import cors from 'cors'
2import * as express from 'express' 2import express from 'express'
3import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' 3import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
4import { HttpStatusCode } from '../../shared/models/http/http-error-codes' 4import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
5import { logger } from '../helpers/logger' 5import { logger } from '../helpers/logger'
diff --git a/server/controllers/live.ts b/server/controllers/live.ts
index 95d5c0135..81008f120 100644
--- a/server/controllers/live.ts
+++ b/server/controllers/live.ts
@@ -1,5 +1,5 @@
1import * as cors from 'cors' 1import cors from 'cors'
2import * as express from 'express' 2import express from 'express'
3import { mapToJSON } from '@server/helpers/core-utils' 3import { mapToJSON } from '@server/helpers/core-utils'
4import { LiveSegmentShaStore } from '@server/lib/live' 4import { LiveSegmentShaStore } from '@server/lib/live'
5import { HttpStatusCode } from '@shared/models' 5import { HttpStatusCode } from '@shared/models'
diff --git a/server/controllers/plugins.ts b/server/controllers/plugins.ts
index 11ab3f10a..28fffc9e1 100644
--- a/server/controllers/plugins.ts
+++ b/server/controllers/plugins.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { join } from 'path' 2import { join } from 'path'
3import { logger } from '@server/helpers/logger' 3import { logger } from '@server/helpers/logger'
4import { optionalAuthenticate } from '@server/middlewares/auth' 4import { optionalAuthenticate } from '@server/middlewares/auth'
diff --git a/server/controllers/services.ts b/server/controllers/services.ts
index 8c0af9ff7..8a8a95486 100644
--- a/server/controllers/services.ts
+++ b/server/controllers/services.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER, THUMBNAILS_SIZE } from '../initializers/constants' 2import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER, THUMBNAILS_SIZE } from '../initializers/constants'
3import { asyncMiddleware, oembedValidator } from '../middlewares' 3import { asyncMiddleware, oembedValidator } from '../middlewares'
4import { accountNameWithHostGetValidator } from '../middlewares/validators' 4import { accountNameWithHostGetValidator } from '../middlewares/validators'
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 912d7e36c..1c04e4b11 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -1,5 +1,5 @@
1import * as cors from 'cors' 1import cors from 'cors'
2import * as express from 'express' 2import express from 'express'
3import { join } from 'path' 3import { join } from 'path'
4import { serveIndexHTML } from '@server/lib/client-html' 4import { serveIndexHTML } from '@server/lib/client-html'
5import { ServerConfigManager } from '@server/lib/server-config-manager' 5import { ServerConfigManager } from '@server/lib/server-config-manager'
diff --git a/server/controllers/tracker.ts b/server/controllers/tracker.ts
index 37f8f12c9..da9c68c6c 100644
--- a/server/controllers/tracker.ts
+++ b/server/controllers/tracker.ts
@@ -1,7 +1,7 @@
1import * as bitTorrentTracker from 'bittorrent-tracker' 1import { Server as TrackerServer } from 'bittorrent-tracker'
2import * as express from 'express' 2import express from 'express'
3import * as http from 'http' 3import { createServer } from 'http'
4import * as proxyAddr from 'proxy-addr' 4import proxyAddr from 'proxy-addr'
5import { Server as WebSocketServer } from 'ws' 5import { Server as WebSocketServer } from 'ws'
6import { Redis } from '@server/lib/redis' 6import { Redis } from '@server/lib/redis'
7import { logger } from '../helpers/logger' 7import { logger } from '../helpers/logger'
@@ -10,8 +10,6 @@ import { TRACKER_RATE_LIMITS } from '../initializers/constants'
10import { VideoFileModel } from '../models/video/video-file' 10import { VideoFileModel } from '../models/video/video-file'
11import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' 11import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
12 12
13const TrackerServer = bitTorrentTracker.Server
14
15const trackerRouter = express.Router() 13const trackerRouter = express.Router()
16 14
17let peersIps = {} 15let peersIps = {}
@@ -86,7 +84,7 @@ trackerRouter.get('/tracker/announce', (req, res) => onHttpRequest(req, res, { a
86trackerRouter.get('/tracker/scrape', (req, res) => onHttpRequest(req, res, { action: 'scrape' })) 84trackerRouter.get('/tracker/scrape', (req, res) => onHttpRequest(req, res, { action: 'scrape' }))
87 85
88function createWebsocketTrackerServer (app: express.Application) { 86function createWebsocketTrackerServer (app: express.Application) {
89 const server = http.createServer(app) 87 const server = createServer(app)
90 const wss = new WebSocketServer({ noServer: true }) 88 const wss = new WebSocketServer({ noServer: true })
91 89
92 wss.on('connection', function (ws, req) { 90 wss.on('connection', function (ws, req) {
diff --git a/server/controllers/webfinger.ts b/server/controllers/webfinger.ts
index 885e4498f..29ce01166 100644
--- a/server/controllers/webfinger.ts
+++ b/server/controllers/webfinger.ts
@@ -1,5 +1,5 @@
1import * as cors from 'cors' 1import cors from 'cors'
2import * as express from 'express' 2import express from 'express'
3import { WEBSERVER } from '@server/initializers/constants' 3import { WEBSERVER } from '@server/initializers/constants'
4import { asyncMiddleware } from '../middlewares' 4import { asyncMiddleware } from '../middlewares'
5import { webfingerValidator } from '../middlewares/validators' 5import { webfingerValidator } from '../middlewares/validators'
diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts
index e0754b501..8b56d2d50 100644
--- a/server/helpers/activitypub.ts
+++ b/server/helpers/activitypub.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import Bluebird from 'bluebird'
2import { URL } from 'url' 2import { URL } from 'url'
3import validator from 'validator' 3import validator from 'validator'
4import { ContextType } from '@shared/models/activitypub/context' 4import { ContextType } from '@shared/models/activitypub/context'
diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts
index 884bd187d..5f2e870e3 100644
--- a/server/helpers/audit-logger.ts
+++ b/server/helpers/audit-logger.ts
@@ -1,9 +1,9 @@
1import { diff } from 'deep-object-diff' 1import { diff } from 'deep-object-diff'
2import * as express from 'express' 2import express from 'express'
3import * as flatten from 'flat' 3import flatten from 'flat'
4import { chain } from 'lodash' 4import { chain } from 'lodash'
5import * as path from 'path' 5import { join } from 'path'
6import * as winston from 'winston' 6import { addColors, config, createLogger, format, transports } from 'winston'
7import { AUDIT_LOG_FILENAME } from '@server/initializers/constants' 7import { AUDIT_LOG_FILENAME } from '@server/initializers/constants'
8import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared' 8import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared'
9import { CustomConfig } from '../../shared/models/server/custom-config.model' 9import { CustomConfig } from '../../shared/models/server/custom-config.model'
@@ -21,23 +21,23 @@ enum AUDIT_TYPE {
21 DELETE = 'delete' 21 DELETE = 'delete'
22} 22}
23 23
24const colors = winston.config.npm.colors 24const colors = config.npm.colors
25colors.audit = winston.config.npm.colors.info 25colors.audit = config.npm.colors.info
26 26
27winston.addColors(colors) 27addColors(colors)
28 28
29const auditLogger = winston.createLogger({ 29const auditLogger = createLogger({
30 levels: { audit: 0 }, 30 levels: { audit: 0 },
31 transports: [ 31 transports: [
32 new winston.transports.File({ 32 new transports.File({
33 filename: path.join(CONFIG.STORAGE.LOG_DIR, AUDIT_LOG_FILENAME), 33 filename: join(CONFIG.STORAGE.LOG_DIR, AUDIT_LOG_FILENAME),
34 level: 'audit', 34 level: 'audit',
35 maxsize: 5242880, 35 maxsize: 5242880,
36 maxFiles: 5, 36 maxFiles: 5,
37 format: winston.format.combine( 37 format: format.combine(
38 winston.format.timestamp(), 38 format.timestamp(),
39 labelFormatter(), 39 labelFormatter(),
40 winston.format.splat(), 40 format.splat(),
41 jsonLoggerFormat 41 jsonLoggerFormat
42 ) 42 )
43 }) 43 })
@@ -84,9 +84,9 @@ abstract class EntityAuditView {
84 constructor (private readonly keysToKeep: string[], private readonly prefix: string, private readonly entityInfos: object) { } 84 constructor (private readonly keysToKeep: string[], private readonly prefix: string, private readonly entityInfos: object) { }
85 85
86 toLogKeys (): object { 86 toLogKeys (): object {
87 return chain(flatten(this.entityInfos, { delimiter: '-', safe: true })) 87 return chain(flatten<object, any>(this.entityInfos, { delimiter: '-', safe: true }))
88 .pick(this.keysToKeep) 88 .pick(this.keysToKeep)
89 .mapKeys((value, key) => `${this.prefix}-${key}`) 89 .mapKeys((_value, key) => `${this.prefix}-${key}`)
90 .value() 90 .value()
91 } 91 }
92} 92}
diff --git a/server/helpers/captions-utils.ts b/server/helpers/captions-utils.ts
index ca03f7a49..f6e5b9784 100644
--- a/server/helpers/captions-utils.ts
+++ b/server/helpers/captions-utils.ts
@@ -1,10 +1,10 @@
1import { createReadStream, createWriteStream, move, remove } from 'fs-extra' 1import { createReadStream, createWriteStream, move, remove } from 'fs-extra'
2import { join } from 'path' 2import { join } from 'path'
3import * as srt2vtt from 'srt-to-vtt' 3import srt2vtt from 'srt-to-vtt'
4import { Transform } from 'stream'
4import { MVideoCaption } from '@server/types/models' 5import { MVideoCaption } from '@server/types/models'
5import { CONFIG } from '../initializers/config' 6import { CONFIG } from '../initializers/config'
6import { pipelinePromise } from './core-utils' 7import { pipelinePromise } from './core-utils'
7import { Transform } from 'stream'
8 8
9async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaption) { 9async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaption) {
10 const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR 10 const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index 9abc532d2..7f28cfc8b 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -9,7 +9,7 @@ import { exec, ExecOptions } from 'child_process'
9import { BinaryToTextEncoding, createHash, randomBytes } from 'crypto' 9import { BinaryToTextEncoding, createHash, randomBytes } from 'crypto'
10import { truncate } from 'lodash' 10import { truncate } from 'lodash'
11import { basename, extname, isAbsolute, join, resolve } from 'path' 11import { basename, extname, isAbsolute, join, resolve } from 'path'
12import * as pem from 'pem' 12import { createPrivateKey as createPrivateKey_1, getPublicKey as getPublicKey_1 } from 'pem'
13import { pipeline } from 'stream' 13import { pipeline } from 'stream'
14import { URL } from 'url' 14import { URL } from 'url'
15import { promisify } from 'util' 15import { promisify } from 'util'
@@ -281,8 +281,8 @@ function promisify2<T, U, A> (func: (arg1: T, arg2: U, cb: (err: any, result: A)
281} 281}
282 282
283const randomBytesPromise = promisify1<number, Buffer>(randomBytes) 283const randomBytesPromise = promisify1<number, Buffer>(randomBytes)
284const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey) 284const createPrivateKey = promisify1<number, { key: string }>(createPrivateKey_1)
285const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey) 285const getPublicKey = promisify1<string, { publicKey: string }>(getPublicKey_1)
286const execPromise2 = promisify2<string, any, string>(exec) 286const execPromise2 = promisify2<string, any, string>(exec)
287const execPromise = promisify1<string, string>(exec) 287const execPromise = promisify1<string, string>(exec)
288const pipelinePromise = promisify(pipeline) 288const pipelinePromise = promisify(pipeline)
diff --git a/server/helpers/custom-jsonld-signature.ts b/server/helpers/custom-jsonld-signature.ts
index 56f10086c..3c706e372 100644
--- a/server/helpers/custom-jsonld-signature.ts
+++ b/server/helpers/custom-jsonld-signature.ts
@@ -1,7 +1,8 @@
1import * as AsyncLRU from 'async-lru' 1import AsyncLRU from 'async-lru'
2import * as jsonld from 'jsonld'
3import { logger } from './logger' 2import { logger } from './logger'
4 3
4import jsonld = require('jsonld')
5
5const CACHE = { 6const CACHE = {
6 'https://w3id.org/security/v1': { 7 'https://w3id.org/security/v1': {
7 '@context': { 8 '@context': {
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index b33e088eb..c3604fbad 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -1,6 +1,6 @@
1import { UploadFilesForCheck } from 'express' 1import { UploadFilesForCheck } from 'express'
2import { values } from 'lodash' 2import { values } from 'lodash'
3import * as magnetUtil from 'magnet-uri' 3import magnetUtil from 'magnet-uri'
4import validator from 'validator' 4import validator from 'validator'
5import { VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared' 5import { VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared'
6import { 6import {
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index ec35295df..aedcc5e64 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -1,5 +1,5 @@
1import * as retry from 'async/retry' 1import retry from 'async/retry'
2import * as Bluebird from 'bluebird' 2import Bluebird from 'bluebird'
3import { Transaction } from 'sequelize' 3import { Transaction } from 'sequelize'
4import { Model } from 'sequelize-typescript' 4import { Model } from 'sequelize-typescript'
5import { sequelizeTypescript } from '@server/initializers/database' 5import { sequelizeTypescript } from '@server/initializers/database'
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts
index c299b70f1..38fe6926b 100644
--- a/server/helpers/express-utils.ts
+++ b/server/helpers/express-utils.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import express from 'express'
2import * as multer from 'multer' 2import multer, { diskStorage } from 'multer'
3import { HttpStatusCode } from '../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
4import { CONFIG } from '../initializers/config' 4import { CONFIG } from '../initializers/config'
5import { REMOTE_SCHEME } from '../initializers/constants' 5import { REMOTE_SCHEME } from '../initializers/constants'
@@ -70,7 +70,7 @@ function createReqFiles (
70 mimeTypes: { [id: string]: string | string[] }, 70 mimeTypes: { [id: string]: string | string[] },
71 destinations: { [fieldName: string]: string } 71 destinations: { [fieldName: string]: string }
72) { 72) {
73 const storage = multer.diskStorage({ 73 const storage = diskStorage({
74 destination: (req, file, cb) => { 74 destination: (req, file, cb) => {
75 cb(null, destinations[file.fieldname]) 75 cb(null, destinations[file.fieldname])
76 }, 76 },
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index a99c9ee7c..54fd031b7 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -1,5 +1,5 @@
1import { Job } from 'bull' 1import { Job } from 'bull'
2import * as ffmpeg from 'fluent-ffmpeg' 2import ffmpeg, { FfmpegCommand, FilterSpecification, getAvailableEncoders } from 'fluent-ffmpeg'
3import { readFile, remove, writeFile } from 'fs-extra' 3import { readFile, remove, writeFile } from 'fs-extra'
4import { dirname, join } from 'path' 4import { dirname, join } from 'path'
5import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants' 5import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants'
@@ -42,7 +42,7 @@ async function checkFFmpegEncoders (peertubeAvailableEncoders: AvailableEncoders
42 return supportedEncoders 42 return supportedEncoders
43 } 43 }
44 44
45 const getAvailableEncodersPromise = promisify0(ffmpeg.getAvailableEncoders) 45 const getAvailableEncodersPromise = promisify0(getAvailableEncoders)
46 const availableFFmpegEncoders = await getAvailableEncodersPromise() 46 const availableFFmpegEncoders = await getAvailableEncodersPromise()
47 47
48 const searchEncoders = new Set<string>() 48 const searchEncoders = new Set<string>()
@@ -191,7 +191,7 @@ type TranscodeOptions =
191 | QuickTranscodeOptions 191 | QuickTranscodeOptions
192 192
193const builders: { 193const builders: {
194 [ type in TranscodeOptionsType ]: (c: ffmpeg.FfmpegCommand, o?: TranscodeOptions) => Promise<ffmpeg.FfmpegCommand> | ffmpeg.FfmpegCommand 194 [ type in TranscodeOptionsType ]: (c: FfmpegCommand, o?: TranscodeOptions) => Promise<FfmpegCommand> | FfmpegCommand
195} = { 195} = {
196 'quick-transcode': buildQuickTranscodeCommand, 196 'quick-transcode': buildQuickTranscodeCommand,
197 'hls': buildHLSVODCommand, 197 'hls': buildHLSVODCommand,
@@ -241,7 +241,7 @@ async function getLiveTranscodingCommand (options: {
241 241
242 const varStreamMap: string[] = [] 242 const varStreamMap: string[] = []
243 243
244 const complexFilter: ffmpeg.FilterSpecification[] = [ 244 const complexFilter: FilterSpecification[] = [
245 { 245 {
246 inputs: '[v:0]', 246 inputs: '[v:0]',
247 filter: 'split', 247 filter: 'split',
@@ -353,7 +353,7 @@ function buildStreamSuffix (base: string, streamNum?: number) {
353// --------------------------------------------------------------------------- 353// ---------------------------------------------------------------------------
354 354
355function addDefaultEncoderGlobalParams (options: { 355function addDefaultEncoderGlobalParams (options: {
356 command: ffmpeg.FfmpegCommand 356 command: FfmpegCommand
357}) { 357}) {
358 const { command } = options 358 const { command } = options
359 359
@@ -370,7 +370,7 @@ function addDefaultEncoderGlobalParams (options: {
370} 370}
371 371
372function addDefaultEncoderParams (options: { 372function addDefaultEncoderParams (options: {
373 command: ffmpeg.FfmpegCommand 373 command: FfmpegCommand
374 encoder: 'libx264' | string 374 encoder: 'libx264' | string
375 streamNum?: number 375 streamNum?: number
376 fps?: number 376 fps?: number
@@ -390,7 +390,7 @@ function addDefaultEncoderParams (options: {
390 } 390 }
391} 391}
392 392
393function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, masterPlaylistName: string) { 393function addDefaultLiveHLSParams (command: FfmpegCommand, outPath: string, masterPlaylistName: string) {
394 command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS) 394 command.outputOption('-hls_time ' + VIDEO_LIVE.SEGMENT_TIME_SECONDS)
395 command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE) 395 command.outputOption('-hls_list_size ' + VIDEO_LIVE.SEGMENTS_LIST_SIZE)
396 command.outputOption('-hls_flags delete_segments+independent_segments') 396 command.outputOption('-hls_flags delete_segments+independent_segments')
@@ -405,7 +405,7 @@ function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string
405// Transcode VOD command builders 405// Transcode VOD command builders
406// --------------------------------------------------------------------------- 406// ---------------------------------------------------------------------------
407 407
408async function buildx264VODCommand (command: ffmpeg.FfmpegCommand, options: TranscodeOptions) { 408async function buildx264VODCommand (command: FfmpegCommand, options: TranscodeOptions) {
409 let fps = await getVideoFileFPS(options.inputPath) 409 let fps = await getVideoFileFPS(options.inputPath)
410 fps = computeFPS(fps, options.resolution) 410 fps = computeFPS(fps, options.resolution)
411 411
@@ -422,7 +422,7 @@ async function buildx264VODCommand (command: ffmpeg.FfmpegCommand, options: Tran
422 return command 422 return command
423} 423}
424 424
425async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: MergeAudioTranscodeOptions) { 425async function buildAudioMergeCommand (command: FfmpegCommand, options: MergeAudioTranscodeOptions) {
426 command = command.loop(undefined) 426 command = command.loop(undefined)
427 427
428 const scaleFilterValue = getScaleCleanerValue() 428 const scaleFilterValue = getScaleCleanerValue()
@@ -437,13 +437,13 @@ async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: M
437 return command 437 return command
438} 438}
439 439
440function buildOnlyAudioCommand (command: ffmpeg.FfmpegCommand, _options: OnlyAudioTranscodeOptions) { 440function buildOnlyAudioCommand (command: FfmpegCommand, _options: OnlyAudioTranscodeOptions) {
441 command = presetOnlyAudio(command) 441 command = presetOnlyAudio(command)
442 442
443 return command 443 return command
444} 444}
445 445
446function buildQuickTranscodeCommand (command: ffmpeg.FfmpegCommand) { 446function buildQuickTranscodeCommand (command: FfmpegCommand) {
447 command = presetCopy(command) 447 command = presetCopy(command)
448 448
449 command = command.outputOption('-map_metadata -1') // strip all metadata 449 command = command.outputOption('-map_metadata -1') // strip all metadata
@@ -452,7 +452,7 @@ function buildQuickTranscodeCommand (command: ffmpeg.FfmpegCommand) {
452 return command 452 return command
453} 453}
454 454
455function addCommonHLSVODCommandOptions (command: ffmpeg.FfmpegCommand, outputPath: string) { 455function addCommonHLSVODCommandOptions (command: FfmpegCommand, outputPath: string) {
456 return command.outputOption('-hls_time 4') 456 return command.outputOption('-hls_time 4')
457 .outputOption('-hls_list_size 0') 457 .outputOption('-hls_list_size 0')
458 .outputOption('-hls_playlist_type vod') 458 .outputOption('-hls_playlist_type vod')
@@ -462,7 +462,7 @@ function addCommonHLSVODCommandOptions (command: ffmpeg.FfmpegCommand, outputPat
462 .outputOption('-hls_flags single_file') 462 .outputOption('-hls_flags single_file')
463} 463}
464 464
465async function buildHLSVODCommand (command: ffmpeg.FfmpegCommand, options: HLSTranscodeOptions) { 465async function buildHLSVODCommand (command: FfmpegCommand, options: HLSTranscodeOptions) {
466 const videoPath = getHLSVideoPath(options) 466 const videoPath = getHLSVideoPath(options)
467 467
468 if (options.copyCodecs) command = presetCopy(command) 468 if (options.copyCodecs) command = presetCopy(command)
@@ -474,7 +474,7 @@ async function buildHLSVODCommand (command: ffmpeg.FfmpegCommand, options: HLSTr
474 return command 474 return command
475} 475}
476 476
477function buildHLSVODFromTSCommand (command: ffmpeg.FfmpegCommand, options: HLSFromTSTranscodeOptions) { 477function buildHLSVODFromTSCommand (command: FfmpegCommand, options: HLSFromTSTranscodeOptions) {
478 const videoPath = getHLSVideoPath(options) 478 const videoPath = getHLSVideoPath(options)
479 479
480 command.outputOption('-c copy') 480 command.outputOption('-c copy')
@@ -571,7 +571,7 @@ async function getEncoderBuilderResult (options: EncoderOptionsBuilderParams & {
571} 571}
572 572
573async function presetVideo (options: { 573async function presetVideo (options: {
574 command: ffmpeg.FfmpegCommand 574 command: FfmpegCommand
575 input: string 575 input: string
576 transcodeOptions: TranscodeOptions 576 transcodeOptions: TranscodeOptions
577 fps?: number 577 fps?: number
@@ -640,21 +640,21 @@ async function presetVideo (options: {
640 return localCommand 640 return localCommand
641} 641}
642 642
643function presetCopy (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand { 643function presetCopy (command: FfmpegCommand): FfmpegCommand {
644 return command 644 return command
645 .format('mp4') 645 .format('mp4')
646 .videoCodec('copy') 646 .videoCodec('copy')
647 .audioCodec('copy') 647 .audioCodec('copy')
648} 648}
649 649
650function presetOnlyAudio (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand { 650function presetOnlyAudio (command: FfmpegCommand): FfmpegCommand {
651 return command 651 return command
652 .format('mp4') 652 .format('mp4')
653 .audioCodec('copy') 653 .audioCodec('copy')
654 .noVideo() 654 .noVideo()
655} 655}
656 656
657function applyEncoderOptions (command: ffmpeg.FfmpegCommand, options: EncoderOptions): ffmpeg.FfmpegCommand { 657function applyEncoderOptions (command: FfmpegCommand, options: EncoderOptions): FfmpegCommand {
658 return command 658 return command
659 .inputOptions(options.inputOptions ?? []) 659 .inputOptions(options.inputOptions ?? [])
660 .outputOptions(options.outputOptions ?? []) 660 .outputOptions(options.outputOptions ?? [])
@@ -714,7 +714,7 @@ function getFFmpegVersion () {
714} 714}
715 715
716async function runCommand (options: { 716async function runCommand (options: {
717 command: ffmpeg.FfmpegCommand 717 command: FfmpegCommand
718 silent?: boolean // false 718 silent?: boolean // false
719 job?: Job 719 job?: Job
720}) { 720}) {
diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts
index e58444b07..8381dee84 100644
--- a/server/helpers/ffprobe-utils.ts
+++ b/server/helpers/ffprobe-utils.ts
@@ -1,4 +1,4 @@
1import * as ffmpeg from 'fluent-ffmpeg' 1import { ffprobe, FfprobeData } from 'fluent-ffmpeg'
2import { getMaxBitrate } from '@shared/core-utils' 2import { getMaxBitrate } from '@shared/core-utils'
3import { VideoFileMetadata, VideoResolution, VideoTranscodingFPS } from '../../shared/models/videos' 3import { VideoFileMetadata, VideoResolution, VideoTranscodingFPS } from '../../shared/models/videos'
4import { CONFIG } from '../initializers/config' 4import { CONFIG } from '../initializers/config'
@@ -12,8 +12,8 @@ import { logger } from './logger'
12 */ 12 */
13 13
14function ffprobePromise (path: string) { 14function ffprobePromise (path: string) {
15 return new Promise<ffmpeg.FfprobeData>((res, rej) => { 15 return new Promise<FfprobeData>((res, rej) => {
16 ffmpeg.ffprobe(path, (err, data) => { 16 ffprobe(path, (err, data) => {
17 if (err) return rej(err) 17 if (err) return rej(err)
18 18
19 return res(data) 19 return res(data)
@@ -21,7 +21,7 @@ function ffprobePromise (path: string) {
21 }) 21 })
22} 22}
23 23
24async function getAudioStream (videoPath: string, existingProbe?: ffmpeg.FfprobeData) { 24async function getAudioStream (videoPath: string, existingProbe?: FfprobeData) {
25 // without position, ffprobe considers the last input only 25 // without position, ffprobe considers the last input only
26 // we make it consider the first input only 26 // we make it consider the first input only
27 // if you pass a file path to pos, then ffprobe acts on that file directly 27 // if you pass a file path to pos, then ffprobe acts on that file directly
@@ -76,7 +76,7 @@ function getMaxAudioBitrate (type: 'aac' | 'mp3' | string, bitrate: number) {
76 } 76 }
77} 77}
78 78
79async function getVideoStreamSize (path: string, existingProbe?: ffmpeg.FfprobeData): Promise<{ width: number, height: number }> { 79async function getVideoStreamSize (path: string, existingProbe?: FfprobeData): Promise<{ width: number, height: number }> {
80 const videoStream = await getVideoStreamFromFile(path, existingProbe) 80 const videoStream = await getVideoStreamFromFile(path, existingProbe)
81 81
82 return videoStream === null 82 return videoStream === null
@@ -127,7 +127,7 @@ async function getVideoStreamCodec (path: string) {
127 return `${videoCodec}.${baseProfile}${level}` 127 return `${videoCodec}.${baseProfile}${level}`
128} 128}
129 129
130async function getAudioStreamCodec (path: string, existingProbe?: ffmpeg.FfprobeData) { 130async function getAudioStreamCodec (path: string, existingProbe?: FfprobeData) {
131 const { audioStream } = await getAudioStream(path, existingProbe) 131 const { audioStream } = await getAudioStream(path, existingProbe)
132 132
133 if (!audioStream) return '' 133 if (!audioStream) return ''
@@ -143,7 +143,7 @@ async function getAudioStreamCodec (path: string, existingProbe?: ffmpeg.Ffprobe
143 return 'mp4a.40.2' // Fallback 143 return 'mp4a.40.2' // Fallback
144} 144}
145 145
146async function getVideoFileResolution (path: string, existingProbe?: ffmpeg.FfprobeData) { 146async function getVideoFileResolution (path: string, existingProbe?: FfprobeData) {
147 const size = await getVideoStreamSize(path, existingProbe) 147 const size = await getVideoStreamSize(path, existingProbe)
148 148
149 return { 149 return {
@@ -155,7 +155,7 @@ async function getVideoFileResolution (path: string, existingProbe?: ffmpeg.Ffpr
155 } 155 }
156} 156}
157 157
158async function getVideoFileFPS (path: string, existingProbe?: ffmpeg.FfprobeData) { 158async function getVideoFileFPS (path: string, existingProbe?: FfprobeData) {
159 const videoStream = await getVideoStreamFromFile(path, existingProbe) 159 const videoStream = await getVideoStreamFromFile(path, existingProbe)
160 if (videoStream === null) return 0 160 if (videoStream === null) return 0
161 161
@@ -173,13 +173,13 @@ async function getVideoFileFPS (path: string, existingProbe?: ffmpeg.FfprobeData
173 return 0 173 return 0
174} 174}
175 175
176async function getMetadataFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) { 176async function getMetadataFromFile (path: string, existingProbe?: FfprobeData) {
177 const metadata = existingProbe || await ffprobePromise(path) 177 const metadata = existingProbe || await ffprobePromise(path)
178 178
179 return new VideoFileMetadata(metadata) 179 return new VideoFileMetadata(metadata)
180} 180}
181 181
182async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.FfprobeData): Promise<number> { 182async function getVideoFileBitrate (path: string, existingProbe?: FfprobeData): Promise<number> {
183 const metadata = await getMetadataFromFile(path, existingProbe) 183 const metadata = await getMetadataFromFile(path, existingProbe)
184 184
185 let bitrate = metadata.format.bit_rate as number 185 let bitrate = metadata.format.bit_rate as number
@@ -194,13 +194,13 @@ async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.Ffprobe
194 return undefined 194 return undefined
195} 195}
196 196
197async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) { 197async function getDurationFromVideoFile (path: string, existingProbe?: FfprobeData) {
198 const metadata = await getMetadataFromFile(path, existingProbe) 198 const metadata = await getMetadataFromFile(path, existingProbe)
199 199
200 return Math.round(metadata.format.duration) 200 return Math.round(metadata.format.duration)
201} 201}
202 202
203async function getVideoStreamFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) { 203async function getVideoStreamFromFile (path: string, existingProbe?: FfprobeData) {
204 const metadata = await getMetadataFromFile(path, existingProbe) 204 const metadata = await getMetadataFromFile(path, existingProbe)
205 205
206 return metadata.streams.find(s => s.codec_type === 'video') || null 206 return metadata.streams.find(s => s.codec_type === 'video') || null
@@ -243,7 +243,7 @@ async function canDoQuickTranscode (path: string): Promise<boolean> {
243 await canDoQuickAudioTranscode(path, probe) 243 await canDoQuickAudioTranscode(path, probe)
244} 244}
245 245
246async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> { 246async function canDoQuickVideoTranscode (path: string, probe?: FfprobeData): Promise<boolean> {
247 const videoStream = await getVideoStreamFromFile(path, probe) 247 const videoStream = await getVideoStreamFromFile(path, probe)
248 const fps = await getVideoFileFPS(path, probe) 248 const fps = await getVideoFileFPS(path, probe)
249 const bitRate = await getVideoFileBitrate(path, probe) 249 const bitRate = await getVideoFileBitrate(path, probe)
@@ -262,7 +262,7 @@ async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeDat
262 return true 262 return true
263} 263}
264 264
265async function canDoQuickAudioTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> { 265async function canDoQuickAudioTranscode (path: string, probe?: FfprobeData): Promise<boolean> {
266 const parsedAudio = await getAudioStream(path, probe) 266 const parsedAudio = await getAudioStream(path, probe)
267 267
268 if (!parsedAudio.audioStream) return true 268 if (!parsedAudio.audioStream) return true
diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts
index c76ed545b..033be2c50 100644
--- a/server/helpers/image-utils.ts
+++ b/server/helpers/image-utils.ts
@@ -1,5 +1,5 @@
1import { copy, readFile, remove, rename } from 'fs-extra' 1import { copy, readFile, remove, rename } from 'fs-extra'
2import * as Jimp from 'jimp' 2import Jimp, { read } from 'jimp'
3import { getLowercaseExtension } from './core-utils' 3import { getLowercaseExtension } from './core-utils'
4import { convertWebPToJPG, processGIF } from './ffmpeg-utils' 4import { convertWebPToJPG, processGIF } from './ffmpeg-utils'
5import { logger } from './logger' 5import { logger } from './logger'
@@ -47,7 +47,7 @@ async function jimpProcessor (path: string, destination: string, newSize: { widt
47 const inputBuffer = await readFile(path) 47 const inputBuffer = await readFile(path)
48 48
49 try { 49 try {
50 jimpInstance = await Jimp.read(inputBuffer) 50 jimpInstance = await read(inputBuffer)
51 } catch (err) { 51 } catch (err) {
52 logger.debug('Cannot read %s with jimp. Try to convert the image using ffmpeg first.', path, { err }) 52 logger.debug('Cannot read %s with jimp. Try to convert the image using ffmpeg first.', path, { err })
53 53
@@ -55,7 +55,7 @@ async function jimpProcessor (path: string, destination: string, newSize: { widt
55 await convertWebPToJPG(path, newName) 55 await convertWebPToJPG(path, newName)
56 await rename(newName, path) 56 await rename(newName, path)
57 57
58 jimpInstance = await Jimp.read(path) 58 jimpInstance = await read(path)
59 } 59 }
60 60
61 await remove(destination) 61 await remove(destination)
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index 20c3c3edb..4bd00e503 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -1,9 +1,9 @@
1// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/ 1// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
2import { mkdirpSync, stat } from 'fs-extra' 2import { mkdirpSync, stat } from 'fs-extra'
3import { omit } from 'lodash' 3import { omit } from 'lodash'
4import * as path from 'path' 4import { join } from 'path'
5import { format as sqlFormat } from 'sql-formatter' 5import { format as sqlFormat } from 'sql-formatter'
6import * as winston from 'winston' 6import { createLogger, format, transports } from 'winston'
7import { FileTransportOptions } from 'winston/lib/winston/transports' 7import { FileTransportOptions } from 'winston/lib/winston/transports'
8import { CONFIG } from '../initializers/config' 8import { CONFIG } from '../initializers/config'
9import { LOG_FILENAME } from '../initializers/constants' 9import { LOG_FILENAME } from '../initializers/constants'
@@ -47,7 +47,7 @@ function getLoggerReplacer () {
47 } 47 }
48} 48}
49 49
50const consoleLoggerFormat = winston.format.printf(info => { 50const consoleLoggerFormat = format.printf(info => {
51 const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql', 'tags' ] 51 const toOmit = [ 'label', 'timestamp', 'level', 'message', 'sql', 'tags' ]
52 52
53 const obj = omit(info, ...toOmit) 53 const obj = omit(info, ...toOmit)
@@ -71,24 +71,24 @@ const consoleLoggerFormat = winston.format.printf(info => {
71 return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}` 71 return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}`
72}) 72})
73 73
74const jsonLoggerFormat = winston.format.printf(info => { 74const jsonLoggerFormat = format.printf(info => {
75 return JSON.stringify(info, getLoggerReplacer()) 75 return JSON.stringify(info, getLoggerReplacer())
76}) 76})
77 77
78const timestampFormatter = winston.format.timestamp({ 78const timestampFormatter = format.timestamp({
79 format: 'YYYY-MM-DD HH:mm:ss.SSS' 79 format: 'YYYY-MM-DD HH:mm:ss.SSS'
80}) 80})
81const labelFormatter = (suffix?: string) => { 81const labelFormatter = (suffix?: string) => {
82 return winston.format.label({ 82 return format.label({
83 label: suffix ? `${label} ${suffix}` : label 83 label: suffix ? `${label} ${suffix}` : label
84 }) 84 })
85} 85}
86 86
87const fileLoggerOptions: FileTransportOptions = { 87const fileLoggerOptions: FileTransportOptions = {
88 filename: path.join(CONFIG.STORAGE.LOG_DIR, LOG_FILENAME), 88 filename: join(CONFIG.STORAGE.LOG_DIR, LOG_FILENAME),
89 handleExceptions: true, 89 handleExceptions: true,
90 format: winston.format.combine( 90 format: format.combine(
91 winston.format.timestamp(), 91 format.timestamp(),
92 jsonLoggerFormat 92 jsonLoggerFormat
93 ) 93 )
94} 94}
@@ -101,19 +101,19 @@ if (CONFIG.LOG.ROTATION.ENABLED) {
101const logger = buildLogger() 101const logger = buildLogger()
102 102
103function buildLogger (labelSuffix?: string) { 103function buildLogger (labelSuffix?: string) {
104 return winston.createLogger({ 104 return createLogger({
105 level: CONFIG.LOG.LEVEL, 105 level: CONFIG.LOG.LEVEL,
106 format: winston.format.combine( 106 format: format.combine(
107 labelFormatter(labelSuffix), 107 labelFormatter(labelSuffix),
108 winston.format.splat() 108 format.splat()
109 ), 109 ),
110 transports: [ 110 transports: [
111 new winston.transports.File(fileLoggerOptions), 111 new transports.File(fileLoggerOptions),
112 new winston.transports.Console({ 112 new transports.Console({
113 handleExceptions: true, 113 handleExceptions: true,
114 format: winston.format.combine( 114 format: format.combine(
115 timestampFormatter, 115 timestampFormatter,
116 winston.format.colorize(), 116 format.colorize(),
117 consoleLoggerFormat 117 consoleLoggerFormat
118 ) 118 )
119 }) 119 })
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts
index bc6f1d074..66060bde2 100644
--- a/server/helpers/peertube-crypto.ts
+++ b/server/helpers/peertube-crypto.ts
@@ -1,16 +1,16 @@
1import { compare, genSalt, hash } from 'bcrypt'
2import { createSign, createVerify } from 'crypto'
1import { Request } from 'express' 3import { Request } from 'express'
4import { cloneDeep } from 'lodash'
2import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants' 5import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants'
6import { MActor } from '../types/models'
3import { createPrivateKey, getPublicKey, promisify1, promisify2, sha256 } from './core-utils' 7import { createPrivateKey, getPublicKey, promisify1, promisify2, sha256 } from './core-utils'
4import { jsonld } from './custom-jsonld-signature' 8import { jsonld } from './custom-jsonld-signature'
5import { logger } from './logger' 9import { logger } from './logger'
6import { cloneDeep } from 'lodash'
7import { createSign, createVerify } from 'crypto'
8import * as bcrypt from 'bcrypt'
9import { MActor } from '../types/models'
10 10
11const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare) 11const bcryptComparePromise = promisify2<any, string, boolean>(compare)
12const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt) 12const bcryptGenSaltPromise = promisify1<number, string>(genSalt)
13const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash) 13const bcryptHashPromise = promisify2<any, string | number, string>(hash)
14 14
15const httpSignature = require('http-signature') 15const httpSignature = require('http-signature')
16 16
@@ -129,7 +129,7 @@ export {
129 129
130// --------------------------------------------------------------------------- 130// ---------------------------------------------------------------------------
131 131
132function hash (obj: any): Promise<any> { 132function hashObject (obj: any): Promise<any> {
133 return jsonld.promises 133 return jsonld.promises
134 .normalize(obj, { 134 .normalize(obj, {
135 algorithm: 'URDNA2015', 135 algorithm: 'URDNA2015',
@@ -151,12 +151,12 @@ function createSignatureHash (signature: any) {
151 delete signatureCopy.id 151 delete signatureCopy.id
152 delete signatureCopy.signatureValue 152 delete signatureCopy.signatureValue
153 153
154 return hash(signatureCopy) 154 return hashObject(signatureCopy)
155} 155}
156 156
157function createDocWithoutSignatureHash (doc: any) { 157function createDocWithoutSignatureHash (doc: any) {
158 const docWithoutSignature = cloneDeep(doc) 158 const docWithoutSignature = cloneDeep(doc)
159 delete docWithoutSignature.signature 159 delete docWithoutSignature.signature
160 160
161 return hash(docWithoutSignature) 161 return hashObject(docWithoutSignature)
162} 162}
diff --git a/server/helpers/uuid.ts b/server/helpers/uuid.ts
index 3eb06c773..f3c80e046 100644
--- a/server/helpers/uuid.ts
+++ b/server/helpers/uuid.ts
@@ -1,9 +1,9 @@
1import * as short from 'short-uuid' 1import short, { uuid } from 'short-uuid'
2 2
3const translator = short() 3const translator = short()
4 4
5function buildUUID () { 5function buildUUID () {
6 return short.uuid() 6 return uuid()
7} 7}
8 8
9function uuidToShort (uuid: string) { 9function uuidToShort (uuid: string) {
diff --git a/server/helpers/webtorrent.ts b/server/helpers/webtorrent.ts
index 813ebc236..83b46e085 100644
--- a/server/helpers/webtorrent.ts
+++ b/server/helpers/webtorrent.ts
@@ -1,10 +1,11 @@
1import * as bencode from 'bencode' 1import { decode, encode } from 'bencode'
2import * as createTorrent from 'create-torrent' 2import createTorrent from 'create-torrent'
3import { createWriteStream, ensureDir, readFile, remove, writeFile } from 'fs-extra' 3import { createWriteStream, ensureDir, readFile, remove, writeFile } from 'fs-extra'
4import * as magnetUtil from 'magnet-uri' 4import magnetUtil from 'magnet-uri'
5import * as parseTorrent from 'parse-torrent' 5import parseTorrent from 'parse-torrent'
6import { dirname, join } from 'path' 6import { dirname, join } from 'path'
7import * as WebTorrent from 'webtorrent' 7import { pipeline } from 'stream'
8import WebTorrent, { Instance, TorrentFile } from 'webtorrent'
8import { isArray } from '@server/helpers/custom-validators/misc' 9import { isArray } from '@server/helpers/custom-validators/misc'
9import { WEBSERVER } from '@server/initializers/constants' 10import { WEBSERVER } from '@server/initializers/constants'
10import { generateTorrentFileName } from '@server/lib/paths' 11import { generateTorrentFileName } from '@server/lib/paths'
@@ -17,7 +18,6 @@ import { promisify2 } from './core-utils'
17import { logger } from './logger' 18import { logger } from './logger'
18import { generateVideoImportTmpPath } from './utils' 19import { generateVideoImportTmpPath } from './utils'
19import { extractVideo } from './video' 20import { extractVideo } from './video'
20import { pipeline } from 'stream'
21 21
22const createTorrentPromise = promisify2<string, any, any>(createTorrent) 22const createTorrentPromise = promisify2<string, any, any>(createTorrent)
23 23
@@ -33,7 +33,7 @@ async function downloadWebTorrentVideo (target: { magnetUri: string, torrentName
33 33
34 return new Promise<string>((res, rej) => { 34 return new Promise<string>((res, rej) => {
35 const webtorrent = new WebTorrent() 35 const webtorrent = new WebTorrent()
36 let file: WebTorrent.TorrentFile 36 let file: TorrentFile
37 37
38 const torrentId = target.magnetUri || join(CONFIG.STORAGE.TORRENTS_DIR, target.torrentName) 38 const torrentId = target.magnetUri || join(CONFIG.STORAGE.TORRENTS_DIR, target.torrentName)
39 39
@@ -126,7 +126,7 @@ async function updateTorrentUrls (videoOrPlaylist: MVideo | MStreamingPlaylistVi
126 const oldTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename) 126 const oldTorrentPath = join(CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename)
127 127
128 const torrentContent = await readFile(oldTorrentPath) 128 const torrentContent = await readFile(oldTorrentPath)
129 const decoded = bencode.decode(torrentContent) 129 const decoded = decode(torrentContent)
130 130
131 decoded['announce-list'] = buildAnnounceList() 131 decoded['announce-list'] = buildAnnounceList()
132 decoded.announce = decoded['announce-list'][0][0] 132 decoded.announce = decoded['announce-list'][0][0]
@@ -138,7 +138,7 @@ async function updateTorrentUrls (videoOrPlaylist: MVideo | MStreamingPlaylistVi
138 138
139 logger.info('Updating torrent URLs %s -> %s.', oldTorrentPath, newTorrentPath) 139 logger.info('Updating torrent URLs %s -> %s.', oldTorrentPath, newTorrentPath)
140 140
141 await writeFile(newTorrentPath, bencode.encode(decoded)) 141 await writeFile(newTorrentPath, encode(decoded))
142 await remove(join(CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename)) 142 await remove(join(CONFIG.STORAGE.TORRENTS_DIR, videoFile.torrentFilename))
143 143
144 videoFile.torrentFilename = newTorrentFilename 144 videoFile.torrentFilename = newTorrentFilename
@@ -180,7 +180,7 @@ export {
180// --------------------------------------------------------------------------- 180// ---------------------------------------------------------------------------
181 181
182function safeWebtorrentDestroy ( 182function safeWebtorrentDestroy (
183 webtorrent: WebTorrent.Instance, 183 webtorrent: Instance,
184 torrentId: string, 184 torrentId: string,
185 downloadedFile?: { directoryPath: string, filepath: string }, 185 downloadedFile?: { directoryPath: string, filepath: string },
186 torrentName?: string 186 torrentName?: string
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts
index 09f587274..c0a6c41ab 100644
--- a/server/initializers/checker-after-init.ts
+++ b/server/initializers/checker-after-init.ts
@@ -1,4 +1,4 @@
1import * as config from 'config' 1import { util, has, get } from 'config'
2import { uniq } from 'lodash' 2import { uniq } from 'lodash'
3import { URL } from 'url' 3import { URL } from 'url'
4import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils' 4import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils'
@@ -18,8 +18,8 @@ async function checkActivityPubUrls () {
18 18
19 const parsed = new URL(actor.url) 19 const parsed = new URL(actor.url)
20 if (WEBSERVER.HOST !== parsed.host) { 20 if (WEBSERVER.HOST !== parsed.host) {
21 const NODE_ENV = config.util.getEnv('NODE_ENV') 21 const NODE_ENV = util.getEnv('NODE_ENV')
22 const NODE_CONFIG_DIR = config.util.getEnv('NODE_CONFIG_DIR') 22 const NODE_CONFIG_DIR = util.getEnv('NODE_CONFIG_DIR')
23 23
24 logger.warn( 24 logger.warn(
25 'It seems PeerTube was started (and created some data) with another domain name. ' + 25 'It seems PeerTube was started (and created some data) with another domain name. ' +
@@ -36,7 +36,7 @@ async function checkActivityPubUrls () {
36function checkConfig () { 36function checkConfig () {
37 37
38 // Moved configuration keys 38 // Moved configuration keys
39 if (config.has('services.csp-logger')) { 39 if (has('services.csp-logger')) {
40 logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.') 40 logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.')
41 } 41 }
42 42
@@ -97,7 +97,7 @@ function checkConfig () {
97 97
98 // Check storage directory locations 98 // Check storage directory locations
99 if (isProdInstance()) { 99 if (isProdInstance()) {
100 const configStorage = config.get('storage') 100 const configStorage = get('storage')
101 for (const key of Object.keys(configStorage)) { 101 for (const key of Object.keys(configStorage)) {
102 if (configStorage[key].startsWith('storage/')) { 102 if (configStorage[key].startsWith('storage/')) {
103 logger.warn( 103 logger.warn(
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 93c019121..16dc137c0 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -1,7 +1,10 @@
1import * as config from 'config' 1import { IConfig } from 'config'
2import { parseSemVersion, promisify0 } from '../helpers/core-utils' 2import { parseSemVersion, promisify0 } from '../helpers/core-utils'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4 4
5// Special behaviour for config because we can reload it
6const config: IConfig = require('config')
7
5// ONLY USE CORE MODULES IN THIS FILE! 8// ONLY USE CORE MODULES IN THIS FILE!
6 9
7// Check the config files 10// Check the config files
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 0e684eef8..be9fc61f0 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -1,4 +1,4 @@
1import * as bytes from 'bytes' 1import bytes from 'bytes'
2import { IConfig } from 'config' 2import { IConfig } from 'config'
3import decache from 'decache' 3import decache from 'decache'
4import { dirname, join } from 'path' 4import { dirname, join } from 'path'
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts
index 676f88653..75daeb5d8 100644
--- a/server/initializers/installer.ts
+++ b/server/initializers/installer.ts
@@ -1,15 +1,15 @@
1import * as passwordGenerator from 'password-generator' 1import { ensureDir, remove } from 'fs-extra'
2import passwordGenerator from 'password-generator'
2import { UserRole } from '../../shared' 3import { UserRole } from '../../shared'
3import { logger } from '../helpers/logger' 4import { logger } from '../helpers/logger'
4import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' 5import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user'
5import { UserModel } from '../models/user/user'
6import { ApplicationModel } from '../models/application/application' 6import { ApplicationModel } from '../models/application/application'
7import { OAuthClientModel } from '../models/oauth/oauth-client' 7import { OAuthClientModel } from '../models/oauth/oauth-client'
8import { UserModel } from '../models/user/user'
8import { applicationExist, clientsExist, usersExist } from './checker-after-init' 9import { applicationExist, clientsExist, usersExist } from './checker-after-init'
10import { CONFIG } from './config'
9import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants' 11import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants'
10import { sequelizeTypescript } from './database' 12import { sequelizeTypescript } from './database'
11import { ensureDir, remove } from 'fs-extra'
12import { CONFIG } from './config'
13 13
14async function installApplication () { 14async function installApplication () {
15 try { 15 try {
diff --git a/server/initializers/migrator.ts b/server/initializers/migrator.ts
index 77203ae24..7d7c9f8cb 100644
--- a/server/initializers/migrator.ts
+++ b/server/initializers/migrator.ts
@@ -1,9 +1,9 @@
1import * as path from 'path' 1import { readdir } from 'fs-extra'
2import { join } from 'path'
3import { QueryTypes } from 'sequelize'
2import { logger } from '../helpers/logger' 4import { logger } from '../helpers/logger'
3import { LAST_MIGRATION_VERSION } from './constants' 5import { LAST_MIGRATION_VERSION } from './constants'
4import { sequelizeTypescript } from './database' 6import { sequelizeTypescript } from './database'
5import { readdir } from 'fs-extra'
6import { QueryTypes } from 'sequelize'
7 7
8async function migrate () { 8async function migrate () {
9 const tables = await sequelizeTypescript.getQueryInterface().showAllTables() 9 const tables = await sequelizeTypescript.getQueryInterface().showAllTables()
@@ -58,7 +58,7 @@ export {
58// --------------------------------------------------------------------------- 58// ---------------------------------------------------------------------------
59 59
60async function getMigrationScripts () { 60async function getMigrationScripts () {
61 const files = await readdir(path.join(__dirname, 'migrations')) 61 const files = await readdir(join(__dirname, 'migrations'))
62 const filesToMigrate: { 62 const filesToMigrate: {
63 version: string 63 version: string
64 script: string 64 script: string
@@ -88,7 +88,7 @@ async function executeMigration (actualVersion: number, entity: { version: strin
88 const migrationScriptName = entity.script 88 const migrationScriptName = entity.script
89 logger.info('Executing %s migration script.', migrationScriptName) 89 logger.info('Executing %s migration script.', migrationScriptName)
90 90
91 const migrationScript = require(path.join(__dirname, 'migrations', migrationScriptName)) 91 const migrationScript = require(join(__dirname, 'migrations', migrationScriptName))
92 92
93 return sequelizeTypescript.transaction(async t => { 93 return sequelizeTypescript.transaction(async t => {
94 const options = { 94 const options = {
diff --git a/server/lib/activitypub/actors/webfinger.ts b/server/lib/activitypub/actors/webfinger.ts
index 1c7ec4717..5532f05bd 100644
--- a/server/lib/activitypub/actors/webfinger.ts
+++ b/server/lib/activitypub/actors/webfinger.ts
@@ -1,4 +1,4 @@
1import * as WebFinger from 'webfinger.js' 1import WebFinger from 'webfinger.js'
2import { isProdInstance } from '@server/helpers/core-utils' 2import { isProdInstance } from '@server/helpers/core-utils'
3import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' 3import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
4import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants' 4import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants'
diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts
index 28ff5225a..336129b82 100644
--- a/server/lib/activitypub/crawl.ts
+++ b/server/lib/activitypub/crawl.ts
@@ -1,13 +1,13 @@
1import { retryTransactionWrapper } from '@server/helpers/database-utils' 1import Bluebird from 'bluebird'
2import * as Bluebird from 'bluebird'
3import { URL } from 'url' 2import { URL } from 'url'
3import { retryTransactionWrapper } from '@server/helpers/database-utils'
4import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' 4import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
5import { logger } from '../../helpers/logger' 5import { logger } from '../../helpers/logger'
6import { doJSONRequest } from '../../helpers/requests' 6import { doJSONRequest } from '../../helpers/requests'
7import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants' 7import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants'
8 8
9type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) 9type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>)
10type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) 10type CleanerFunction = (startedDate: Date) => Promise<any>
11 11
12async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) { 12async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) {
13 let url = argUrl 13 let url = argUrl
diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/lib/activitypub/playlists/create-update.ts
index ea3e61ac5..b152d709c 100644
--- a/server/lib/activitypub/playlists/create-update.ts
+++ b/server/lib/activitypub/playlists/create-update.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import { getAPId } from '@server/helpers/activitypub' 2import { getAPId } from '@server/helpers/activitypub'
3import { isArray } from '@server/helpers/custom-validators/misc' 3import { isArray } from '@server/helpers/custom-validators/misc'
4import { logger, loggerTagsFactory } from '@server/helpers/logger' 4import { logger, loggerTagsFactory } from '@server/helpers/logger'
@@ -24,7 +24,7 @@ import {
24const lTags = loggerTagsFactory('ap', 'video-playlist') 24const lTags = loggerTagsFactory('ap', 'video-playlist')
25 25
26async function createAccountPlaylists (playlistUrls: string[]) { 26async function createAccountPlaylists (playlistUrls: string[]) {
27 await Bluebird.map(playlistUrls, async playlistUrl => { 27 await map(playlistUrls, async playlistUrl => {
28 try { 28 try {
29 const exists = await VideoPlaylistModel.doesPlaylistExist(playlistUrl) 29 const exists = await VideoPlaylistModel.doesPlaylistExist(playlistUrl)
30 if (exists === true) return 30 if (exists === true) return
@@ -140,7 +140,7 @@ async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MV
140async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) { 140async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) {
141 const elementsToCreate: FilteredModelAttributes<VideoPlaylistElementModel>[] = [] 141 const elementsToCreate: FilteredModelAttributes<VideoPlaylistElementModel>[] = []
142 142
143 await Bluebird.map(elementUrls, async elementUrl => { 143 await map(elementUrls, async elementUrl => {
144 try { 144 try {
145 const { elementObject } = await fetchRemotePlaylistElement(elementUrl) 145 const { elementObject } = await fetchRemotePlaylistElement(elementUrl)
146 146
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts
index 1ff01a175..b18761174 100644
--- a/server/lib/activitypub/share.ts
+++ b/server/lib/activitypub/share.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import { Transaction } from 'sequelize' 2import { Transaction } from 'sequelize'
3import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
4import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' 4import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
@@ -38,7 +38,7 @@ async function changeVideoChannelShare (
38} 38}
39 39
40async function addVideoShares (shareUrls: string[], video: MVideoId) { 40async function addVideoShares (shareUrls: string[], video: MVideoId) {
41 await Bluebird.map(shareUrls, async shareUrl => { 41 await map(shareUrls, async shareUrl => {
42 try { 42 try {
43 await addVideoShare(shareUrl, video) 43 await addVideoShare(shareUrl, video)
44 } catch (err) { 44 } catch (err) {
diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts
index 6b7f9504f..2a14790fe 100644
--- a/server/lib/activitypub/video-comments.ts
+++ b/server/lib/activitypub/video-comments.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import { checkUrlsSameHost } from '../../helpers/activitypub' 2import { checkUrlsSameHost } from '../../helpers/activitypub'
3import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' 3import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
@@ -18,7 +18,7 @@ type ResolveThreadParams = {
18type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }> 18type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }>
19 19
20async function addVideoComments (commentUrls: string[]) { 20async function addVideoComments (commentUrls: string[]) {
21 return Bluebird.map(commentUrls, async commentUrl => { 21 return map(commentUrls, async commentUrl => {
22 try { 22 try {
23 await resolveThread({ url: commentUrl, isVideo: false }) 23 await resolveThread({ url: commentUrl, isVideo: false })
24 } catch (err) { 24 } catch (err) {
diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts
index 9fb97ef84..04aa5eae9 100644
--- a/server/lib/activitypub/video-rates.ts
+++ b/server/lib/activitypub/video-rates.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import { Transaction } from 'sequelize' 2import { Transaction } from 'sequelize'
3import { doJSONRequest } from '@server/helpers/requests' 3import { doJSONRequest } from '@server/helpers/requests'
4import { VideoRateType } from '../../../shared/models/videos' 4import { VideoRateType } from '../../../shared/models/videos'
@@ -15,7 +15,7 @@ import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlBy
15const lTags = loggerTagsFactory('ap', 'video-rate', 'create') 15const lTags = loggerTagsFactory('ap', 'video-rate', 'create')
16 16
17async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) { 17async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) {
18 await Bluebird.map(ratesUrl, async rateUrl => { 18 await map(ratesUrl, async rateUrl => {
19 try { 19 try {
20 await createRate(rateUrl, video, rate) 20 await createRate(rateUrl, video, rate)
21 } catch (err) { 21 } catch (err) {
diff --git a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
index bd9ed45a9..62354ab56 100644
--- a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
+++ b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts
@@ -1,5 +1,5 @@
1import { maxBy, minBy } from 'lodash' 1import { maxBy, minBy } from 'lodash'
2import * as magnetUtil from 'magnet-uri' 2import magnetUtil from 'magnet-uri'
3import { basename } from 'path' 3import { basename } from 'path'
4import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos' 4import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos'
5import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos' 5import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos'
diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts
index ae728d080..f2ef0a78a 100644
--- a/server/lib/auth/oauth-model.ts
+++ b/server/lib/auth/oauth-model.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { AccessDeniedError } from 'oauth2-server' 2import { AccessDeniedError } from 'oauth2-server'
3import { PluginManager } from '@server/lib/plugins/plugin-manager' 3import { PluginManager } from '@server/lib/plugins/plugin-manager'
4import { ActorModel } from '@server/models/actor/actor' 4import { ActorModel } from '@server/models/actor/actor'
diff --git a/server/lib/auth/oauth.ts b/server/lib/auth/oauth.ts
index a97681c86..497773536 100644
--- a/server/lib/auth/oauth.ts
+++ b/server/lib/auth/oauth.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { 2import {
3 InvalidClientError, 3 InvalidClientError,
4 InvalidGrantError, 4 InvalidGrantError,
diff --git a/server/lib/auth/tokens-cache.ts b/server/lib/auth/tokens-cache.ts
index b027ce69a..410708a35 100644
--- a/server/lib/auth/tokens-cache.ts
+++ b/server/lib/auth/tokens-cache.ts
@@ -1,4 +1,4 @@
1import * as LRUCache from 'lru-cache' 1import LRUCache from 'lru-cache'
2import { MOAuthTokenUser } from '@server/types/models' 2import { MOAuthTokenUser } from '@server/types/models'
3import { LRU_CACHE } from '../../initializers/constants' 3import { LRU_CACHE } from '../../initializers/constants'
4 4
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index e093d35f7..3b0a68f4d 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { readFile } from 'fs-extra' 2import { readFile } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import validator from 'validator' 4import validator from 'validator'
diff --git a/server/lib/files-cache/abstract-video-static-file-cache.ts b/server/lib/files-cache/abstract-video-static-file-cache.ts
index af66689a0..a7ac88525 100644
--- a/server/lib/files-cache/abstract-video-static-file-cache.ts
+++ b/server/lib/files-cache/abstract-video-static-file-cache.ts
@@ -1,6 +1,6 @@
1import { remove } from 'fs-extra' 1import { remove } from 'fs-extra'
2import { logger } from '../../helpers/logger' 2import { logger } from '../../helpers/logger'
3import * as memoizee from 'memoizee' 3import memoizee from 'memoizee'
4 4
5type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined 5type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined
6 6
diff --git a/server/lib/job-queue/handlers/activitypub-cleaner.ts b/server/lib/job-queue/handlers/activitypub-cleaner.ts
index 56e2b0ceb..d5e4508fe 100644
--- a/server/lib/job-queue/handlers/activitypub-cleaner.ts
+++ b/server/lib/job-queue/handlers/activitypub-cleaner.ts
@@ -1,5 +1,5 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import * as Bull from 'bull' 2import { Job } from 'bull'
3import { checkUrlsSameHost } from '@server/helpers/activitypub' 3import { checkUrlsSameHost } from '@server/helpers/activitypub'
4import { 4import {
5 isAnnounceActivityValid, 5 isAnnounceActivityValid,
@@ -18,14 +18,14 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat
18 18
19// Job to clean remote interactions off local videos 19// Job to clean remote interactions off local videos
20 20
21async function processActivityPubCleaner (_job: Bull.Job) { 21async function processActivityPubCleaner (_job: Job) {
22 logger.info('Processing ActivityPub cleaner.') 22 logger.info('Processing ActivityPub cleaner.')
23 23
24 { 24 {
25 const rateUrls = await AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos() 25 const rateUrls = await AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos()
26 const { bodyValidator, deleter, updater } = rateOptionsFactory() 26 const { bodyValidator, deleter, updater } = rateOptionsFactory()
27 27
28 await Bluebird.map(rateUrls, async rateUrl => { 28 await map(rateUrls, async rateUrl => {
29 try { 29 try {
30 const result = await updateObjectIfNeeded(rateUrl, bodyValidator, updater, deleter) 30 const result = await updateObjectIfNeeded(rateUrl, bodyValidator, updater, deleter)
31 31
@@ -44,7 +44,7 @@ async function processActivityPubCleaner (_job: Bull.Job) {
44 const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos() 44 const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos()
45 const { bodyValidator, deleter, updater } = shareOptionsFactory() 45 const { bodyValidator, deleter, updater } = shareOptionsFactory()
46 46
47 await Bluebird.map(shareUrls, async shareUrl => { 47 await map(shareUrls, async shareUrl => {
48 try { 48 try {
49 await updateObjectIfNeeded(shareUrl, bodyValidator, updater, deleter) 49 await updateObjectIfNeeded(shareUrl, bodyValidator, updater, deleter)
50 } catch (err) { 50 } catch (err) {
@@ -57,7 +57,7 @@ async function processActivityPubCleaner (_job: Bull.Job) {
57 const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos() 57 const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos()
58 const { bodyValidator, deleter, updater } = commentOptionsFactory() 58 const { bodyValidator, deleter, updater } = commentOptionsFactory()
59 59
60 await Bluebird.map(commentUrls, async commentUrl => { 60 await map(commentUrls, async commentUrl => {
61 try { 61 try {
62 await updateObjectIfNeeded(commentUrl, bodyValidator, updater, deleter) 62 await updateObjectIfNeeded(commentUrl, bodyValidator, updater, deleter)
63 } catch (err) { 63 } catch (err) {
diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts
index f896d7af4..91e3d33c6 100644
--- a/server/lib/job-queue/handlers/activitypub-follow.ts
+++ b/server/lib/job-queue/handlers/activitypub-follow.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url' 2import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url'
3import { ActivitypubFollowPayload } from '@shared/models' 3import { ActivitypubFollowPayload } from '@shared/models'
4import { sanitizeHost } from '../../../helpers/core-utils' 4import { sanitizeHost } from '../../../helpers/core-utils'
@@ -13,7 +13,7 @@ import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../activi
13import { sendFollow } from '../../activitypub/send' 13import { sendFollow } from '../../activitypub/send'
14import { Notifier } from '../../notifier' 14import { Notifier } from '../../notifier'
15 15
16async function processActivityPubFollow (job: Bull.Job) { 16async function processActivityPubFollow (job: Job) {
17 const payload = job.data as ActivitypubFollowPayload 17 const payload = job.data as ActivitypubFollowPayload
18 const host = payload.host 18 const host = payload.host
19 19
diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
index d4b328635..9b0bb6574 100644
--- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts
@@ -1,5 +1,5 @@
1import * as Bluebird from 'bluebird' 1import { map } from 'bluebird'
2import * as Bull from 'bull' 2import { Job } from 'bull'
3import { ActivitypubHttpBroadcastPayload } from '@shared/models' 3import { ActivitypubHttpBroadcastPayload } from '@shared/models'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { doRequest } from '../../../helpers/requests' 5import { doRequest } from '../../../helpers/requests'
@@ -7,7 +7,7 @@ import { BROADCAST_CONCURRENCY } from '../../../initializers/constants'
7import { ActorFollowScoreCache } from '../../files-cache' 7import { ActorFollowScoreCache } from '../../files-cache'
8import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' 8import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
9 9
10async function processActivityPubHttpBroadcast (job: Bull.Job) { 10async function processActivityPubHttpBroadcast (job: Job) {
11 logger.info('Processing ActivityPub broadcast in job %d.', job.id) 11 logger.info('Processing ActivityPub broadcast in job %d.', job.id)
12 12
13 const payload = job.data as ActivitypubHttpBroadcastPayload 13 const payload = job.data as ActivitypubHttpBroadcastPayload
@@ -25,7 +25,7 @@ async function processActivityPubHttpBroadcast (job: Bull.Job) {
25 const badUrls: string[] = [] 25 const badUrls: string[] = []
26 const goodUrls: string[] = [] 26 const goodUrls: string[] = []
27 27
28 await Bluebird.map(payload.uris, uri => { 28 await map(payload.uris, uri => {
29 return doRequest(uri, options) 29 return doRequest(uri, options)
30 .then(() => goodUrls.push(uri)) 30 .then(() => goodUrls.push(uri))
31 .catch(() => badUrls.push(uri)) 31 .catch(() => badUrls.push(uri))
diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
index ab9675cae..46016a0a7 100644
--- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' 2import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 4import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
@@ -13,7 +13,7 @@ import { addVideoShares } from '../../activitypub/share'
13import { addVideoComments } from '../../activitypub/video-comments' 13import { addVideoComments } from '../../activitypub/video-comments'
14import { createRates } from '../../activitypub/video-rates' 14import { createRates } from '../../activitypub/video-rates'
15 15
16async function processActivityPubHttpFetcher (job: Bull.Job) { 16async function processActivityPubHttpFetcher (job: Job) {
17 logger.info('Processing ActivityPub fetcher in job %d.', job.id) 17 logger.info('Processing ActivityPub fetcher in job %d.', job.id)
18 18
19 const payload = job.data as ActivitypubHttpFetcherPayload 19 const payload = job.data as ActivitypubHttpFetcherPayload
diff --git a/server/lib/job-queue/handlers/activitypub-http-unicast.ts b/server/lib/job-queue/handlers/activitypub-http-unicast.ts
index 9e561c6b7..9be50837f 100644
--- a/server/lib/job-queue/handlers/activitypub-http-unicast.ts
+++ b/server/lib/job-queue/handlers/activitypub-http-unicast.ts
@@ -1,11 +1,11 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { ActivitypubHttpUnicastPayload } from '@shared/models' 2import { ActivitypubHttpUnicastPayload } from '@shared/models'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { doRequest } from '../../../helpers/requests' 4import { doRequest } from '../../../helpers/requests'
5import { ActorFollowScoreCache } from '../../files-cache' 5import { ActorFollowScoreCache } from '../../files-cache'
6import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' 6import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils'
7 7
8async function processActivityPubHttpUnicast (job: Bull.Job) { 8async function processActivityPubHttpUnicast (job: Job) {
9 logger.info('Processing ActivityPub unicast in job %d.', job.id) 9 logger.info('Processing ActivityPub unicast in job %d.', job.id)
10 10
11 const payload = job.data as ActivitypubHttpUnicastPayload 11 const payload = job.data as ActivitypubHttpUnicastPayload
diff --git a/server/lib/job-queue/handlers/activitypub-refresher.ts b/server/lib/job-queue/handlers/activitypub-refresher.ts
index d97e50ebc..5037992d2 100644
--- a/server/lib/job-queue/handlers/activitypub-refresher.ts
+++ b/server/lib/job-queue/handlers/activitypub-refresher.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists' 2import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists'
3import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos' 3import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos'
4import { loadVideoByUrl } from '@server/lib/model-loaders' 4import { loadVideoByUrl } from '@server/lib/model-loaders'
@@ -8,7 +8,7 @@ import { ActorModel } from '../../../models/actor/actor'
8import { VideoPlaylistModel } from '../../../models/video/video-playlist' 8import { VideoPlaylistModel } from '../../../models/video/video-playlist'
9import { refreshActorIfNeeded } from '../../activitypub/actors' 9import { refreshActorIfNeeded } from '../../activitypub/actors'
10 10
11async function refreshAPObject (job: Bull.Job) { 11async function refreshAPObject (job: Job) {
12 const payload = job.data as RefreshPayload 12 const payload = job.data as RefreshPayload
13 13
14 logger.info('Processing AP refresher in job %d for %s.', job.id, payload.url) 14 logger.info('Processing AP refresher in job %d for %s.', job.id, payload.url)
diff --git a/server/lib/job-queue/handlers/actor-keys.ts b/server/lib/job-queue/handlers/actor-keys.ts
index 60ac61afd..9d5a65376 100644
--- a/server/lib/job-queue/handlers/actor-keys.ts
+++ b/server/lib/job-queue/handlers/actor-keys.ts
@@ -1,10 +1,10 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors' 2import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors'
3import { ActorModel } from '@server/models/actor/actor' 3import { ActorModel } from '@server/models/actor/actor'
4import { ActorKeysPayload } from '@shared/models' 4import { ActorKeysPayload } from '@shared/models'
5import { logger } from '../../../helpers/logger' 5import { logger } from '../../../helpers/logger'
6 6
7async function processActorKeys (job: Bull.Job) { 7async function processActorKeys (job: Job) {
8 const payload = job.data as ActorKeysPayload 8 const payload = job.data as ActorKeysPayload
9 logger.info('Processing actor keys in job %d.', job.id) 9 logger.info('Processing actor keys in job %d.', job.id)
10 10
diff --git a/server/lib/job-queue/handlers/email.ts b/server/lib/job-queue/handlers/email.ts
index 3157731e2..6fc1caa84 100644
--- a/server/lib/job-queue/handlers/email.ts
+++ b/server/lib/job-queue/handlers/email.ts
@@ -1,9 +1,9 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { EmailPayload } from '@shared/models'
2import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
3import { Emailer } from '../../emailer' 4import { Emailer } from '../../emailer'
4import { EmailPayload } from '@shared/models'
5 5
6async function processEmail (job: Bull.Job) { 6async function processEmail (job: Job) {
7 const payload = job.data as EmailPayload 7 const payload = job.data as EmailPayload
8 logger.info('Processing email in job %d.', job.id) 8 logger.info('Processing email in job %d.', job.id)
9 9
diff --git a/server/lib/job-queue/handlers/move-to-object-storage.ts b/server/lib/job-queue/handlers/move-to-object-storage.ts
index f3b8726eb..0bebc0fc2 100644
--- a/server/lib/job-queue/handlers/move-to-object-storage.ts
+++ b/server/lib/job-queue/handlers/move-to-object-storage.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { remove } from 'fs-extra' 2import { remove } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import { logger } from '@server/helpers/logger' 4import { logger } from '@server/helpers/logger'
@@ -12,7 +12,7 @@ import { VideoJobInfoModel } from '@server/models/video/video-job-info'
12import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' 12import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models'
13import { MoveObjectStoragePayload, VideoStorage } from '../../../../shared' 13import { MoveObjectStoragePayload, VideoStorage } from '../../../../shared'
14 14
15export async function processMoveToObjectStorage (job: Bull.Job) { 15export async function processMoveToObjectStorage (job: Job) {
16 const payload = job.data as MoveObjectStoragePayload 16 const payload = job.data as MoveObjectStoragePayload
17 logger.info('Moving video %s in job %d.', payload.videoUUID, job.id) 17 logger.info('Moving video %s in job %d.', payload.videoUUID, job.id)
18 18
diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts
index e8ee1f759..e6c918e6c 100644
--- a/server/lib/job-queue/handlers/video-file-import.ts
+++ b/server/lib/job-queue/handlers/video-file-import.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { copy, stat } from 'fs-extra' 2import { copy, stat } from 'fs-extra'
3import { getLowercaseExtension } from '@server/helpers/core-utils' 3import { getLowercaseExtension } from '@server/helpers/core-utils'
4import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' 4import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
@@ -16,7 +16,7 @@ import { VideoModel } from '../../../models/video/video'
16import { VideoFileModel } from '../../../models/video/video-file' 16import { VideoFileModel } from '../../../models/video/video-file'
17import { createHlsJobIfEnabled } from './video-transcoding' 17import { createHlsJobIfEnabled } from './video-transcoding'
18 18
19async function processVideoFileImport (job: Bull.Job) { 19async function processVideoFileImport (job: Job) {
20 const payload = job.data as VideoFileImportPayload 20 const payload = job.data as VideoFileImportPayload
21 logger.info('Processing video file import in job %d.', job.id) 21 logger.info('Processing video file import in job %d.', job.id)
22 22
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts
index a5fa204f5..bdbf07a06 100644
--- a/server/lib/job-queue/handlers/video-import.ts
+++ b/server/lib/job-queue/handlers/video-import.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { move, remove, stat } from 'fs-extra' 2import { move, remove, stat } from 'fs-extra'
3import { getLowercaseExtension } from '@server/helpers/core-utils' 3import { getLowercaseExtension } from '@server/helpers/core-utils'
4import { retryTransactionWrapper } from '@server/helpers/database-utils' 4import { retryTransactionWrapper } from '@server/helpers/database-utils'
@@ -37,7 +37,7 @@ import { federateVideoIfNeeded } from '../../activitypub/videos'
37import { Notifier } from '../../notifier' 37import { Notifier } from '../../notifier'
38import { generateVideoMiniature } from '../../thumbnail' 38import { generateVideoMiniature } from '../../thumbnail'
39 39
40async function processVideoImport (job: Bull.Job) { 40async function processVideoImport (job: Job) {
41 const payload = job.data as VideoImportPayload 41 const payload = job.data as VideoImportPayload
42 42
43 if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload) 43 if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload)
@@ -52,7 +52,7 @@ export {
52 52
53// --------------------------------------------------------------------------- 53// ---------------------------------------------------------------------------
54 54
55async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentPayload) { 55async function processTorrentImport (job: Job, payload: VideoImportTorrentPayload) {
56 logger.info('Processing torrent video import in job %d.', job.id) 56 logger.info('Processing torrent video import in job %d.', job.id)
57 57
58 const videoImport = await getVideoImportOrDie(payload.videoImportId) 58 const videoImport = await getVideoImportOrDie(payload.videoImportId)
@@ -68,7 +68,7 @@ async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentP
68 return processFile(() => downloadWebTorrentVideo(target, VIDEO_IMPORT_TIMEOUT), videoImport, options) 68 return processFile(() => downloadWebTorrentVideo(target, VIDEO_IMPORT_TIMEOUT), videoImport, options)
69} 69}
70 70
71async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutubeDLPayload) { 71async function processYoutubeDLImport (job: Job, payload: VideoImportYoutubeDLPayload) {
72 logger.info('Processing youtubeDL video import in job %d.', job.id) 72 logger.info('Processing youtubeDL video import in job %d.', job.id)
73 73
74 const videoImport = await getVideoImportOrDie(payload.videoImportId) 74 const videoImport = await getVideoImportOrDie(payload.videoImportId)
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts
index 9ccf724c2..a04cfa2c9 100644
--- a/server/lib/job-queue/handlers/video-live-ending.ts
+++ b/server/lib/job-queue/handlers/video-live-ending.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { pathExists, readdir, remove } from 'fs-extra' 2import { pathExists, readdir, remove } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils' 4import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils'
@@ -17,7 +17,7 @@ import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models'
17import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' 17import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models'
18import { logger } from '../../../helpers/logger' 18import { logger } from '../../../helpers/logger'
19 19
20async function processVideoLiveEnding (job: Bull.Job) { 20async function processVideoLiveEnding (job: Job) {
21 const payload = job.data as VideoLiveEndingPayload 21 const payload = job.data as VideoLiveEndingPayload
22 22
23 function logError () { 23 function logError () {
diff --git a/server/lib/job-queue/handlers/video-redundancy.ts b/server/lib/job-queue/handlers/video-redundancy.ts
index 6296dab05..9cb7a6589 100644
--- a/server/lib/job-queue/handlers/video-redundancy.ts
+++ b/server/lib/job-queue/handlers/video-redundancy.ts
@@ -1,9 +1,9 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { logger } from '../../../helpers/logger'
3import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler' 2import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler'
4import { VideoRedundancyPayload } from '@shared/models' 3import { VideoRedundancyPayload } from '@shared/models'
4import { logger } from '../../../helpers/logger'
5 5
6async function processVideoRedundancy (job: Bull.Job) { 6async function processVideoRedundancy (job: Job) {
7 const payload = job.data as VideoRedundancyPayload 7 const payload = job.data as VideoRedundancyPayload
8 logger.info('Processing video redundancy in job %d.', job.id) 8 logger.info('Processing video redundancy in job %d.', job.id)
9 9
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts
index 5a93c4ed1..20880cdc1 100644
--- a/server/lib/job-queue/handlers/video-transcoding.ts
+++ b/server/lib/job-queue/handlers/video-transcoding.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import { Job } from 'bull'
2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' 2import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils'
3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' 3import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video'
4import { VideoPathManager } from '@server/lib/video-path-manager' 4import { VideoPathManager } from '@server/lib/video-path-manager'
@@ -25,7 +25,7 @@ import {
25 transcodeNewWebTorrentResolution 25 transcodeNewWebTorrentResolution
26} from '../../transcoding/video-transcoding' 26} from '../../transcoding/video-transcoding'
27 27
28type HandlerFunction = (job: Bull.Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void> 28type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void>
29 29
30const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = { 30const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = {
31 'new-resolution-to-hls': handleHLSJob, 31 'new-resolution-to-hls': handleHLSJob,
@@ -36,7 +36,7 @@ const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } =
36 36
37const lTags = loggerTagsFactory('transcoding') 37const lTags = loggerTagsFactory('transcoding')
38 38
39async function processVideoTranscoding (job: Bull.Job) { 39async function processVideoTranscoding (job: Job) {
40 const payload = job.data as VideoTranscodingPayload 40 const payload = job.data as VideoTranscodingPayload
41 logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID)) 41 logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID))
42 42
@@ -64,7 +64,7 @@ async function processVideoTranscoding (job: Bull.Job) {
64// Job handlers 64// Job handlers
65// --------------------------------------------------------------------------- 65// ---------------------------------------------------------------------------
66 66
67async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) { 67async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) {
68 logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid)) 68 logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid))
69 69
70 const videoFileInput = payload.copyCodecs 70 const videoFileInput = payload.copyCodecs
@@ -90,7 +90,7 @@ async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, vide
90} 90}
91 91
92async function handleNewWebTorrentResolutionJob ( 92async function handleNewWebTorrentResolutionJob (
93 job: Bull.Job, 93 job: Job,
94 payload: NewResolutionTranscodingPayload, 94 payload: NewResolutionTranscodingPayload,
95 video: MVideoFullLight, 95 video: MVideoFullLight,
96 user: MUserId 96 user: MUserId
@@ -104,7 +104,7 @@ async function handleNewWebTorrentResolutionJob (
104 await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload) 104 await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload)
105} 105}
106 106
107async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { 107async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) {
108 logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid)) 108 logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid))
109 109
110 await mergeAudioVideofile(video, payload.resolution, job) 110 await mergeAudioVideofile(video, payload.resolution, job)
@@ -114,7 +114,7 @@ async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudio
114 await retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user) 114 await retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user)
115} 115}
116 116
117async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { 117async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) {
118 logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid)) 118 logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid))
119 119
120 const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job) 120 const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job)
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts
index 7a3a1bf82..4cda12b57 100644
--- a/server/lib/job-queue/job-queue.ts
+++ b/server/lib/job-queue/job-queue.ts
@@ -1,4 +1,4 @@
1import * as Bull from 'bull' 1import Bull, { Job, JobOptions, Queue } from 'bull'
2import { jobStates } from '@server/helpers/custom-validators/jobs' 2import { jobStates } from '@server/helpers/custom-validators/jobs'
3import { CONFIG } from '@server/initializers/config' 3import { CONFIG } from '@server/initializers/config'
4import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy' 4import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy'
@@ -30,12 +30,12 @@ import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unica
30import { refreshAPObject } from './handlers/activitypub-refresher' 30import { refreshAPObject } from './handlers/activitypub-refresher'
31import { processActorKeys } from './handlers/actor-keys' 31import { processActorKeys } from './handlers/actor-keys'
32import { processEmail } from './handlers/email' 32import { processEmail } from './handlers/email'
33import { processMoveToObjectStorage } from './handlers/move-to-object-storage'
33import { processVideoFileImport } from './handlers/video-file-import' 34import { processVideoFileImport } from './handlers/video-file-import'
34import { processVideoImport } from './handlers/video-import' 35import { processVideoImport } from './handlers/video-import'
35import { processVideoLiveEnding } from './handlers/video-live-ending' 36import { processVideoLiveEnding } from './handlers/video-live-ending'
36import { processVideoTranscoding } from './handlers/video-transcoding' 37import { processVideoTranscoding } from './handlers/video-transcoding'
37import { processVideosViews } from './handlers/video-views' 38import { processVideosViews } from './handlers/video-views'
38import { processMoveToObjectStorage } from './handlers/move-to-object-storage'
39 39
40type CreateJobArgument = 40type CreateJobArgument =
41 { type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } | 41 { type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } |
@@ -59,7 +59,7 @@ export type CreateJobOptions = {
59 priority?: number 59 priority?: number
60} 60}
61 61
62const handlers: { [id in JobType]: (job: Bull.Job) => Promise<any> } = { 62const handlers: { [id in JobType]: (job: Job) => Promise<any> } = {
63 'activitypub-http-broadcast': processActivityPubHttpBroadcast, 63 'activitypub-http-broadcast': processActivityPubHttpBroadcast,
64 'activitypub-http-unicast': processActivityPubHttpUnicast, 64 'activitypub-http-unicast': processActivityPubHttpUnicast,
65 'activitypub-http-fetcher': processActivityPubHttpFetcher, 65 'activitypub-http-fetcher': processActivityPubHttpFetcher,
@@ -99,7 +99,7 @@ class JobQueue {
99 99
100 private static instance: JobQueue 100 private static instance: JobQueue
101 101
102 private queues: { [id in JobType]?: Bull.Queue } = {} 102 private queues: { [id in JobType]?: Queue } = {}
103 private initialized = false 103 private initialized = false
104 private jobRedisPrefix: string 104 private jobRedisPrefix: string
105 105
@@ -160,7 +160,7 @@ class JobQueue {
160 return 160 return
161 } 161 }
162 162
163 const jobArgs: Bull.JobOptions = { 163 const jobArgs: JobOptions = {
164 backoff: { delay: 60 * 1000, type: 'exponential' }, 164 backoff: { delay: 60 * 1000, type: 'exponential' },
165 attempts: JOB_ATTEMPTS[obj.type], 165 attempts: JOB_ATTEMPTS[obj.type],
166 timeout: JOB_TTL[obj.type], 166 timeout: JOB_TTL[obj.type],
@@ -177,11 +177,11 @@ class JobQueue {
177 count: number 177 count: number
178 asc?: boolean 178 asc?: boolean
179 jobType: JobType 179 jobType: JobType
180 }): Promise<Bull.Job[]> { 180 }): Promise<Job[]> {
181 const { state, start, count, asc, jobType } = options 181 const { state, start, count, asc, jobType } = options
182 182
183 const states = state ? [ state ] : jobStates 183 const states = state ? [ state ] : jobStates
184 let results: Bull.Job[] = [] 184 let results: Job[] = []
185 185
186 const filteredJobTypes = this.filterJobTypes(jobType) 186 const filteredJobTypes = this.filterJobTypes(jobType)
187 187
diff --git a/server/lib/live/shared/muxing-session.ts b/server/lib/live/shared/muxing-session.ts
index 0c9fb0cb6..a6907142d 100644
--- a/server/lib/live/shared/muxing-session.ts
+++ b/server/lib/live/shared/muxing-session.ts
@@ -1,6 +1,6 @@
1 1
2import * as Bluebird from 'bluebird' 2import { mapSeries } from 'bluebird'
3import * as chokidar from 'chokidar' 3import { FSWatcher, watch } from 'chokidar'
4import { FfmpegCommand } from 'fluent-ffmpeg' 4import { FfmpegCommand } from 'fluent-ffmpeg'
5import { appendFile, ensureDir, readFile, stat } from 'fs-extra' 5import { appendFile, ensureDir, readFile, stat } from 'fs-extra'
6import { basename, join } from 'path' 6import { basename, join } from 'path'
@@ -67,8 +67,8 @@ class MuxingSession extends EventEmitter {
67 67
68 private segmentsToProcessPerPlaylist: { [playlistId: string]: string[] } = {} 68 private segmentsToProcessPerPlaylist: { [playlistId: string]: string[] } = {}
69 69
70 private tsWatcher: chokidar.FSWatcher 70 private tsWatcher: FSWatcher
71 private masterWatcher: chokidar.FSWatcher 71 private masterWatcher: FSWatcher
72 72
73 private readonly isAbleToUploadVideoWithCache = memoizee((userId: number) => { 73 private readonly isAbleToUploadVideoWithCache = memoizee((userId: number) => {
74 return isAbleToUploadVideo(userId, 1000) 74 return isAbleToUploadVideo(userId, 1000)
@@ -197,7 +197,7 @@ class MuxingSession extends EventEmitter {
197 } 197 }
198 198
199 private watchMasterFile (outPath: string) { 199 private watchMasterFile (outPath: string) {
200 this.masterWatcher = chokidar.watch(outPath + '/' + this.streamingPlaylist.playlistFilename) 200 this.masterWatcher = watch(outPath + '/' + this.streamingPlaylist.playlistFilename)
201 201
202 this.masterWatcher.on('add', () => { 202 this.masterWatcher.on('add', () => {
203 this.emit('master-playlist-created', { videoId: this.videoId }) 203 this.emit('master-playlist-created', { videoId: this.videoId })
@@ -210,7 +210,7 @@ class MuxingSession extends EventEmitter {
210 private watchTSFiles (outPath: string) { 210 private watchTSFiles (outPath: string) {
211 const startStreamDateTime = new Date().getTime() 211 const startStreamDateTime = new Date().getTime()
212 212
213 this.tsWatcher = chokidar.watch(outPath + '/*.ts') 213 this.tsWatcher = watch(outPath + '/*.ts')
214 214
215 const playlistIdMatcher = /^([\d+])-/ 215 const playlistIdMatcher = /^([\d+])-/
216 216
@@ -306,7 +306,7 @@ class MuxingSession extends EventEmitter {
306 } 306 }
307 307
308 private processSegments (hlsVideoPath: string, segmentPaths: string[]) { 308 private processSegments (hlsVideoPath: string, segmentPaths: string[]) {
309 Bluebird.mapSeries(segmentPaths, async previousSegment => { 309 mapSeries(segmentPaths, async previousSegment => {
310 // Add sha hash of previous segments, because ffmpeg should have finished generating them 310 // Add sha hash of previous segments, because ffmpeg should have finished generating them
311 await LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment) 311 await LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment)
312 312
diff --git a/server/lib/local-actor.ts b/server/lib/local-actor.ts
index 77667f6b0..821a92b91 100644
--- a/server/lib/local-actor.ts
+++ b/server/lib/local-actor.ts
@@ -1,6 +1,6 @@
1import 'multer' 1import 'multer'
2import { queue } from 'async' 2import { queue } from 'async'
3import * as LRUCache from 'lru-cache' 3import LRUCache from 'lru-cache'
4import { join } from 'path' 4import { join } from 'path'
5import { getLowercaseExtension } from '@server/helpers/core-utils' 5import { getLowercaseExtension } from '@server/helpers/core-utils'
6import { buildUUID } from '@server/helpers/uuid' 6import { buildUUID } from '@server/helpers/uuid'
diff --git a/server/lib/peertube-socket.ts b/server/lib/peertube-socket.ts
index 0740e378e..901435dea 100644
--- a/server/lib/peertube-socket.ts
+++ b/server/lib/peertube-socket.ts
@@ -1,23 +1,23 @@
1import { Server } from 'http' 1import { Server as HTTPServer } from 'http'
2import * as SocketIO from 'socket.io' 2import { Namespace, Server as SocketServer, Socket } from 'socket.io'
3import { isIdValid } from '@server/helpers/custom-validators/misc'
3import { MVideo } from '@server/types/models' 4import { MVideo } from '@server/types/models'
4import { UserNotificationModelForApi } from '@server/types/models/user' 5import { UserNotificationModelForApi } from '@server/types/models/user'
5import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' 6import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models'
6import { logger } from '../helpers/logger' 7import { logger } from '../helpers/logger'
7import { authenticateSocket } from '../middlewares' 8import { authenticateSocket } from '../middlewares'
8import { isIdValid } from '@server/helpers/custom-validators/misc'
9 9
10class PeerTubeSocket { 10class PeerTubeSocket {
11 11
12 private static instance: PeerTubeSocket 12 private static instance: PeerTubeSocket
13 13
14 private userNotificationSockets: { [ userId: number ]: SocketIO.Socket[] } = {} 14 private userNotificationSockets: { [ userId: number ]: Socket[] } = {}
15 private liveVideosNamespace: SocketIO.Namespace 15 private liveVideosNamespace: Namespace
16 16
17 private constructor () {} 17 private constructor () {}
18 18
19 init (server: Server) { 19 init (server: HTTPServer) {
20 const io = new SocketIO.Server(server) 20 const io = new SocketServer(server)
21 21
22 io.of('/user-notifications') 22 io.of('/user-notifications')
23 .use(authenticateSocket) 23 .use(authenticateSocket)
diff --git a/server/lib/plugins/hooks.ts b/server/lib/plugins/hooks.ts
index 5e97b52a0..327aaece2 100644
--- a/server/lib/plugins/hooks.ts
+++ b/server/lib/plugins/hooks.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import Bluebird from 'bluebird'
2import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models' 2import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { PluginManager } from './plugin-manager' 4import { PluginManager } from './plugin-manager'
diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.ts
index 8487672ba..e26776f45 100644
--- a/server/lib/plugins/plugin-helpers-builder.ts
+++ b/server/lib/plugins/plugin-helpers-builder.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { join } from 'path' 2import { join } from 'path'
3import { buildLogger } from '@server/helpers/logger' 3import { buildLogger } from '@server/helpers/logger'
4import { CONFIG } from '@server/initializers/config' 4import { CONFIG } from '@server/initializers/config'
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index 6599bccca..d4d2a7edc 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -1,5 +1,5 @@
1import decache from 'decache' 1import decache from 'decache'
2import * as express from 'express' 2import express from 'express'
3import { createReadStream, createWriteStream } from 'fs' 3import { createReadStream, createWriteStream } from 'fs'
4import { ensureDir, outputFile, readJSON } from 'fs-extra' 4import { ensureDir, outputFile, readJSON } from 'fs-extra'
5import { basename, join } from 'path' 5import { basename, join } from 'path'
diff --git a/server/lib/plugins/register-helpers.ts b/server/lib/plugins/register-helpers.ts
index af533effd..acca9309a 100644
--- a/server/lib/plugins/register-helpers.ts
+++ b/server/lib/plugins/register-helpers.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { logger } from '@server/helpers/logger' 2import { logger } from '@server/helpers/logger'
3import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth' 3import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth'
4import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory' 4import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory'
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index 62641e313..d1d88d853 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { createClient, RedisClient } from 'redis' 2import { createClient, RedisClient } from 'redis'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4import { generateRandomString } from '../helpers/utils' 4import { generateRandomString } from '../helpers/utils'
diff --git a/server/lib/schedulers/abstract-scheduler.ts b/server/lib/schedulers/abstract-scheduler.ts
index 0e6088911..f3d51a22e 100644
--- a/server/lib/schedulers/abstract-scheduler.ts
+++ b/server/lib/schedulers/abstract-scheduler.ts
@@ -1,5 +1,5 @@
1import Bluebird from 'bluebird'
1import { logger } from '../../helpers/logger' 2import { logger } from '../../helpers/logger'
2import * as Bluebird from 'bluebird'
3 3
4export abstract class AbstractScheduler { 4export abstract class AbstractScheduler {
5 5
diff --git a/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts b/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts
index 1acea7998..099fa5651 100644
--- a/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts
+++ b/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts
@@ -1,4 +1,4 @@
1import * as bluebird from 'bluebird' 1import { map } from 'bluebird'
2import { readdir, remove, stat } from 'fs-extra' 2import { readdir, remove, stat } from 'fs-extra'
3import { logger, loggerTagsFactory } from '@server/helpers/logger' 3import { logger, loggerTagsFactory } from '@server/helpers/logger'
4import { getResumableUploadPath } from '@server/helpers/upload' 4import { getResumableUploadPath } from '@server/helpers/upload'
@@ -32,7 +32,7 @@ export class RemoveDanglingResumableUploadsScheduler extends AbstractScheduler {
32 logger.debug('Reading resumable video upload folder %s with %d files', path, metafiles.length, lTags()) 32 logger.debug('Reading resumable video upload folder %s with %d files', path, metafiles.length, lTags())
33 33
34 try { 34 try {
35 await bluebird.map(metafiles, metafile => { 35 await map(metafiles, metafile => {
36 return this.deleteIfOlderThan(metafile, this.lastExecutionTimeMs) 36 return this.deleteIfOlderThan(metafile, this.lastExecutionTimeMs)
37 }, { concurrency: 5 }) 37 }, { concurrency: 5 })
38 } catch (error) { 38 } catch (error) {
diff --git a/server/lib/search.ts b/server/lib/search.ts
index b643a4055..2f4c5eed9 100644
--- a/server/lib/search.ts
+++ b/server/lib/search.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { CONFIG } from '@server/initializers/config' 2import { CONFIG } from '@server/initializers/config'
3import { AccountBlocklistModel } from '@server/models/account/account-blocklist' 3import { AccountBlocklistModel } from '@server/models/account/account-blocklist'
4import { getServerActor } from '@server/models/application/application' 4import { getServerActor } from '@server/models/application/application'
diff --git a/server/lib/signup.ts b/server/lib/signup.ts
index 8fa81e601..3c1397a12 100644
--- a/server/lib/signup.ts
+++ b/server/lib/signup.ts
@@ -1,6 +1,6 @@
1import { UserModel } from '../models/user/user' 1import { IPv4, IPv6, parse, subnetMatch } from 'ipaddr.js'
2import * as ipaddr from 'ipaddr.js'
3import { CONFIG } from '../initializers/config' 2import { CONFIG } from '../initializers/config'
3import { UserModel } from '../models/user/user'
4 4
5const isCidr = require('is-cidr') 5const isCidr = require('is-cidr')
6 6
@@ -22,7 +22,7 @@ async function isSignupAllowed (): Promise<{ allowed: boolean, errorMessage?: st
22function isSignupAllowedForCurrentIP (ip: string) { 22function isSignupAllowedForCurrentIP (ip: string) {
23 if (!ip) return false 23 if (!ip) return false
24 24
25 const addr = ipaddr.parse(ip) 25 const addr = parse(ip)
26 const excludeList = [ 'blacklist' ] 26 const excludeList = [ 'blacklist' ]
27 let matched = '' 27 let matched = ''
28 28
@@ -32,23 +32,23 @@ function isSignupAllowedForCurrentIP (ip: string) {
32 } 32 }
33 33
34 if (addr.kind() === 'ipv4') { 34 if (addr.kind() === 'ipv4') {
35 const addrV4 = ipaddr.IPv4.parse(ip) 35 const addrV4 = IPv4.parse(ip)
36 const rangeList = { 36 const rangeList = {
37 whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v4(cidr)) 37 whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v4(cidr))
38 .map(cidr => ipaddr.IPv4.parseCIDR(cidr)), 38 .map(cidr => IPv4.parseCIDR(cidr)),
39 blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v4(cidr)) 39 blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v4(cidr))
40 .map(cidr => ipaddr.IPv4.parseCIDR(cidr)) 40 .map(cidr => IPv4.parseCIDR(cidr))
41 } 41 }
42 matched = ipaddr.subnetMatch(addrV4, rangeList, 'unknown') 42 matched = subnetMatch(addrV4, rangeList, 'unknown')
43 } else if (addr.kind() === 'ipv6') { 43 } else if (addr.kind() === 'ipv6') {
44 const addrV6 = ipaddr.IPv6.parse(ip) 44 const addrV6 = IPv6.parse(ip)
45 const rangeList = { 45 const rangeList = {
46 whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v6(cidr)) 46 whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v6(cidr))
47 .map(cidr => ipaddr.IPv6.parseCIDR(cidr)), 47 .map(cidr => IPv6.parseCIDR(cidr)),
48 blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v6(cidr)) 48 blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v6(cidr))
49 .map(cidr => ipaddr.IPv6.parseCIDR(cidr)) 49 .map(cidr => IPv6.parseCIDR(cidr))
50 } 50 }
51 matched = ipaddr.subnetMatch(addrV6, rangeList, 'unknown') 51 matched = subnetMatch(addrV6, rangeList, 'unknown')
52 } 52 }
53 53
54 return !excludeList.includes(matched) 54 return !excludeList.includes(matched)
diff --git a/server/lib/stat-manager.ts b/server/lib/stat-manager.ts
index 3c5e0a93e..03063793d 100644
--- a/server/lib/stat-manager.ts
+++ b/server/lib/stat-manager.ts
@@ -1,14 +1,14 @@
1import { mapSeries } from 'bluebird'
1import { CONFIG } from '@server/initializers/config' 2import { CONFIG } from '@server/initializers/config'
2import { UserModel } from '@server/models/user/user'
3import { ActorFollowModel } from '@server/models/actor/actor-follow' 3import { ActorFollowModel } from '@server/models/actor/actor-follow'
4import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' 4import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
5import { UserModel } from '@server/models/user/user'
5import { VideoModel } from '@server/models/video/video' 6import { VideoModel } from '@server/models/video/video'
6import { VideoChannelModel } from '@server/models/video/video-channel' 7import { VideoChannelModel } from '@server/models/video/video-channel'
7import { VideoCommentModel } from '@server/models/video/video-comment' 8import { VideoCommentModel } from '@server/models/video/video-comment'
8import { VideoFileModel } from '@server/models/video/video-file' 9import { VideoFileModel } from '@server/models/video/video-file'
9import { VideoPlaylistModel } from '@server/models/video/video-playlist' 10import { VideoPlaylistModel } from '@server/models/video/video-playlist'
10import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models' 11import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models'
11import * as Bluebird from 'bluebird'
12 12
13class StatsManager { 13class StatsManager {
14 14
@@ -107,7 +107,7 @@ class StatsManager {
107 107
108 strategies.push({ strategy: 'manual', size: null }) 108 strategies.push({ strategy: 'manual', size: null })
109 109
110 return Bluebird.mapSeries(strategies, r => { 110 return mapSeries(strategies, r => {
111 return VideoRedundancyModel.getStats(r.strategy) 111 return VideoRedundancyModel.getStats(r.strategy)
112 .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size })) 112 .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size }))
113 }) 113 })
diff --git a/server/middlewares/auth.ts b/server/middlewares/auth.ts
index 9e6327b23..c5424be97 100644
--- a/server/middlewares/auth.ts
+++ b/server/middlewares/auth.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { Socket } from 'socket.io' 2import { Socket } from 'socket.io'
3import { getAccessToken } from '@server/lib/auth/oauth-model' 3import { getAccessToken } from '@server/lib/auth/oauth-model'
4import { HttpStatusCode } from '../../shared/models/http/http-error-codes' 4import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
diff --git a/server/middlewares/cache/shared/api-cache.ts b/server/middlewares/cache/shared/api-cache.ts
index f9f7b1b67..f8846dcfc 100644
--- a/server/middlewares/cache/shared/api-cache.ts
+++ b/server/middlewares/cache/shared/api-cache.ts
@@ -1,7 +1,7 @@
1// Thanks: https://github.com/kwhitley/apicache 1// Thanks: https://github.com/kwhitley/apicache
2// We duplicated the library because it is unmaintened and prevent us to upgrade to recent NodeJS versions 2// We duplicated the library because it is unmaintened and prevent us to upgrade to recent NodeJS versions
3 3
4import * as express from 'express' 4import express from 'express'
5import { OutgoingHttpHeaders } from 'http' 5import { OutgoingHttpHeaders } from 'http'
6import { isTestInstance, parseDurationToMs } from '@server/helpers/core-utils' 6import { isTestInstance, parseDurationToMs } from '@server/helpers/core-utils'
7import { logger } from '@server/helpers/logger' 7import { logger } from '@server/helpers/logger'
diff --git a/server/middlewares/csp.ts b/server/middlewares/csp.ts
index 0ee44bf47..e2a75a17e 100644
--- a/server/middlewares/csp.ts
+++ b/server/middlewares/csp.ts
@@ -1,4 +1,4 @@
1import * as helmet from 'helmet' 1import { contentSecurityPolicy } from 'helmet'
2import { CONFIG } from '../initializers/config' 2import { CONFIG } from '../initializers/config'
3 3
4const baseDirectives = Object.assign({}, 4const baseDirectives = Object.assign({},
@@ -22,12 +22,12 @@ const baseDirectives = Object.assign({},
22 CONFIG.WEBSERVER.SCHEME === 'https' ? { upgradeInsecureRequests: [] } : {} 22 CONFIG.WEBSERVER.SCHEME === 'https' ? { upgradeInsecureRequests: [] } : {}
23) 23)
24 24
25const baseCSP = helmet.contentSecurityPolicy({ 25const baseCSP = contentSecurityPolicy({
26 directives: baseDirectives, 26 directives: baseDirectives,
27 reportOnly: CONFIG.CSP.REPORT_ONLY 27 reportOnly: CONFIG.CSP.REPORT_ONLY
28}) 28})
29 29
30const embedCSP = helmet.contentSecurityPolicy({ 30const embedCSP = contentSecurityPolicy({
31 directives: Object.assign({}, baseDirectives, { frameAncestors: [ '*' ] }), 31 directives: Object.assign({}, baseDirectives, { frameAncestors: [ '*' ] }),
32 reportOnly: CONFIG.CSP.REPORT_ONLY 32 reportOnly: CONFIG.CSP.REPORT_ONLY
33}) 33})
diff --git a/server/middlewares/doc.ts b/server/middlewares/doc.ts
index 3db85c68d..eef76acaa 100644
--- a/server/middlewares/doc.ts
+++ b/server/middlewares/doc.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2 2
3function openapiOperationDoc (options: { 3function openapiOperationDoc (options: {
4 url?: string 4 url?: string
diff --git a/server/middlewares/error.ts b/server/middlewares/error.ts
index af5a9c29a..6c52ce7bd 100644
--- a/server/middlewares/error.ts
+++ b/server/middlewares/error.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details' 2import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details'
3import { HttpStatusCode } from '@shared/models' 3import { HttpStatusCode } from '@shared/models'
4 4
diff --git a/server/middlewares/pagination.ts b/server/middlewares/pagination.ts
index b59717d7b..9812af9e4 100644
--- a/server/middlewares/pagination.ts
+++ b/server/middlewares/pagination.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { PAGINATION } from '../initializers/constants' 2import { PAGINATION } from '../initializers/constants'
3 3
4function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) { 4function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
diff --git a/server/middlewares/servers.ts b/server/middlewares/servers.ts
index cf70d901e..ebfa03e6c 100644
--- a/server/middlewares/servers.ts
+++ b/server/middlewares/servers.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { HttpStatusCode } from '../../shared/models/http/http-error-codes' 2import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
3import { getHostWithPort } from '../helpers/express-utils' 3import { getHostWithPort } from '../helpers/express-utils'
4 4
diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts
index 0600ccd15..458895898 100644
--- a/server/middlewares/sort.ts
+++ b/server/middlewares/sort.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { SortType } from '../models/utils' 2import { SortType } from '../models/utils'
3 3
4const setDefaultSort = setDefaultSortFactory('-createdAt') 4const setDefaultSort = setDefaultSortFactory('-createdAt')
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts
index c8c694f05..ea95b16c2 100644
--- a/server/middlewares/user-right.ts
+++ b/server/middlewares/user-right.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { UserRight } from '../../shared' 2import { UserRight } from '../../shared'
3import { HttpStatusCode } from '../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
4import { logger } from '../helpers/logger' 4import { logger } from '../helpers/logger'
diff --git a/server/middlewares/validators/abuse.ts b/server/middlewares/validators/abuse.ts
index f4d9c3af2..22f66c8cf 100644
--- a/server/middlewares/validators/abuse.ts
+++ b/server/middlewares/validators/abuse.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { 3import {
4 areAbusePredefinedReasonsValid, 4 areAbusePredefinedReasonsValid,
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts
index 599eb10bb..e529c831d 100644
--- a/server/middlewares/validators/account.ts
+++ b/server/middlewares/validators/account.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { param } from 'express-validator' 2import { param } from 'express-validator'
3import { isAccountNameValid } from '../../helpers/custom-validators/accounts' 3import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts
index d24e4427b..e296b8be7 100644
--- a/server/middlewares/validators/activitypub/activity.ts
+++ b/server/middlewares/validators/activitypub/activity.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { getServerActor } from '@server/models/application/application' 2import { getServerActor } from '@server/models/application/application'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' 4import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity'
diff --git a/server/middlewares/validators/activitypub/pagination.ts b/server/middlewares/validators/activitypub/pagination.ts
index c8ec34eb6..c542d4173 100644
--- a/server/middlewares/validators/activitypub/pagination.ts
+++ b/server/middlewares/validators/activitypub/pagination.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { query } from 'express-validator' 2import { query } from 'express-validator'
3import { PAGINATION } from '@server/initializers/constants' 3import { PAGINATION } from '@server/initializers/constants'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
diff --git a/server/middlewares/validators/activitypub/signature.ts b/server/middlewares/validators/activitypub/signature.ts
index f2f7d5848..642bcefe0 100644
--- a/server/middlewares/validators/activitypub/signature.ts
+++ b/server/middlewares/validators/activitypub/signature.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { 3import {
4 isSignatureCreatorValid, 4 isSignatureCreatorValid,
diff --git a/server/middlewares/validators/actor-image.ts b/server/middlewares/validators/actor-image.ts
index 49daadd61..c7e9f391c 100644
--- a/server/middlewares/validators/actor-image.ts
+++ b/server/middlewares/validators/actor-image.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { isActorImageFile } from '@server/helpers/custom-validators/actor-images' 3import { isActorImageFile } from '@server/helpers/custom-validators/actor-images'
4import { cleanUpReqFiles } from '../../helpers/express-utils' 4import { cleanUpReqFiles } from '../../helpers/express-utils'
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts
index f15b293e9..b7749e204 100644
--- a/server/middlewares/validators/blocklist.ts
+++ b/server/middlewares/validators/blocklist.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param } from 'express-validator' 2import { body, param } from 'express-validator'
3import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
diff --git a/server/middlewares/validators/bulk.ts b/server/middlewares/validators/bulk.ts
index 6fec58149..1cfc7481e 100644
--- a/server/middlewares/validators/bulk.ts
+++ b/server/middlewares/validators/bulk.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk' 3import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk'
4import { HttpStatusCode, UserRight } from '@shared/models' 4import { HttpStatusCode, UserRight } from '@shared/models'
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index 1aeadbe65..16a840667 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { isIntOrNull } from '@server/helpers/custom-validators/misc' 3import { isIntOrNull } from '@server/helpers/custom-validators/misc'
4import { isEmailEnabled } from '@server/initializers/config' 4import { isEmailEnabled } from '@server/initializers/config'
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts
index d29bebf64..f8ebaf6ed 100644
--- a/server/middlewares/validators/feeds.ts
+++ b/server/middlewares/validators/feeds.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { param, query } from 'express-validator' 2import { param, query } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' 4import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts
index 16abdd096..df4cefe28 100644
--- a/server/middlewares/validators/follows.ts
+++ b/server/middlewares/validators/follows.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { isEachUniqueHandleValid, isFollowStateValid, isRemoteHandleValid } from '@server/helpers/custom-validators/follows' 3import { isEachUniqueHandleValid, isFollowStateValid, isRemoteHandleValid } from '@server/helpers/custom-validators/follows'
4import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors' 4import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors'
diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.ts
index 5d89d167f..4de90548b 100644
--- a/server/middlewares/validators/jobs.ts
+++ b/server/middlewares/validators/jobs.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { param, query } from 'express-validator' 2import { param, query } from 'express-validator'
3import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs' 3import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs'
4import { logger, loggerTagsFactory } from '../../helpers/logger' 4import { logger, loggerTagsFactory } from '../../helpers/logger'
diff --git a/server/middlewares/validators/logs.ts b/server/middlewares/validators/logs.ts
index c55baaee3..03c1c4df1 100644
--- a/server/middlewares/validators/logs.ts
+++ b/server/middlewares/validators/logs.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { query } from 'express-validator' 2import { query } from 'express-validator'
3import { isValidLogLevel } from '../../helpers/custom-validators/logs' 3import { isValidLogLevel } from '../../helpers/custom-validators/logs'
4import { isDateValid } from '../../helpers/custom-validators/misc' 4import { isDateValid } from '../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts
index e5fc0c277..5e47211b5 100644
--- a/server/middlewares/validators/oembed.ts
+++ b/server/middlewares/validators/oembed.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { query } from 'express-validator' 2import { query } from 'express-validator'
3import { join } from 'path' 3import { join } from 'path'
4import { loadVideo } from '@server/lib/model-loaders' 4import { loadVideo } from '@server/lib/model-loaders'
diff --git a/server/middlewares/validators/pagination.ts b/server/middlewares/validators/pagination.ts
index 74eae251e..8e4922b9d 100644
--- a/server/middlewares/validators/pagination.ts
+++ b/server/middlewares/validators/pagination.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { query } from 'express-validator' 2import { query } from 'express-validator'
3import { PAGINATION } from '@server/initializers/constants' 3import { PAGINATION } from '@server/initializers/constants'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index 3fb2176b9..21171af23 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param, query, ValidationChain } from 'express-validator' 2import { body, param, query, ValidationChain } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { PluginType } from '../../../shared/models/plugins/plugin.type' 4import { PluginType } from '../../../shared/models/plugins/plugin.type'
diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.ts
index f1b2ff5cd..d31b216f5 100644
--- a/server/middlewares/validators/redundancy.ts
+++ b/server/middlewares/validators/redundancy.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies' 3import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies'
4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.ts
index 27d0e541d..e6ec8642a 100644
--- a/server/middlewares/validators/search.ts
+++ b/server/middlewares/validators/search.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { query } from 'express-validator' 2import { query } from 'express-validator'
3import { isSearchTargetValid } from '@server/helpers/custom-validators/search' 3import { isSearchTargetValid } from '@server/helpers/custom-validators/search'
4import { isHostValid } from '@server/helpers/custom-validators/servers' 4import { isHostValid } from '@server/helpers/custom-validators/servers'
diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts
index 29fdc13d2..10bbefe38 100644
--- a/server/middlewares/validators/server.ts
+++ b/server/middlewares/validators/server.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers' 4import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers'
diff --git a/server/middlewares/validators/shared/utils.ts b/server/middlewares/validators/shared/utils.ts
index 4f08560af..5c66ad500 100644
--- a/server/middlewares/validators/shared/utils.ts
+++ b/server/middlewares/validators/shared/utils.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { param, query, validationResult } from 'express-validator' 2import { param, query, validationResult } from 'express-validator'
3import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' 3import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
diff --git a/server/middlewares/validators/shared/video-channels.ts b/server/middlewares/validators/shared/video-channels.ts
index 3fc3d012a..7c0c89267 100644
--- a/server/middlewares/validators/shared/video-channels.ts
+++ b/server/middlewares/validators/shared/video-channels.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { VideoChannelModel } from '@server/models/video/video-channel' 2import { VideoChannelModel } from '@server/models/video/video-channel'
3import { MChannelBannerAccountDefault } from '@server/types/models' 3import { MChannelBannerAccountDefault } from '@server/types/models'
4import { HttpStatusCode } from '@shared/models' 4import { HttpStatusCode } from '@shared/models'
diff --git a/server/middlewares/validators/shared/video-comments.ts b/server/middlewares/validators/shared/video-comments.ts
index 60132fb6e..386ae911f 100644
--- a/server/middlewares/validators/shared/video-comments.ts
+++ b/server/middlewares/validators/shared/video-comments.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { VideoCommentModel } from '@server/models/video/video-comment' 2import { VideoCommentModel } from '@server/models/video/video-comment'
3import { MVideoId } from '@server/types/models' 3import { MVideoId } from '@server/types/models'
4import { HttpStatusCode } from '@shared/models' 4import { HttpStatusCode } from '@shared/models'
diff --git a/server/middlewares/validators/shared/video-imports.ts b/server/middlewares/validators/shared/video-imports.ts
index 50b49ffcb..69fda4b32 100644
--- a/server/middlewares/validators/shared/video-imports.ts
+++ b/server/middlewares/validators/shared/video-imports.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { VideoImportModel } from '@server/models/video/video-import' 2import { VideoImportModel } from '@server/models/video/video-import'
3import { HttpStatusCode } from '@shared/models' 3import { HttpStatusCode } from '@shared/models'
4 4
diff --git a/server/middlewares/validators/shared/video-ownerships.ts b/server/middlewares/validators/shared/video-ownerships.ts
index 93a23ef40..680613cda 100644
--- a/server/middlewares/validators/shared/video-ownerships.ts
+++ b/server/middlewares/validators/shared/video-ownerships.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' 2import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'
3import { HttpStatusCode } from '@shared/models' 3import { HttpStatusCode } from '@shared/models'
4 4
diff --git a/server/middlewares/validators/shared/video-playlists.ts b/server/middlewares/validators/shared/video-playlists.ts
index 3f6768179..4342fe552 100644
--- a/server/middlewares/validators/shared/video-playlists.ts
+++ b/server/middlewares/validators/shared/video-playlists.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { VideoPlaylistModel } from '@server/models/video/video-playlist' 2import { VideoPlaylistModel } from '@server/models/video/video-playlist'
3import { MVideoPlaylist } from '@server/types/models' 3import { MVideoPlaylist } from '@server/types/models'
4import { HttpStatusCode } from '@shared/models' 4import { HttpStatusCode } from '@shared/models'
diff --git a/server/middlewares/validators/themes.ts b/server/middlewares/validators/themes.ts
index 2953b9505..7b9fee858 100644
--- a/server/middlewares/validators/themes.ts
+++ b/server/middlewares/validators/themes.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { param } from 'express-validator' 2import { param } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { isSafePath } from '../../helpers/custom-validators/misc' 4import { isSafePath } from '../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/user-history.ts b/server/middlewares/validators/user-history.ts
index 1db0d9b26..f9be26627 100644
--- a/server/middlewares/validators/user-history.ts
+++ b/server/middlewares/validators/user-history.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, query } from 'express-validator' 2import { body, query } from 'express-validator'
3import { exists, isDateValid } from '../../helpers/custom-validators/misc' 3import { exists, isDateValid } from '../../helpers/custom-validators/misc'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/user-notifications.ts b/server/middlewares/validators/user-notifications.ts
index 2f8e7686e..4a7577d32 100644
--- a/server/middlewares/validators/user-notifications.ts
+++ b/server/middlewares/validators/user-notifications.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, query } from 'express-validator' 2import { body, query } from 'express-validator'
3import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc' 3import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc'
4import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' 4import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts
index df5777771..48ce90d7b 100644
--- a/server/middlewares/validators/user-subscriptions.ts
+++ b/server/middlewares/validators/user-subscriptions.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' 4import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index c6977fcd9..c06b85862 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { omit } from 'lodash' 3import { omit } from 'lodash'
4import { Hooks } from '@server/lib/plugins/hooks' 4import { Hooks } from '@server/lib/plugins/hooks'
diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts
index 3a4937b7b..de11e69f2 100644
--- a/server/middlewares/validators/videos/video-blacklist.ts
+++ b/server/middlewares/validators/videos/video-blacklist.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, query } from 'express-validator' 2import { body, query } from 'express-validator'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' 4import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/videos/video-captions.ts b/server/middlewares/validators/videos/video-captions.ts
index 6bc127e01..38321ccf9 100644
--- a/server/middlewares/validators/videos/video-captions.ts
+++ b/server/middlewares/validators/videos/video-captions.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param } from 'express-validator' 2import { body, param } from 'express-validator'
3import { UserRight } from '../../../../shared' 3import { UserRight } from '../../../../shared'
4import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions' 4import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions'
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts
index 3b5693d23..fc717abf6 100644
--- a/server/middlewares/validators/videos/video-channels.ts
+++ b/server/middlewares/validators/videos/video-channels.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { VIDEO_CHANNELS } from '@server/initializers/constants' 3import { VIDEO_CHANNELS } from '@server/initializers/constants'
4import { MChannelAccountDefault, MUser } from '@server/types/models' 4import { MChannelAccountDefault, MUser } from '@server/types/models'
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index 61c2ed92f..3ea8bdcbb 100644
--- a/server/middlewares/validators/videos/video-comments.ts
+++ b/server/middlewares/validators/videos/video-comments.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { MUserAccountUrl } from '@server/types/models' 3import { MUserAccountUrl } from '@server/types/models'
4import { UserRight } from '../../../../shared' 4import { UserRight } from '../../../../shared'
diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts
index 52b839e56..640139c73 100644
--- a/server/middlewares/validators/videos/video-imports.ts
+++ b/server/middlewares/validators/videos/video-imports.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { isPreImportVideoAccepted } from '@server/lib/moderation' 3import { isPreImportVideoAccepted } from '@server/lib/moderation'
4import { Hooks } from '@server/lib/plugins/hooks' 4import { Hooks } from '@server/lib/plugins/hooks'
diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts
index 97e8b4510..6c7601e05 100644
--- a/server/middlewares/validators/videos/video-live.ts
+++ b/server/middlewares/validators/videos/video-live.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' 3import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
4import { isLocalLiveVideoAccepted } from '@server/lib/moderation' 4import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
diff --git a/server/middlewares/validators/videos/video-ownership-changes.ts b/server/middlewares/validators/videos/video-ownership-changes.ts
index a7f0b72c3..95e4cebce 100644
--- a/server/middlewares/validators/videos/video-ownership-changes.ts
+++ b/server/middlewares/validators/videos/video-ownership-changes.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { param } from 'express-validator' 2import { param } from 'express-validator'
3import { isIdValid } from '@server/helpers/custom-validators/misc' 3import { isIdValid } from '@server/helpers/custom-validators/misc'
4import { checkUserCanTerminateOwnershipChange } from '@server/helpers/custom-validators/video-ownership' 4import { checkUserCanTerminateOwnershipChange } from '@server/helpers/custom-validators/video-ownership'
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index ab84b4814..8f5c75fd5 100644
--- a/server/middlewares/validators/videos/video-playlists.ts
+++ b/server/middlewares/validators/videos/video-playlists.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param, query, ValidationChain } from 'express-validator' 2import { body, param, query, ValidationChain } from 'express-validator'
3import { ExpressPromiseHandler } from '@server/types/express' 3import { ExpressPromiseHandler } from '@server/types/express'
4import { MUserAccountId } from '@server/types/models' 4import { MUserAccountId } from '@server/types/models'
diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/middlewares/validators/videos/video-rates.ts
index 5fe78b39e..6e0bb0ad1 100644
--- a/server/middlewares/validators/videos/video-rates.ts
+++ b/server/middlewares/validators/videos/video-rates.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { VideoRateType } from '../../../../shared/models/videos' 4import { VideoRateType } from '../../../../shared/models/videos'
diff --git a/server/middlewares/validators/videos/video-shares.ts b/server/middlewares/validators/videos/video-shares.ts
index 3b8d61768..0f04032bb 100644
--- a/server/middlewares/validators/videos/video-shares.ts
+++ b/server/middlewares/validators/videos/video-shares.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { param } from 'express-validator' 2import { param } from 'express-validator'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { isIdValid } from '../../../helpers/custom-validators/misc' 4import { isIdValid } from '../../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/videos/video-watch.ts b/server/middlewares/validators/videos/video-watch.ts
index 431515eb1..d83710a64 100644
--- a/server/middlewares/validators/videos/video-watch.ts
+++ b/server/middlewares/validators/videos/video-watch.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { toIntOrNull } from '../../../helpers/custom-validators/misc' 4import { toIntOrNull } from '../../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 13187f398..23ee9778a 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { body, header, param, query, ValidationChain } from 'express-validator' 2import { body, header, param, query, ValidationChain } from 'express-validator'
3import { getResumableUploadPath } from '@server/helpers/upload' 3import { getResumableUploadPath } from '@server/helpers/upload'
4import { isAbleToUploadVideo } from '@server/lib/user' 4import { isAbleToUploadVideo } from '@server/lib/user'
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts
index 131360820..8893a0c7e 100644
--- a/server/middlewares/validators/webfinger.ts
+++ b/server/middlewares/validators/webfinger.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { query } from 'express-validator' 2import { query } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger' 4import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger'
diff --git a/server/models/application/application.ts b/server/models/application/application.ts
index 5531d134a..e3939383b 100644
--- a/server/models/application/application.ts
+++ b/server/models/application/application.ts
@@ -1,4 +1,4 @@
1import * as memoizee from 'memoizee' 1import memoizee from 'memoizee'
2import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' 2import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
3import { AttributesOnly } from '@shared/core-utils' 3import { AttributesOnly } from '@shared/core-utils'
4import { AccountModel } from '../account/account' 4import { AccountModel } from '../account/account'
diff --git a/server/models/model-cache.ts b/server/models/model-cache.ts
index eafb5c13c..3651267e7 100644
--- a/server/models/model-cache.ts
+++ b/server/models/model-cache.ts
@@ -1,5 +1,4 @@
1import { Model } from 'sequelize-typescript' 1import { Model } from 'sequelize-typescript'
2import * as Bluebird from 'bluebird'
3import { logger } from '@server/helpers/logger' 2import { logger } from '@server/helpers/logger'
4 3
5type ModelCacheType = 4type ModelCacheType =
@@ -52,7 +51,7 @@ class ModelCache {
52 51
53 if (cache.has(key)) { 52 if (cache.has(key)) {
54 logger.debug('Model cache hit for %s -> %s.', cacheType, key) 53 logger.debug('Model cache hit for %s -> %s.', cacheType, key)
55 return Bluebird.resolve<T>(cache.get(key)) 54 return Promise.resolve<T>(cache.get(key))
56 } 55 }
57 56
58 return fun().then(m => { 57 return fun().then(m => {
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index e933989ae..c89279c65 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -585,7 +585,7 @@ export class VideoCommentModel extends Model<Partial<AttributesOnly<VideoComment
585 585
586 if (accountId) { 586 if (accountId) {
587 whereAnd.push({ 587 whereAnd.push({
588 [Op.eq]: accountId 588 accountId
589 }) 589 })
590 } 590 }
591 591
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 627c95763..5e8d29d0a 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -1,5 +1,5 @@
1import { remove } from 'fs-extra' 1import { remove } from 'fs-extra'
2import * as memoizee from 'memoizee' 2import memoizee from 'memoizee'
3import { join } from 'path' 3import { join } from 'path'
4import { FindOptions, Op, Transaction } from 'sequelize' 4import { FindOptions, Op, Transaction } from 'sequelize'
5import { 5import {
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts
index 3e9fd97c7..18d96c750 100644
--- a/server/models/video/video-streaming-playlist.ts
+++ b/server/models/video/video-streaming-playlist.ts
@@ -1,4 +1,4 @@
1import * as memoizee from 'memoizee' 1import memoizee from 'memoizee'
2import { join } from 'path' 2import { join } from 'path'
3import { Op } from 'sequelize' 3import { Op } from 'sequelize'
4import { 4import {
diff --git a/server/models/video/video-view.ts b/server/models/video/video-view.ts
index dfc6296ce..b51f0f84d 100644
--- a/server/models/video/video-view.ts
+++ b/server/models/video/video-view.ts
@@ -1,5 +1,5 @@
1import * as Sequelize from 'sequelize' 1import { literal, Op } from 'sequelize'
2import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table } from 'sequelize-typescript' 2import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Model, Table } from 'sequelize-typescript'
3import { AttributesOnly } from '@shared/core-utils' 3import { AttributesOnly } from '@shared/core-utils'
4import { VideoModel } from './video' 4import { VideoModel } from './video'
5 5
@@ -20,11 +20,11 @@ export class VideoViewModel extends Model<Partial<AttributesOnly<VideoViewModel>
20 createdAt: Date 20 createdAt: Date
21 21
22 @AllowNull(false) 22 @AllowNull(false)
23 @Column(Sequelize.DATE) 23 @Column(DataType.DATE)
24 startDate: Date 24 startDate: Date
25 25
26 @AllowNull(false) 26 @AllowNull(false)
27 @Column(Sequelize.DATE) 27 @Column(DataType.DATE)
28 endDate: Date 28 endDate: Date
29 29
30 @AllowNull(false) 30 @AllowNull(false)
@@ -47,10 +47,10 @@ export class VideoViewModel extends Model<Partial<AttributesOnly<VideoViewModel>
47 const query = { 47 const query = {
48 where: { 48 where: {
49 startDate: { 49 startDate: {
50 [Sequelize.Op.lt]: beforeDate 50 [Op.lt]: beforeDate
51 }, 51 },
52 videoId: { 52 videoId: {
53 [Sequelize.Op.in]: Sequelize.literal('(SELECT "id" FROM "video" WHERE "remote" IS TRUE)') 53 [Op.in]: literal('(SELECT "id" FROM "video" WHERE "remote" IS TRUE)')
54 } 54 }
55 } 55 }
56 } 56 }
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 874ad168a..e0c4dd2db 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1,4 +1,4 @@
1import * as Bluebird from 'bluebird' 1import Bluebird from 'bluebird'
2import { remove } from 'fs-extra' 2import { remove } from 'fs-extra'
3import { maxBy, minBy } from 'lodash' 3import { maxBy, minBy } from 'lodash'
4import { join } from 'path' 4import { join } from 'path'
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index fe42e5fa8..86b40cfe6 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { readdir } from 'fs-extra' 5import { readdir } from 'fs-extra'
6import * as magnetUtil from 'magnet-uri' 6import magnetUtil from 'magnet-uri'
7import { basename, join } from 'path' 7import { basename, join } from 'path'
8import { 8import {
9 checkSegmentHash, 9 checkSegmentHash,
diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts
index 719813ae9..1e0c95a3b 100644
--- a/server/tests/api/server/no-client.ts
+++ b/server/tests/api/server/no-client.ts
@@ -1,5 +1,5 @@
1import 'mocha' 1import 'mocha'
2import * as request from 'supertest' 2import request from 'supertest'
3import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/extra-utils' 3import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/extra-utils'
4import { HttpStatusCode } from '@shared/models' 4import { HttpStatusCode } from '@shared/models'
5 5
diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts
index f597ac60c..30a9618b3 100644
--- a/server/tests/api/server/tracker.ts
+++ b/server/tests/api/server/tracker.ts
@@ -1,8 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await,@typescript-eslint/no-floating-promises */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await,@typescript-eslint/no-floating-promises */
2 2
3import 'mocha' 3import 'mocha'
4import * as magnetUtil from 'magnet-uri' 4import magnetUtil from 'magnet-uri'
5import * as WebTorrent from 'webtorrent' 5import WebTorrent from 'webtorrent'
6import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' 6import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
7 7
8describe('Test tracker', function () { 8describe('Test tracker', function () {
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index f9220e4b3..df9deb1e1 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import * as request from 'supertest' 5import request from 'supertest'
6import { 6import {
7 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
8 checkTmpIsEmpty, 8 checkTmpIsEmpty,
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index 55b434846..a1c976fd3 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import * as xmlParser from 'fast-xml-parser' 5import { parse, validate } from 'fast-xml-parser'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createMultipleServers, 8 createMultipleServers,
@@ -149,9 +149,9 @@ describe('Test syndication feeds', () => {
149 it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () { 149 it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () {
150 for (const server of servers) { 150 for (const server of servers) {
151 const rss = await server.feed.getXML({ feed: 'videos' }) 151 const rss = await server.feed.getXML({ feed: 'videos' })
152 expect(xmlParser.validate(rss)).to.be.true 152 expect(validate(rss)).to.be.true
153 153
154 const xmlDoc = xmlParser.parse(rss, { parseAttributeValue: true, ignoreAttributes: false }) 154 const xmlDoc = parse(rss, { parseAttributeValue: true, ignoreAttributes: false })
155 155
156 const enclosure = xmlDoc.rss.channel.item[0].enclosure 156 const enclosure = xmlDoc.rss.channel.item[0].enclosure
157 expect(enclosure).to.exist 157 expect(enclosure).to.exist
diff --git a/server/tools/peertube-auth.ts b/server/tools/peertube-auth.ts
index b9f4ef4f8..afa19ee08 100644
--- a/server/tools/peertube-auth.ts
+++ b/server/tools/peertube-auth.ts
@@ -4,10 +4,11 @@ import { registerTSPaths } from '../helpers/register-ts-paths'
4registerTSPaths() 4registerTSPaths()
5 5
6import { OptionValues, program } from 'commander' 6import { OptionValues, program } from 'commander'
7import * as prompt from 'prompt'
8import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './cli' 7import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './cli'
9import { isUserUsernameValid } from '../helpers/custom-validators/users' 8import { isUserUsernameValid } from '../helpers/custom-validators/users'
10import * as CliTable3 from 'cli-table3' 9import CliTable3 from 'cli-table3'
10
11import prompt = require('prompt')
11 12
12async function delInstance (url: string) { 13async function delInstance (url: string) {
13 const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ]) 14 const [ settings, netrc ] = await Promise.all([ getSettings(), getNetrc() ])
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts
index 488109b7a..758b561e1 100644
--- a/server/tools/peertube-import-videos.ts
+++ b/server/tools/peertube-import-videos.ts
@@ -6,7 +6,6 @@ import { accessSync, constants } from 'fs'
6import { remove } from 'fs-extra' 6import { remove } from 'fs-extra'
7import { truncate } from 'lodash' 7import { truncate } from 'lodash'
8import { join } from 'path' 8import { join } from 'path'
9import * as prompt from 'prompt'
10import { promisify } from 'util' 9import { promisify } from 'util'
11import { YoutubeDL } from '@server/helpers/youtube-dl' 10import { YoutubeDL } from '@server/helpers/youtube-dl'
12import { sha256 } from '../helpers/core-utils' 11import { sha256 } from '../helpers/core-utils'
@@ -22,6 +21,8 @@ import {
22} from './cli' 21} from './cli'
23import { PeerTubeServer } from '@shared/extra-utils' 22import { PeerTubeServer } from '@shared/extra-utils'
24 23
24import prompt = require('prompt')
25
25const processOptions = { 26const processOptions = {
26 maxBuffer: Infinity 27 maxBuffer: Infinity
27} 28}
diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts
index d9c285115..ae625114d 100644
--- a/server/tools/peertube-plugins.ts
+++ b/server/tools/peertube-plugins.ts
@@ -7,7 +7,7 @@ import { program, Command, OptionValues } from 'commander'
7import { assignToken, buildServer, getServerCredentials } from './cli' 7import { assignToken, buildServer, getServerCredentials } from './cli'
8import { PluginType } from '../../shared/models' 8import { PluginType } from '../../shared/models'
9import { isAbsolute } from 'path' 9import { isAbsolute } from 'path'
10import * as CliTable3 from 'cli-table3' 10import CliTable3 from 'cli-table3'
11 11
12program 12program
13 .name('plugins') 13 .name('plugins')
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts
index 73b026ac8..7e27ca49e 100644
--- a/server/tools/peertube-redundancy.ts
+++ b/server/tools/peertube-redundancy.ts
@@ -1,7 +1,7 @@
1import { registerTSPaths } from '../helpers/register-ts-paths' 1import { registerTSPaths } from '../helpers/register-ts-paths'
2registerTSPaths() 2registerTSPaths()
3 3
4import * as CliTable3 from 'cli-table3' 4import CliTable3 from 'cli-table3'
5import { Command, program } from 'commander' 5import { Command, program } from 'commander'
6import { uniq } from 'lodash' 6import { uniq } from 'lodash'
7import { URL } from 'url' 7import { URL } from 'url'
diff --git a/server/types/plugins/register-server-auth.model.ts b/server/types/plugins/register-server-auth.model.ts
index 3e1a5aeba..79c18c406 100644
--- a/server/types/plugins/register-server-auth.model.ts
+++ b/server/types/plugins/register-server-auth.model.ts
@@ -1,4 +1,4 @@
1import * as express from 'express' 1import express from 'express'
2import { UserRole } from '@shared/models' 2import { UserRole } from '@shared/models'
3import { MOAuthToken, MUser } from '../models' 3import { MOAuthToken, MUser } from '../models'
4 4