diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-27 14:32:44 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-27 15:12:22 +0200 |
commit | 41fb13c330de629df2d23379209e79c7af0f2e9a (patch) | |
tree | 73bc5a90566406b3910f142beae2a879c1e4265d /server | |
parent | 40e7ed0714f96c01e16de3ac971a4b28116294e1 (diff) | |
download | PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.gz PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.zst PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.zip |
esModuleInterop to true
Diffstat (limited to 'server')
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 @@ | |||
1 | import * as cors from 'cors' | 1 | import cors from 'cors' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { getServerActor } from '@server/models/application/application' | 3 | import { getServerActor } from '@server/models/application/application' |
4 | import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models' | 4 | import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models' |
5 | import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { InboxManager } from '@server/lib/activitypub/inbox-manager' | 2 | import { InboxManager } from '@server/lib/activitypub/inbox-manager' |
3 | import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' | 3 | import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' |
4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { activityPubClientRouter } from './client' | 2 | import { activityPubClientRouter } from './client' |
3 | import { inboxRouter } from './inbox' | 3 | import { inboxRouter } from './inbox' |
4 | import { outboxRouter } from './outbox' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { Activity } from '../../../shared/models/activitypub/activity' | 2 | import { Activity } from '../../../shared/models/activitypub/activity' |
3 | import { VideoPrivacy } from '../../../shared/models/videos' | 3 | import { VideoPrivacy } from '../../../shared/models/videos' |
4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | 2 | ||
3 | function activityPubResponse (data: any, res: express.Response) { | 3 | function 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { logger } from '@server/helpers/logger' | 2 | import { logger } from '@server/helpers/logger' |
3 | import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation' | 3 | import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation' |
4 | import { Notifier } from '@server/lib/notifier' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { pickCommonVideoQuery } from '@server/helpers/query' | 2 | import { pickCommonVideoQuery } from '@server/helpers/query' |
3 | import { getServerActor } from '@server/models/application/application' | 3 | import { getServerActor } from '@server/models/application/application' |
4 | import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { removeComment } from '@server/lib/video-comment' | 2 | import { removeComment } from '@server/lib/video-comment' |
3 | import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk' | 3 | import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk' |
4 | import { VideoCommentModel } from '@server/models/video/video-comment' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { remove, writeJSON } from 'fs-extra' | 2 | import { remove, writeJSON } from 'fs-extra' |
3 | import { snakeCase } from 'lodash' | 3 | import { snakeCase } from 'lodash' |
4 | import validator from 'validator' | 4 | import 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 2 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
3 | import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' | 3 | import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' |
4 | import { HttpStatusCode, UserRight } from '@shared/models' | 4 | import { 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 @@ | |||
1 | import * as cors from 'cors' | 1 | import cors from 'cors' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import * as RateLimit from 'express-rate-limit' | 3 | import RateLimit from 'express-rate-limit' |
4 | import { HttpStatusCode } from '../../../shared/models' | 4 | import { HttpStatusCode } from '../../../shared/models' |
5 | import { badRequest } from '../../helpers/express-utils' | 5 | import { badRequest } from '../../helpers/express-utils' |
6 | import { CONFIG } from '../../initializers/config' | 6 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { ResultList } from '../../../shared' | 2 | import { ResultList } from '../../../shared' |
3 | import { Job, JobState, JobType } from '../../../shared/models' | 3 | import { Job, JobState, JobType } from '../../../shared/models' |
4 | import { UserRight } from '../../../shared/models/users' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { OAuthClientLocal } from '../../../shared' | 2 | import { OAuthClientLocal } from '../../../shared' |
3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { logger } from '../../helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import * as memoizee from 'memoizee' | 2 | import memoizee from 'memoizee' |
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
5 | import { VideoModel } from '@server/models/video/video' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { logger } from '@server/helpers/logger' | 2 | import { logger } from '@server/helpers/logger' |
3 | import { getFormattedObjects } from '@server/helpers/utils' | 3 | import { getFormattedObjects } from '@server/helpers/utils' |
4 | import { listAvailablePluginsFromIndex } from '@server/lib/plugins/plugin-index' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { searchChannelsRouter } from './search-video-channels' | 2 | import { searchChannelsRouter } from './search-video-channels' |
3 | import { searchPlaylistsRouter } from './search-video-playlists' | 3 | import { searchPlaylistsRouter } from './search-video-playlists' |
4 | import { searchVideosRouter } from './search-videos' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { sanitizeUrl } from '@server/helpers/core-utils' | 2 | import { sanitizeUrl } from '@server/helpers/core-utils' |
3 | import { pickSearchChannelQuery } from '@server/helpers/query' | 3 | import { pickSearchChannelQuery } from '@server/helpers/query' |
4 | import { doJSONRequest } from '@server/helpers/requests' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { sanitizeUrl } from '@server/helpers/core-utils' | 2 | import { sanitizeUrl } from '@server/helpers/core-utils' |
3 | import { isUserAbleToSearchRemoteURI } from '@server/helpers/express-utils' | 3 | import { isUserAbleToSearchRemoteURI } from '@server/helpers/express-utils' |
4 | import { logger } from '@server/helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { sanitizeUrl } from '@server/helpers/core-utils' | 2 | import { sanitizeUrl } from '@server/helpers/core-utils' |
3 | import { pickSearchVideoQuery } from '@server/helpers/query' | 3 | import { pickSearchVideoQuery } from '@server/helpers/query' |
4 | import { doJSONRequest } from '@server/helpers/requests' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 2 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
3 | import { ContactForm } from '../../../../shared/models/server' | 3 | import { ContactForm } from '../../../../shared/models/server' |
4 | import { Emailer } from '../../../lib/emailer' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { InboxManager } from '@server/lib/activitypub/inbox-manager' | 2 | import { InboxManager } from '@server/lib/activitypub/inbox-manager' |
3 | import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' | 3 | import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' |
4 | import { Debug, SendDebugCommand } from '@shared/models' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { getServerActor } from '@server/models/application/application' | 2 | import { getServerActor } from '@server/models/application/application' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { UserRight } from '../../../../shared/models/users' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { contactRouter } from './contact' | 2 | import { contactRouter } from './contact' |
3 | import { debugRouter } from './debug' | 3 | import { debugRouter } from './debug' |
4 | import { serverFollowsRouter } from './follows' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { readdir, readFile } from 'fs-extra' | 2 | import { readdir, readFile } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { logger, mtimeSortFilesDesc } from '@server/helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { JobQueue } from '@server/lib/job-queue' | 2 | import { JobQueue } from '@server/lib/job-queue' |
3 | import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' | 3 | import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' |
4 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 4 | import { 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 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { getServerActor } from '@server/models/application/application' | 4 | import { getServerActor } from '@server/models/application/application' |
5 | import { UserNotificationModel } from '@server/models/user/user-notification' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { StatsManager } from '@server/lib/stat-manager' | 2 | import { StatsManager } from '@server/lib/stat-manager' |
3 | import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' | 3 | import { ROUTE_CACHE_LIFETIME } from '../../../initializers/constants' |
4 | import { asyncMiddleware } from '../../../middlewares' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import * as RateLimit from 'express-rate-limit' | 2 | import RateLimit from 'express-rate-limit' |
3 | import { tokensRouter } from '@server/controllers/api/users/token' | 3 | import { tokensRouter } from '@server/controllers/api/users/token' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
5 | import { OAuthTokenModel } from '@server/models/oauth/oauth-token' | 5 | import { 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 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' | 3 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
5 | import { AttributesOnly } from '@shared/core-utils' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { AbuseModel } from '@server/models/abuse/abuse' | 2 | import { AbuseModel } from '@server/models/abuse/abuse' |
3 | import { | 3 | import { |
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 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { UserNotificationModel } from '@server/models/user/user-notification' | 4 | import { UserNotificationModel } from '@server/models/user/user-notification' |
5 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 2 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
3 | import { getFormattedObjects } from '../../../helpers/utils' | 3 | import { getFormattedObjects } from '../../../helpers/utils' |
4 | import { sequelizeTypescript } from '../../../initializers/database' | 4 | import { 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 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { UserNotificationModel } from '@server/models/user/user-notification' | 3 | import { UserNotificationModel } from '@server/models/user/user-notification' |
4 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 4 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
5 | import { UserNotificationSetting } from '../../../../shared/models/users' | 5 | import { 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 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { pickCommonVideoQuery } from '@server/helpers/query' | 3 | import { pickCommonVideoQuery } from '@server/helpers/query' |
4 | import { sendUndoFollow } from '@server/lib/activitypub/send' | 4 | import { sendUndoFollow } from '@server/lib/activitypub/send' |
5 | import { VideoChannelModel } from '@server/models/video/video-channel' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' | 2 | import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' |
3 | import { asyncMiddleware, authenticate } from '../../../middlewares' | 3 | import { asyncMiddleware, authenticate } from '../../../middlewares' |
4 | import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import * as RateLimit from 'express-rate-limit' | 2 | import RateLimit from 'express-rate-limit' |
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { buildUUID } from '@server/helpers/uuid' | 4 | import { buildUUID } from '@server/helpers/uuid' |
5 | import { CONFIG } from '@server/initializers/config' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { pickCommonVideoQuery } from '@server/helpers/query' | 2 | import { pickCommonVideoQuery } from '@server/helpers/query' |
3 | import { Hooks } from '@server/lib/plugins/hooks' | 3 | import { Hooks } from '@server/lib/plugins/hooks' |
4 | import { getServerActor } from '@server/models/application/application' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { uuidToShort } from '@server/helpers/uuid' | 3 | import { uuidToShort } from '@server/helpers/uuid' |
4 | import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist' | 2 | import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist' |
3 | import { UserRight, VideoBlacklistCreate } from '../../../../shared' | 3 | import { UserRight, VideoBlacklistCreate } from '../../../../shared' |
4 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { MVideoCaption } from '@server/types/models' | 2 | import { MVideoCaption } from '@server/types/models' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' | 2 | import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { move, readFile } from 'fs-extra' | 2 | import { move, readFile } from 'fs-extra' |
3 | import * as magnetUtil from 'magnet-uri' | 3 | import { decode } from 'magnet-uri' |
4 | import * as parseTorrent from 'parse-torrent' | 4 | import parseTorrent, { Instance } from 'parse-torrent' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 6 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
7 | import { setVideoTags } from '@server/lib/video' | 7 | import { 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 | ||
350 | function processMagnetURI (body: VideoImportCreate) { | 350 | function 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import toInt from 'validator/lib/toInt' | 2 | import toInt from 'validator/lib/toInt' |
3 | import { pickCommonVideoQuery } from '@server/helpers/query' | 3 | import { pickCommonVideoQuery } from '@server/helpers/query' |
4 | import { doJSONRequest } from '@server/helpers/requests' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { createReqFiles } from '@server/helpers/express-utils' | 2 | import { createReqFiles } from '@server/helpers/express-utils' |
3 | import { buildUUID, uuidToShort } from '@server/helpers/uuid' | 3 | import { buildUUID, uuidToShort } from '@server/helpers/uuid' |
4 | import { CONFIG } from '@server/initializers/config' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { MVideoFullLight } from '@server/types/models' | 2 | import { MVideoFullLight } from '@server/types/models' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { UserVideoRateUpdate } from '../../../../shared' | 2 | import { UserVideoRateUpdate } from '../../../../shared' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { logger } from '../../../helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { Transaction } from 'sequelize/types' | 2 | import { Transaction } from 'sequelize/types' |
3 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' | 3 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' |
4 | import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { move } from 'fs-extra' | 2 | import { move } from 'fs-extra' |
3 | import { basename } from 'path' | 3 | import { basename } from 'path' |
4 | import { getLowercaseExtension } from '@server/helpers/core-utils' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { UserWatchingVideo } from '../../../../shared' | 2 | import { UserWatchingVideo } from '../../../../shared' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { | 4 | import { |
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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { truncate } from 'lodash' | 2 | import { truncate } from 'lodash' |
3 | import { SitemapStream, streamToPromise } from 'sitemap' | 3 | import { SitemapStream, streamToPromise } from 'sitemap' |
4 | import { buildNSFWFilter } from '../helpers/express-utils' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { constants, promises as fs } from 'fs' | 2 | import { constants, promises as fs } from 'fs' |
3 | import { readFile } from 'fs-extra' | 3 | import { readFile } from 'fs-extra' |
4 | import { join } from 'path' | 4 | import { 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 @@ | |||
1 | import * as cors from 'cors' | 1 | import cors from 'cors' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' | 4 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' |
5 | import { Hooks } from '@server/lib/plugins/hooks' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import * as Feed from 'pfeed' | 2 | import Feed from 'pfeed' |
3 | import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils' | 3 | import { getCategoryLabel } from '@server/models/video/formatter/video-format-utils' |
4 | import { VideoFilter } from '../../shared/models/videos/video-query.type' | 4 | import { VideoFilter } from '../../shared/models/videos/video-query.type' |
5 | import { buildNSFWFilter } from '../helpers/express-utils' | 5 | import { 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 @@ | |||
1 | import * as cors from 'cors' | 1 | import cors from 'cors' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' | 3 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' |
4 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' | 4 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
5 | import { logger } from '../helpers/logger' | 5 | import { 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 @@ | |||
1 | import * as cors from 'cors' | 1 | import cors from 'cors' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { mapToJSON } from '@server/helpers/core-utils' | 3 | import { mapToJSON } from '@server/helpers/core-utils' |
4 | import { LiveSegmentShaStore } from '@server/lib/live' | 4 | import { LiveSegmentShaStore } from '@server/lib/live' |
5 | import { HttpStatusCode } from '@shared/models' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { optionalAuthenticate } from '@server/middlewares/auth' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER, THUMBNAILS_SIZE } from '../initializers/constants' | 2 | import { EMBED_SIZE, PREVIEWS_SIZE, WEBSERVER, THUMBNAILS_SIZE } from '../initializers/constants' |
3 | import { asyncMiddleware, oembedValidator } from '../middlewares' | 3 | import { asyncMiddleware, oembedValidator } from '../middlewares' |
4 | import { accountNameWithHostGetValidator } from '../middlewares/validators' | 4 | import { 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 @@ | |||
1 | import * as cors from 'cors' | 1 | import cors from 'cors' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { serveIndexHTML } from '@server/lib/client-html' | 4 | import { serveIndexHTML } from '@server/lib/client-html' |
5 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 5 | import { 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 @@ | |||
1 | import * as bitTorrentTracker from 'bittorrent-tracker' | 1 | import { Server as TrackerServer } from 'bittorrent-tracker' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import * as http from 'http' | 3 | import { createServer } from 'http' |
4 | import * as proxyAddr from 'proxy-addr' | 4 | import proxyAddr from 'proxy-addr' |
5 | import { Server as WebSocketServer } from 'ws' | 5 | import { Server as WebSocketServer } from 'ws' |
6 | import { Redis } from '@server/lib/redis' | 6 | import { Redis } from '@server/lib/redis' |
7 | import { logger } from '../helpers/logger' | 7 | import { logger } from '../helpers/logger' |
@@ -10,8 +10,6 @@ import { TRACKER_RATE_LIMITS } from '../initializers/constants' | |||
10 | import { VideoFileModel } from '../models/video/video-file' | 10 | import { VideoFileModel } from '../models/video/video-file' |
11 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' | 11 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' |
12 | 12 | ||
13 | const TrackerServer = bitTorrentTracker.Server | ||
14 | |||
15 | const trackerRouter = express.Router() | 13 | const trackerRouter = express.Router() |
16 | 14 | ||
17 | let peersIps = {} | 15 | let peersIps = {} |
@@ -86,7 +84,7 @@ trackerRouter.get('/tracker/announce', (req, res) => onHttpRequest(req, res, { a | |||
86 | trackerRouter.get('/tracker/scrape', (req, res) => onHttpRequest(req, res, { action: 'scrape' })) | 84 | trackerRouter.get('/tracker/scrape', (req, res) => onHttpRequest(req, res, { action: 'scrape' })) |
87 | 85 | ||
88 | function createWebsocketTrackerServer (app: express.Application) { | 86 | function 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 @@ | |||
1 | import * as cors from 'cors' | 1 | import cors from 'cors' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { WEBSERVER } from '@server/initializers/constants' | 3 | import { WEBSERVER } from '@server/initializers/constants' |
4 | import { asyncMiddleware } from '../middlewares' | 4 | import { asyncMiddleware } from '../middlewares' |
5 | import { webfingerValidator } from '../middlewares/validators' | 5 | import { 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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import Bluebird from 'bluebird' |
2 | import { URL } from 'url' | 2 | import { URL } from 'url' |
3 | import validator from 'validator' | 3 | import validator from 'validator' |
4 | import { ContextType } from '@shared/models/activitypub/context' | 4 | import { 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 @@ | |||
1 | import { diff } from 'deep-object-diff' | 1 | import { diff } from 'deep-object-diff' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import * as flatten from 'flat' | 3 | import flatten from 'flat' |
4 | import { chain } from 'lodash' | 4 | import { chain } from 'lodash' |
5 | import * as path from 'path' | 5 | import { join } from 'path' |
6 | import * as winston from 'winston' | 6 | import { addColors, config, createLogger, format, transports } from 'winston' |
7 | import { AUDIT_LOG_FILENAME } from '@server/initializers/constants' | 7 | import { AUDIT_LOG_FILENAME } from '@server/initializers/constants' |
8 | import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared' | 8 | import { AdminAbuse, User, VideoChannel, VideoDetails, VideoImport } from '../../shared' |
9 | import { CustomConfig } from '../../shared/models/server/custom-config.model' | 9 | import { 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 | ||
24 | const colors = winston.config.npm.colors | 24 | const colors = config.npm.colors |
25 | colors.audit = winston.config.npm.colors.info | 25 | colors.audit = config.npm.colors.info |
26 | 26 | ||
27 | winston.addColors(colors) | 27 | addColors(colors) |
28 | 28 | ||
29 | const auditLogger = winston.createLogger({ | 29 | const 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 @@ | |||
1 | import { createReadStream, createWriteStream, move, remove } from 'fs-extra' | 1 | import { createReadStream, createWriteStream, move, remove } from 'fs-extra' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import * as srt2vtt from 'srt-to-vtt' | 3 | import srt2vtt from 'srt-to-vtt' |
4 | import { Transform } from 'stream' | ||
4 | import { MVideoCaption } from '@server/types/models' | 5 | import { MVideoCaption } from '@server/types/models' |
5 | import { CONFIG } from '../initializers/config' | 6 | import { CONFIG } from '../initializers/config' |
6 | import { pipelinePromise } from './core-utils' | 7 | import { pipelinePromise } from './core-utils' |
7 | import { Transform } from 'stream' | ||
8 | 8 | ||
9 | async function moveAndProcessCaptionFile (physicalFile: { filename: string, path: string }, videoCaption: MVideoCaption) { | 9 | async 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' | |||
9 | import { BinaryToTextEncoding, createHash, randomBytes } from 'crypto' | 9 | import { BinaryToTextEncoding, createHash, randomBytes } from 'crypto' |
10 | import { truncate } from 'lodash' | 10 | import { truncate } from 'lodash' |
11 | import { basename, extname, isAbsolute, join, resolve } from 'path' | 11 | import { basename, extname, isAbsolute, join, resolve } from 'path' |
12 | import * as pem from 'pem' | 12 | import { createPrivateKey as createPrivateKey_1, getPublicKey as getPublicKey_1 } from 'pem' |
13 | import { pipeline } from 'stream' | 13 | import { pipeline } from 'stream' |
14 | import { URL } from 'url' | 14 | import { URL } from 'url' |
15 | import { promisify } from 'util' | 15 | import { 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 | ||
283 | const randomBytesPromise = promisify1<number, Buffer>(randomBytes) | 283 | const randomBytesPromise = promisify1<number, Buffer>(randomBytes) |
284 | const createPrivateKey = promisify1<number, { key: string }>(pem.createPrivateKey) | 284 | const createPrivateKey = promisify1<number, { key: string }>(createPrivateKey_1) |
285 | const getPublicKey = promisify1<string, { publicKey: string }>(pem.getPublicKey) | 285 | const getPublicKey = promisify1<string, { publicKey: string }>(getPublicKey_1) |
286 | const execPromise2 = promisify2<string, any, string>(exec) | 286 | const execPromise2 = promisify2<string, any, string>(exec) |
287 | const execPromise = promisify1<string, string>(exec) | 287 | const execPromise = promisify1<string, string>(exec) |
288 | const pipelinePromise = promisify(pipeline) | 288 | const 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 @@ | |||
1 | import * as AsyncLRU from 'async-lru' | 1 | import AsyncLRU from 'async-lru' |
2 | import * as jsonld from 'jsonld' | ||
3 | import { logger } from './logger' | 2 | import { logger } from './logger' |
4 | 3 | ||
4 | import jsonld = require('jsonld') | ||
5 | |||
5 | const CACHE = { | 6 | const 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 @@ | |||
1 | import { UploadFilesForCheck } from 'express' | 1 | import { UploadFilesForCheck } from 'express' |
2 | import { values } from 'lodash' | 2 | import { values } from 'lodash' |
3 | import * as magnetUtil from 'magnet-uri' | 3 | import magnetUtil from 'magnet-uri' |
4 | import validator from 'validator' | 4 | import validator from 'validator' |
5 | import { VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared' | 5 | import { VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared' |
6 | import { | 6 | import { |
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 @@ | |||
1 | import * as retry from 'async/retry' | 1 | import retry from 'async/retry' |
2 | import * as Bluebird from 'bluebird' | 2 | import Bluebird from 'bluebird' |
3 | import { Transaction } from 'sequelize' | 3 | import { Transaction } from 'sequelize' |
4 | import { Model } from 'sequelize-typescript' | 4 | import { Model } from 'sequelize-typescript' |
5 | import { sequelizeTypescript } from '@server/initializers/database' | 5 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import * as multer from 'multer' | 2 | import multer, { diskStorage } from 'multer' |
3 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
4 | import { CONFIG } from '../initializers/config' | 4 | import { CONFIG } from '../initializers/config' |
5 | import { REMOTE_SCHEME } from '../initializers/constants' | 5 | import { 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 @@ | |||
1 | import { Job } from 'bull' | 1 | import { Job } from 'bull' |
2 | import * as ffmpeg from 'fluent-ffmpeg' | 2 | import ffmpeg, { FfmpegCommand, FilterSpecification, getAvailableEncoders } from 'fluent-ffmpeg' |
3 | import { readFile, remove, writeFile } from 'fs-extra' | 3 | import { readFile, remove, writeFile } from 'fs-extra' |
4 | import { dirname, join } from 'path' | 4 | import { dirname, join } from 'path' |
5 | import { FFMPEG_NICE, VIDEO_LIVE } from '@server/initializers/constants' | 5 | import { 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 | ||
193 | const builders: { | 193 | const 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 | ||
355 | function addDefaultEncoderGlobalParams (options: { | 355 | function 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 | ||
372 | function addDefaultEncoderParams (options: { | 372 | function 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 | ||
393 | function addDefaultLiveHLSParams (command: ffmpeg.FfmpegCommand, outPath: string, masterPlaylistName: string) { | 393 | function 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 | ||
408 | async function buildx264VODCommand (command: ffmpeg.FfmpegCommand, options: TranscodeOptions) { | 408 | async 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 | ||
425 | async function buildAudioMergeCommand (command: ffmpeg.FfmpegCommand, options: MergeAudioTranscodeOptions) { | 425 | async 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 | ||
440 | function buildOnlyAudioCommand (command: ffmpeg.FfmpegCommand, _options: OnlyAudioTranscodeOptions) { | 440 | function 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 | ||
446 | function buildQuickTranscodeCommand (command: ffmpeg.FfmpegCommand) { | 446 | function 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 | ||
455 | function addCommonHLSVODCommandOptions (command: ffmpeg.FfmpegCommand, outputPath: string) { | 455 | function 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 | ||
465 | async function buildHLSVODCommand (command: ffmpeg.FfmpegCommand, options: HLSTranscodeOptions) { | 465 | async 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 | ||
477 | function buildHLSVODFromTSCommand (command: ffmpeg.FfmpegCommand, options: HLSFromTSTranscodeOptions) { | 477 | function 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 | ||
573 | async function presetVideo (options: { | 573 | async 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 | ||
643 | function presetCopy (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand { | 643 | function 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 | ||
650 | function presetOnlyAudio (command: ffmpeg.FfmpegCommand): ffmpeg.FfmpegCommand { | 650 | function 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 | ||
657 | function applyEncoderOptions (command: ffmpeg.FfmpegCommand, options: EncoderOptions): ffmpeg.FfmpegCommand { | 657 | function 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 | ||
716 | async function runCommand (options: { | 716 | async 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 @@ | |||
1 | import * as ffmpeg from 'fluent-ffmpeg' | 1 | import { ffprobe, FfprobeData } from 'fluent-ffmpeg' |
2 | import { getMaxBitrate } from '@shared/core-utils' | 2 | import { getMaxBitrate } from '@shared/core-utils' |
3 | import { VideoFileMetadata, VideoResolution, VideoTranscodingFPS } from '../../shared/models/videos' | 3 | import { VideoFileMetadata, VideoResolution, VideoTranscodingFPS } from '../../shared/models/videos' |
4 | import { CONFIG } from '../initializers/config' | 4 | import { CONFIG } from '../initializers/config' |
@@ -12,8 +12,8 @@ import { logger } from './logger' | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | function ffprobePromise (path: string) { | 14 | function 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 | ||
24 | async function getAudioStream (videoPath: string, existingProbe?: ffmpeg.FfprobeData) { | 24 | async 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 | ||
79 | async function getVideoStreamSize (path: string, existingProbe?: ffmpeg.FfprobeData): Promise<{ width: number, height: number }> { | 79 | async 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 | ||
130 | async function getAudioStreamCodec (path: string, existingProbe?: ffmpeg.FfprobeData) { | 130 | async 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 | ||
146 | async function getVideoFileResolution (path: string, existingProbe?: ffmpeg.FfprobeData) { | 146 | async 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 | ||
158 | async function getVideoFileFPS (path: string, existingProbe?: ffmpeg.FfprobeData) { | 158 | async 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 | ||
176 | async function getMetadataFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) { | 176 | async 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 | ||
182 | async function getVideoFileBitrate (path: string, existingProbe?: ffmpeg.FfprobeData): Promise<number> { | 182 | async 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 | ||
197 | async function getDurationFromVideoFile (path: string, existingProbe?: ffmpeg.FfprobeData) { | 197 | async 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 | ||
203 | async function getVideoStreamFromFile (path: string, existingProbe?: ffmpeg.FfprobeData) { | 203 | async 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 | ||
246 | async function canDoQuickVideoTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> { | 246 | async 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 | ||
265 | async function canDoQuickAudioTranscode (path: string, probe?: ffmpeg.FfprobeData): Promise<boolean> { | 265 | async 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 @@ | |||
1 | import { copy, readFile, remove, rename } from 'fs-extra' | 1 | import { copy, readFile, remove, rename } from 'fs-extra' |
2 | import * as Jimp from 'jimp' | 2 | import Jimp, { read } from 'jimp' |
3 | import { getLowercaseExtension } from './core-utils' | 3 | import { getLowercaseExtension } from './core-utils' |
4 | import { convertWebPToJPG, processGIF } from './ffmpeg-utils' | 4 | import { convertWebPToJPG, processGIF } from './ffmpeg-utils' |
5 | import { logger } from './logger' | 5 | import { 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/ |
2 | import { mkdirpSync, stat } from 'fs-extra' | 2 | import { mkdirpSync, stat } from 'fs-extra' |
3 | import { omit } from 'lodash' | 3 | import { omit } from 'lodash' |
4 | import * as path from 'path' | 4 | import { join } from 'path' |
5 | import { format as sqlFormat } from 'sql-formatter' | 5 | import { format as sqlFormat } from 'sql-formatter' |
6 | import * as winston from 'winston' | 6 | import { createLogger, format, transports } from 'winston' |
7 | import { FileTransportOptions } from 'winston/lib/winston/transports' | 7 | import { FileTransportOptions } from 'winston/lib/winston/transports' |
8 | import { CONFIG } from '../initializers/config' | 8 | import { CONFIG } from '../initializers/config' |
9 | import { LOG_FILENAME } from '../initializers/constants' | 9 | import { LOG_FILENAME } from '../initializers/constants' |
@@ -47,7 +47,7 @@ function getLoggerReplacer () { | |||
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | const consoleLoggerFormat = winston.format.printf(info => { | 50 | const 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 | ||
74 | const jsonLoggerFormat = winston.format.printf(info => { | 74 | const jsonLoggerFormat = format.printf(info => { |
75 | return JSON.stringify(info, getLoggerReplacer()) | 75 | return JSON.stringify(info, getLoggerReplacer()) |
76 | }) | 76 | }) |
77 | 77 | ||
78 | const timestampFormatter = winston.format.timestamp({ | 78 | const timestampFormatter = format.timestamp({ |
79 | format: 'YYYY-MM-DD HH:mm:ss.SSS' | 79 | format: 'YYYY-MM-DD HH:mm:ss.SSS' |
80 | }) | 80 | }) |
81 | const labelFormatter = (suffix?: string) => { | 81 | const 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 | ||
87 | const fileLoggerOptions: FileTransportOptions = { | 87 | const 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) { | |||
101 | const logger = buildLogger() | 101 | const logger = buildLogger() |
102 | 102 | ||
103 | function buildLogger (labelSuffix?: string) { | 103 | function 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 @@ | |||
1 | import { compare, genSalt, hash } from 'bcrypt' | ||
2 | import { createSign, createVerify } from 'crypto' | ||
1 | import { Request } from 'express' | 3 | import { Request } from 'express' |
4 | import { cloneDeep } from 'lodash' | ||
2 | import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants' | 5 | import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants' |
6 | import { MActor } from '../types/models' | ||
3 | import { createPrivateKey, getPublicKey, promisify1, promisify2, sha256 } from './core-utils' | 7 | import { createPrivateKey, getPublicKey, promisify1, promisify2, sha256 } from './core-utils' |
4 | import { jsonld } from './custom-jsonld-signature' | 8 | import { jsonld } from './custom-jsonld-signature' |
5 | import { logger } from './logger' | 9 | import { logger } from './logger' |
6 | import { cloneDeep } from 'lodash' | ||
7 | import { createSign, createVerify } from 'crypto' | ||
8 | import * as bcrypt from 'bcrypt' | ||
9 | import { MActor } from '../types/models' | ||
10 | 10 | ||
11 | const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare) | 11 | const bcryptComparePromise = promisify2<any, string, boolean>(compare) |
12 | const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt) | 12 | const bcryptGenSaltPromise = promisify1<number, string>(genSalt) |
13 | const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash) | 13 | const bcryptHashPromise = promisify2<any, string | number, string>(hash) |
14 | 14 | ||
15 | const httpSignature = require('http-signature') | 15 | const httpSignature = require('http-signature') |
16 | 16 | ||
@@ -129,7 +129,7 @@ export { | |||
129 | 129 | ||
130 | // --------------------------------------------------------------------------- | 130 | // --------------------------------------------------------------------------- |
131 | 131 | ||
132 | function hash (obj: any): Promise<any> { | 132 | function 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 | ||
157 | function createDocWithoutSignatureHash (doc: any) { | 157 | function 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 @@ | |||
1 | import * as short from 'short-uuid' | 1 | import short, { uuid } from 'short-uuid' |
2 | 2 | ||
3 | const translator = short() | 3 | const translator = short() |
4 | 4 | ||
5 | function buildUUID () { | 5 | function buildUUID () { |
6 | return short.uuid() | 6 | return uuid() |
7 | } | 7 | } |
8 | 8 | ||
9 | function uuidToShort (uuid: string) { | 9 | function 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 @@ | |||
1 | import * as bencode from 'bencode' | 1 | import { decode, encode } from 'bencode' |
2 | import * as createTorrent from 'create-torrent' | 2 | import createTorrent from 'create-torrent' |
3 | import { createWriteStream, ensureDir, readFile, remove, writeFile } from 'fs-extra' | 3 | import { createWriteStream, ensureDir, readFile, remove, writeFile } from 'fs-extra' |
4 | import * as magnetUtil from 'magnet-uri' | 4 | import magnetUtil from 'magnet-uri' |
5 | import * as parseTorrent from 'parse-torrent' | 5 | import parseTorrent from 'parse-torrent' |
6 | import { dirname, join } from 'path' | 6 | import { dirname, join } from 'path' |
7 | import * as WebTorrent from 'webtorrent' | 7 | import { pipeline } from 'stream' |
8 | import WebTorrent, { Instance, TorrentFile } from 'webtorrent' | ||
8 | import { isArray } from '@server/helpers/custom-validators/misc' | 9 | import { isArray } from '@server/helpers/custom-validators/misc' |
9 | import { WEBSERVER } from '@server/initializers/constants' | 10 | import { WEBSERVER } from '@server/initializers/constants' |
10 | import { generateTorrentFileName } from '@server/lib/paths' | 11 | import { generateTorrentFileName } from '@server/lib/paths' |
@@ -17,7 +18,6 @@ import { promisify2 } from './core-utils' | |||
17 | import { logger } from './logger' | 18 | import { logger } from './logger' |
18 | import { generateVideoImportTmpPath } from './utils' | 19 | import { generateVideoImportTmpPath } from './utils' |
19 | import { extractVideo } from './video' | 20 | import { extractVideo } from './video' |
20 | import { pipeline } from 'stream' | ||
21 | 21 | ||
22 | const createTorrentPromise = promisify2<string, any, any>(createTorrent) | 22 | const 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 | ||
182 | function safeWebtorrentDestroy ( | 182 | function 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 @@ | |||
1 | import * as config from 'config' | 1 | import { util, has, get } from 'config' |
2 | import { uniq } from 'lodash' | 2 | import { uniq } from 'lodash' |
3 | import { URL } from 'url' | 3 | import { URL } from 'url' |
4 | import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils' | 4 | import { 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 () { | |||
36 | function checkConfig () { | 36 | function 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 @@ | |||
1 | import * as config from 'config' | 1 | import { IConfig } from 'config' |
2 | import { parseSemVersion, promisify0 } from '../helpers/core-utils' | 2 | import { parseSemVersion, promisify0 } from '../helpers/core-utils' |
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | 4 | ||
5 | // Special behaviour for config because we can reload it | ||
6 | const 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 @@ | |||
1 | import * as bytes from 'bytes' | 1 | import bytes from 'bytes' |
2 | import { IConfig } from 'config' | 2 | import { IConfig } from 'config' |
3 | import decache from 'decache' | 3 | import decache from 'decache' |
4 | import { dirname, join } from 'path' | 4 | import { 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 @@ | |||
1 | import * as passwordGenerator from 'password-generator' | 1 | import { ensureDir, remove } from 'fs-extra' |
2 | import passwordGenerator from 'password-generator' | ||
2 | import { UserRole } from '../../shared' | 3 | import { UserRole } from '../../shared' |
3 | import { logger } from '../helpers/logger' | 4 | import { logger } from '../helpers/logger' |
4 | import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' | 5 | import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' |
5 | import { UserModel } from '../models/user/user' | ||
6 | import { ApplicationModel } from '../models/application/application' | 6 | import { ApplicationModel } from '../models/application/application' |
7 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 7 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
8 | import { UserModel } from '../models/user/user' | ||
8 | import { applicationExist, clientsExist, usersExist } from './checker-after-init' | 9 | import { applicationExist, clientsExist, usersExist } from './checker-after-init' |
10 | import { CONFIG } from './config' | ||
9 | import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants' | 11 | import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION, RESUMABLE_UPLOAD_DIRECTORY } from './constants' |
10 | import { sequelizeTypescript } from './database' | 12 | import { sequelizeTypescript } from './database' |
11 | import { ensureDir, remove } from 'fs-extra' | ||
12 | import { CONFIG } from './config' | ||
13 | 13 | ||
14 | async function installApplication () { | 14 | async 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 @@ | |||
1 | import * as path from 'path' | 1 | import { readdir } from 'fs-extra' |
2 | import { join } from 'path' | ||
3 | import { QueryTypes } from 'sequelize' | ||
2 | import { logger } from '../helpers/logger' | 4 | import { logger } from '../helpers/logger' |
3 | import { LAST_MIGRATION_VERSION } from './constants' | 5 | import { LAST_MIGRATION_VERSION } from './constants' |
4 | import { sequelizeTypescript } from './database' | 6 | import { sequelizeTypescript } from './database' |
5 | import { readdir } from 'fs-extra' | ||
6 | import { QueryTypes } from 'sequelize' | ||
7 | 7 | ||
8 | async function migrate () { | 8 | async 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 | ||
60 | async function getMigrationScripts () { | 60 | async 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 @@ | |||
1 | import * as WebFinger from 'webfinger.js' | 1 | import WebFinger from 'webfinger.js' |
2 | import { isProdInstance } from '@server/helpers/core-utils' | 2 | import { isProdInstance } from '@server/helpers/core-utils' |
3 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' | 3 | import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc' |
4 | import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants' | 4 | import { REQUEST_TIMEOUT, WEBSERVER } from '@server/initializers/constants' |
diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts index 28ff5225a..336129b82 100644 --- a/server/lib/activitypub/crawl.ts +++ b/server/lib/activitypub/crawl.ts | |||
@@ -1,13 +1,13 @@ | |||
1 | import { retryTransactionWrapper } from '@server/helpers/database-utils' | 1 | import Bluebird from 'bluebird' |
2 | import * as Bluebird from 'bluebird' | ||
3 | import { URL } from 'url' | 2 | import { URL } from 'url' |
3 | import { retryTransactionWrapper } from '@server/helpers/database-utils' | ||
4 | import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' | 4 | import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' |
5 | import { logger } from '../../helpers/logger' | 5 | import { logger } from '../../helpers/logger' |
6 | import { doJSONRequest } from '../../helpers/requests' | 6 | import { doJSONRequest } from '../../helpers/requests' |
7 | import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants' | 7 | import { ACTIVITY_PUB, WEBSERVER } from '../../initializers/constants' |
8 | 8 | ||
9 | type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) | 9 | type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) |
10 | type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) | 10 | type CleanerFunction = (startedDate: Date) => Promise<any> |
11 | 11 | ||
12 | async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) { | 12 | async function crawlCollectionPage <T> (argUrl: string, handler: HandlerFunction<T>, cleaner?: CleanerFunction) { |
13 | let url = argUrl | 13 | let url = argUrl |
diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/lib/activitypub/playlists/create-update.ts index ea3e61ac5..b152d709c 100644 --- a/server/lib/activitypub/playlists/create-update.ts +++ b/server/lib/activitypub/playlists/create-update.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { getAPId } from '@server/helpers/activitypub' | 2 | import { getAPId } from '@server/helpers/activitypub' |
3 | import { isArray } from '@server/helpers/custom-validators/misc' | 3 | import { isArray } from '@server/helpers/custom-validators/misc' |
4 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 4 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
@@ -24,7 +24,7 @@ import { | |||
24 | const lTags = loggerTagsFactory('ap', 'video-playlist') | 24 | const lTags = loggerTagsFactory('ap', 'video-playlist') |
25 | 25 | ||
26 | async function createAccountPlaylists (playlistUrls: string[]) { | 26 | async function createAccountPlaylists (playlistUrls: string[]) { |
27 | await Bluebird.map(playlistUrls, async playlistUrl => { | 27 | await map(playlistUrls, async playlistUrl => { |
28 | try { | 28 | try { |
29 | const exists = await VideoPlaylistModel.doesPlaylistExist(playlistUrl) | 29 | const exists = await VideoPlaylistModel.doesPlaylistExist(playlistUrl) |
30 | if (exists === true) return | 30 | if (exists === true) return |
@@ -140,7 +140,7 @@ async function rebuildVideoPlaylistElements (elementUrls: string[], playlist: MV | |||
140 | async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) { | 140 | async function buildElementsDBAttributes (elementUrls: string[], playlist: MVideoPlaylist) { |
141 | const elementsToCreate: FilteredModelAttributes<VideoPlaylistElementModel>[] = [] | 141 | const elementsToCreate: FilteredModelAttributes<VideoPlaylistElementModel>[] = [] |
142 | 142 | ||
143 | await Bluebird.map(elementUrls, async elementUrl => { | 143 | await map(elementUrls, async elementUrl => { |
144 | try { | 144 | try { |
145 | const { elementObject } = await fetchRemotePlaylistElement(elementUrl) | 145 | const { elementObject } = await fetchRemotePlaylistElement(elementUrl) |
146 | 146 | ||
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index 1ff01a175..b18761174 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { Transaction } from 'sequelize' | 2 | import { Transaction } from 'sequelize' |
3 | import { getServerActor } from '@server/models/application/application' | 3 | import { getServerActor } from '@server/models/application/application' |
4 | import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' | 4 | import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' |
@@ -38,7 +38,7 @@ async function changeVideoChannelShare ( | |||
38 | } | 38 | } |
39 | 39 | ||
40 | async function addVideoShares (shareUrls: string[], video: MVideoId) { | 40 | async function addVideoShares (shareUrls: string[], video: MVideoId) { |
41 | await Bluebird.map(shareUrls, async shareUrl => { | 41 | await map(shareUrls, async shareUrl => { |
42 | try { | 42 | try { |
43 | await addVideoShare(shareUrl, video) | 43 | await addVideoShare(shareUrl, video) |
44 | } catch (err) { | 44 | } catch (err) { |
diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts index 6b7f9504f..2a14790fe 100644 --- a/server/lib/activitypub/video-comments.ts +++ b/server/lib/activitypub/video-comments.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { checkUrlsSameHost } from '../../helpers/activitypub' | 2 | import { checkUrlsSameHost } from '../../helpers/activitypub' |
3 | import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' | 3 | import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' |
4 | import { logger } from '../../helpers/logger' | 4 | import { logger } from '../../helpers/logger' |
@@ -18,7 +18,7 @@ type ResolveThreadParams = { | |||
18 | type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }> | 18 | type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }> |
19 | 19 | ||
20 | async function addVideoComments (commentUrls: string[]) { | 20 | async function addVideoComments (commentUrls: string[]) { |
21 | return Bluebird.map(commentUrls, async commentUrl => { | 21 | return map(commentUrls, async commentUrl => { |
22 | try { | 22 | try { |
23 | await resolveThread({ url: commentUrl, isVideo: false }) | 23 | await resolveThread({ url: commentUrl, isVideo: false }) |
24 | } catch (err) { | 24 | } catch (err) { |
diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts index 9fb97ef84..04aa5eae9 100644 --- a/server/lib/activitypub/video-rates.ts +++ b/server/lib/activitypub/video-rates.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { Transaction } from 'sequelize' | 2 | import { Transaction } from 'sequelize' |
3 | import { doJSONRequest } from '@server/helpers/requests' | 3 | import { doJSONRequest } from '@server/helpers/requests' |
4 | import { VideoRateType } from '../../../shared/models/videos' | 4 | import { VideoRateType } from '../../../shared/models/videos' |
@@ -15,7 +15,7 @@ import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlBy | |||
15 | const lTags = loggerTagsFactory('ap', 'video-rate', 'create') | 15 | const lTags = loggerTagsFactory('ap', 'video-rate', 'create') |
16 | 16 | ||
17 | async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) { | 17 | async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) { |
18 | await Bluebird.map(ratesUrl, async rateUrl => { | 18 | await map(ratesUrl, async rateUrl => { |
19 | try { | 19 | try { |
20 | await createRate(rateUrl, video, rate) | 20 | await createRate(rateUrl, video, rate) |
21 | } catch (err) { | 21 | } catch (err) { |
diff --git a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts index bd9ed45a9..62354ab56 100644 --- a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts +++ b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { maxBy, minBy } from 'lodash' | 1 | import { maxBy, minBy } from 'lodash' |
2 | import * as magnetUtil from 'magnet-uri' | 2 | import magnetUtil from 'magnet-uri' |
3 | import { basename } from 'path' | 3 | import { basename } from 'path' |
4 | import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos' | 4 | import { isAPVideoFileUrlMetadataObject } from '@server/helpers/custom-validators/activitypub/videos' |
5 | import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos' | 5 | import { isVideoFileInfoHashValid } from '@server/helpers/custom-validators/videos' |
diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts index ae728d080..f2ef0a78a 100644 --- a/server/lib/auth/oauth-model.ts +++ b/server/lib/auth/oauth-model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { AccessDeniedError } from 'oauth2-server' | 2 | import { AccessDeniedError } from 'oauth2-server' |
3 | import { PluginManager } from '@server/lib/plugins/plugin-manager' | 3 | import { PluginManager } from '@server/lib/plugins/plugin-manager' |
4 | import { ActorModel } from '@server/models/actor/actor' | 4 | import { ActorModel } from '@server/models/actor/actor' |
diff --git a/server/lib/auth/oauth.ts b/server/lib/auth/oauth.ts index a97681c86..497773536 100644 --- a/server/lib/auth/oauth.ts +++ b/server/lib/auth/oauth.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { | 2 | import { |
3 | InvalidClientError, | 3 | InvalidClientError, |
4 | InvalidGrantError, | 4 | InvalidGrantError, |
diff --git a/server/lib/auth/tokens-cache.ts b/server/lib/auth/tokens-cache.ts index b027ce69a..410708a35 100644 --- a/server/lib/auth/tokens-cache.ts +++ b/server/lib/auth/tokens-cache.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as LRUCache from 'lru-cache' | 1 | import LRUCache from 'lru-cache' |
2 | import { MOAuthTokenUser } from '@server/types/models' | 2 | import { MOAuthTokenUser } from '@server/types/models' |
3 | import { LRU_CACHE } from '../../initializers/constants' | 3 | import { LRU_CACHE } from '../../initializers/constants' |
4 | 4 | ||
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index e093d35f7..3b0a68f4d 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { readFile } from 'fs-extra' | 2 | import { readFile } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import validator from 'validator' | 4 | import validator from 'validator' |
diff --git a/server/lib/files-cache/abstract-video-static-file-cache.ts b/server/lib/files-cache/abstract-video-static-file-cache.ts index af66689a0..a7ac88525 100644 --- a/server/lib/files-cache/abstract-video-static-file-cache.ts +++ b/server/lib/files-cache/abstract-video-static-file-cache.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { remove } from 'fs-extra' | 1 | import { remove } from 'fs-extra' |
2 | import { logger } from '../../helpers/logger' | 2 | import { logger } from '../../helpers/logger' |
3 | import * as memoizee from 'memoizee' | 3 | import memoizee from 'memoizee' |
4 | 4 | ||
5 | type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined | 5 | type GetFilePathResult = { isOwned: boolean, path: string, downloadName?: string } | undefined |
6 | 6 | ||
diff --git a/server/lib/job-queue/handlers/activitypub-cleaner.ts b/server/lib/job-queue/handlers/activitypub-cleaner.ts index 56e2b0ceb..d5e4508fe 100644 --- a/server/lib/job-queue/handlers/activitypub-cleaner.ts +++ b/server/lib/job-queue/handlers/activitypub-cleaner.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import * as Bull from 'bull' | 2 | import { Job } from 'bull' |
3 | import { checkUrlsSameHost } from '@server/helpers/activitypub' | 3 | import { checkUrlsSameHost } from '@server/helpers/activitypub' |
4 | import { | 4 | import { |
5 | isAnnounceActivityValid, | 5 | isAnnounceActivityValid, |
@@ -18,14 +18,14 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat | |||
18 | 18 | ||
19 | // Job to clean remote interactions off local videos | 19 | // Job to clean remote interactions off local videos |
20 | 20 | ||
21 | async function processActivityPubCleaner (_job: Bull.Job) { | 21 | async function processActivityPubCleaner (_job: Job) { |
22 | logger.info('Processing ActivityPub cleaner.') | 22 | logger.info('Processing ActivityPub cleaner.') |
23 | 23 | ||
24 | { | 24 | { |
25 | const rateUrls = await AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos() | 25 | const rateUrls = await AccountVideoRateModel.listRemoteRateUrlsOfLocalVideos() |
26 | const { bodyValidator, deleter, updater } = rateOptionsFactory() | 26 | const { bodyValidator, deleter, updater } = rateOptionsFactory() |
27 | 27 | ||
28 | await Bluebird.map(rateUrls, async rateUrl => { | 28 | await map(rateUrls, async rateUrl => { |
29 | try { | 29 | try { |
30 | const result = await updateObjectIfNeeded(rateUrl, bodyValidator, updater, deleter) | 30 | const result = await updateObjectIfNeeded(rateUrl, bodyValidator, updater, deleter) |
31 | 31 | ||
@@ -44,7 +44,7 @@ async function processActivityPubCleaner (_job: Bull.Job) { | |||
44 | const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos() | 44 | const shareUrls = await VideoShareModel.listRemoteShareUrlsOfLocalVideos() |
45 | const { bodyValidator, deleter, updater } = shareOptionsFactory() | 45 | const { bodyValidator, deleter, updater } = shareOptionsFactory() |
46 | 46 | ||
47 | await Bluebird.map(shareUrls, async shareUrl => { | 47 | await map(shareUrls, async shareUrl => { |
48 | try { | 48 | try { |
49 | await updateObjectIfNeeded(shareUrl, bodyValidator, updater, deleter) | 49 | await updateObjectIfNeeded(shareUrl, bodyValidator, updater, deleter) |
50 | } catch (err) { | 50 | } catch (err) { |
@@ -57,7 +57,7 @@ async function processActivityPubCleaner (_job: Bull.Job) { | |||
57 | const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos() | 57 | const commentUrls = await VideoCommentModel.listRemoteCommentUrlsOfLocalVideos() |
58 | const { bodyValidator, deleter, updater } = commentOptionsFactory() | 58 | const { bodyValidator, deleter, updater } = commentOptionsFactory() |
59 | 59 | ||
60 | await Bluebird.map(commentUrls, async commentUrl => { | 60 | await map(commentUrls, async commentUrl => { |
61 | try { | 61 | try { |
62 | await updateObjectIfNeeded(commentUrl, bodyValidator, updater, deleter) | 62 | await updateObjectIfNeeded(commentUrl, bodyValidator, updater, deleter) |
63 | } catch (err) { | 63 | } catch (err) { |
diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index f896d7af4..91e3d33c6 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url' | 2 | import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url' |
3 | import { ActivitypubFollowPayload } from '@shared/models' | 3 | import { ActivitypubFollowPayload } from '@shared/models' |
4 | import { sanitizeHost } from '../../../helpers/core-utils' | 4 | import { sanitizeHost } from '../../../helpers/core-utils' |
@@ -13,7 +13,7 @@ import { getOrCreateAPActor, loadActorUrlOrGetFromWebfinger } from '../../activi | |||
13 | import { sendFollow } from '../../activitypub/send' | 13 | import { sendFollow } from '../../activitypub/send' |
14 | import { Notifier } from '../../notifier' | 14 | import { Notifier } from '../../notifier' |
15 | 15 | ||
16 | async function processActivityPubFollow (job: Bull.Job) { | 16 | async function processActivityPubFollow (job: Job) { |
17 | const payload = job.data as ActivitypubFollowPayload | 17 | const payload = job.data as ActivitypubFollowPayload |
18 | const host = payload.host | 18 | const host = payload.host |
19 | 19 | ||
diff --git a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts index d4b328635..9b0bb6574 100644 --- a/server/lib/job-queue/handlers/activitypub-http-broadcast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-broadcast.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import * as Bull from 'bull' | 2 | import { Job } from 'bull' |
3 | import { ActivitypubHttpBroadcastPayload } from '@shared/models' | 3 | import { ActivitypubHttpBroadcastPayload } from '@shared/models' |
4 | import { logger } from '../../../helpers/logger' | 4 | import { logger } from '../../../helpers/logger' |
5 | import { doRequest } from '../../../helpers/requests' | 5 | import { doRequest } from '../../../helpers/requests' |
@@ -7,7 +7,7 @@ import { BROADCAST_CONCURRENCY } from '../../../initializers/constants' | |||
7 | import { ActorFollowScoreCache } from '../../files-cache' | 7 | import { ActorFollowScoreCache } from '../../files-cache' |
8 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' | 8 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' |
9 | 9 | ||
10 | async function processActivityPubHttpBroadcast (job: Bull.Job) { | 10 | async function processActivityPubHttpBroadcast (job: Job) { |
11 | logger.info('Processing ActivityPub broadcast in job %d.', job.id) | 11 | logger.info('Processing ActivityPub broadcast in job %d.', job.id) |
12 | 12 | ||
13 | const payload = job.data as ActivitypubHttpBroadcastPayload | 13 | const payload = job.data as ActivitypubHttpBroadcastPayload |
@@ -25,7 +25,7 @@ async function processActivityPubHttpBroadcast (job: Bull.Job) { | |||
25 | const badUrls: string[] = [] | 25 | const badUrls: string[] = [] |
26 | const goodUrls: string[] = [] | 26 | const goodUrls: string[] = [] |
27 | 27 | ||
28 | await Bluebird.map(payload.uris, uri => { | 28 | await map(payload.uris, uri => { |
29 | return doRequest(uri, options) | 29 | return doRequest(uri, options) |
30 | .then(() => goodUrls.push(uri)) | 30 | .then(() => goodUrls.push(uri)) |
31 | .catch(() => badUrls.push(uri)) | 31 | .catch(() => badUrls.push(uri)) |
diff --git a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts index ab9675cae..46016a0a7 100644 --- a/server/lib/job-queue/handlers/activitypub-http-fetcher.ts +++ b/server/lib/job-queue/handlers/activitypub-http-fetcher.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' | 2 | import { ActivitypubHttpFetcherPayload, FetchType } from '@shared/models' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 4 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
@@ -13,7 +13,7 @@ import { addVideoShares } from '../../activitypub/share' | |||
13 | import { addVideoComments } from '../../activitypub/video-comments' | 13 | import { addVideoComments } from '../../activitypub/video-comments' |
14 | import { createRates } from '../../activitypub/video-rates' | 14 | import { createRates } from '../../activitypub/video-rates' |
15 | 15 | ||
16 | async function processActivityPubHttpFetcher (job: Bull.Job) { | 16 | async function processActivityPubHttpFetcher (job: Job) { |
17 | logger.info('Processing ActivityPub fetcher in job %d.', job.id) | 17 | logger.info('Processing ActivityPub fetcher in job %d.', job.id) |
18 | 18 | ||
19 | const payload = job.data as ActivitypubHttpFetcherPayload | 19 | const payload = job.data as ActivitypubHttpFetcherPayload |
diff --git a/server/lib/job-queue/handlers/activitypub-http-unicast.ts b/server/lib/job-queue/handlers/activitypub-http-unicast.ts index 9e561c6b7..9be50837f 100644 --- a/server/lib/job-queue/handlers/activitypub-http-unicast.ts +++ b/server/lib/job-queue/handlers/activitypub-http-unicast.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { ActivitypubHttpUnicastPayload } from '@shared/models' | 2 | import { ActivitypubHttpUnicastPayload } from '@shared/models' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { doRequest } from '../../../helpers/requests' | 4 | import { doRequest } from '../../../helpers/requests' |
5 | import { ActorFollowScoreCache } from '../../files-cache' | 5 | import { ActorFollowScoreCache } from '../../files-cache' |
6 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' | 6 | import { buildGlobalHeaders, buildSignedRequestOptions, computeBody } from './utils/activitypub-http-utils' |
7 | 7 | ||
8 | async function processActivityPubHttpUnicast (job: Bull.Job) { | 8 | async function processActivityPubHttpUnicast (job: Job) { |
9 | logger.info('Processing ActivityPub unicast in job %d.', job.id) | 9 | logger.info('Processing ActivityPub unicast in job %d.', job.id) |
10 | 10 | ||
11 | const payload = job.data as ActivitypubHttpUnicastPayload | 11 | const payload = job.data as ActivitypubHttpUnicastPayload |
diff --git a/server/lib/job-queue/handlers/activitypub-refresher.ts b/server/lib/job-queue/handlers/activitypub-refresher.ts index d97e50ebc..5037992d2 100644 --- a/server/lib/job-queue/handlers/activitypub-refresher.ts +++ b/server/lib/job-queue/handlers/activitypub-refresher.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists' | 2 | import { refreshVideoPlaylistIfNeeded } from '@server/lib/activitypub/playlists' |
3 | import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos' | 3 | import { refreshVideoIfNeeded } from '@server/lib/activitypub/videos' |
4 | import { loadVideoByUrl } from '@server/lib/model-loaders' | 4 | import { loadVideoByUrl } from '@server/lib/model-loaders' |
@@ -8,7 +8,7 @@ import { ActorModel } from '../../../models/actor/actor' | |||
8 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | 8 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' |
9 | import { refreshActorIfNeeded } from '../../activitypub/actors' | 9 | import { refreshActorIfNeeded } from '../../activitypub/actors' |
10 | 10 | ||
11 | async function refreshAPObject (job: Bull.Job) { | 11 | async function refreshAPObject (job: Job) { |
12 | const payload = job.data as RefreshPayload | 12 | const payload = job.data as RefreshPayload |
13 | 13 | ||
14 | logger.info('Processing AP refresher in job %d for %s.', job.id, payload.url) | 14 | logger.info('Processing AP refresher in job %d for %s.', job.id, payload.url) |
diff --git a/server/lib/job-queue/handlers/actor-keys.ts b/server/lib/job-queue/handlers/actor-keys.ts index 60ac61afd..9d5a65376 100644 --- a/server/lib/job-queue/handlers/actor-keys.ts +++ b/server/lib/job-queue/handlers/actor-keys.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors' | 2 | import { generateAndSaveActorKeys } from '@server/lib/activitypub/actors' |
3 | import { ActorModel } from '@server/models/actor/actor' | 3 | import { ActorModel } from '@server/models/actor/actor' |
4 | import { ActorKeysPayload } from '@shared/models' | 4 | import { ActorKeysPayload } from '@shared/models' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
6 | 6 | ||
7 | async function processActorKeys (job: Bull.Job) { | 7 | async function processActorKeys (job: Job) { |
8 | const payload = job.data as ActorKeysPayload | 8 | const payload = job.data as ActorKeysPayload |
9 | logger.info('Processing actor keys in job %d.', job.id) | 9 | logger.info('Processing actor keys in job %d.', job.id) |
10 | 10 | ||
diff --git a/server/lib/job-queue/handlers/email.ts b/server/lib/job-queue/handlers/email.ts index 3157731e2..6fc1caa84 100644 --- a/server/lib/job-queue/handlers/email.ts +++ b/server/lib/job-queue/handlers/email.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { EmailPayload } from '@shared/models' | ||
2 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
3 | import { Emailer } from '../../emailer' | 4 | import { Emailer } from '../../emailer' |
4 | import { EmailPayload } from '@shared/models' | ||
5 | 5 | ||
6 | async function processEmail (job: Bull.Job) { | 6 | async function processEmail (job: Job) { |
7 | const payload = job.data as EmailPayload | 7 | const payload = job.data as EmailPayload |
8 | logger.info('Processing email in job %d.', job.id) | 8 | logger.info('Processing email in job %d.', job.id) |
9 | 9 | ||
diff --git a/server/lib/job-queue/handlers/move-to-object-storage.ts b/server/lib/job-queue/handlers/move-to-object-storage.ts index f3b8726eb..0bebc0fc2 100644 --- a/server/lib/job-queue/handlers/move-to-object-storage.ts +++ b/server/lib/job-queue/handlers/move-to-object-storage.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { remove } from 'fs-extra' | 2 | import { remove } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { logger } from '@server/helpers/logger' | 4 | import { logger } from '@server/helpers/logger' |
@@ -12,7 +12,7 @@ import { VideoJobInfoModel } from '@server/models/video/video-job-info' | |||
12 | import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' | 12 | import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoWithAllFiles } from '@server/types/models' |
13 | import { MoveObjectStoragePayload, VideoStorage } from '../../../../shared' | 13 | import { MoveObjectStoragePayload, VideoStorage } from '../../../../shared' |
14 | 14 | ||
15 | export async function processMoveToObjectStorage (job: Bull.Job) { | 15 | export async function processMoveToObjectStorage (job: Job) { |
16 | const payload = job.data as MoveObjectStoragePayload | 16 | const payload = job.data as MoveObjectStoragePayload |
17 | logger.info('Moving video %s in job %d.', payload.videoUUID, job.id) | 17 | logger.info('Moving video %s in job %d.', payload.videoUUID, job.id) |
18 | 18 | ||
diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts index e8ee1f759..e6c918e6c 100644 --- a/server/lib/job-queue/handlers/video-file-import.ts +++ b/server/lib/job-queue/handlers/video-file-import.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { copy, stat } from 'fs-extra' | 2 | import { copy, stat } from 'fs-extra' |
3 | import { getLowercaseExtension } from '@server/helpers/core-utils' | 3 | import { getLowercaseExtension } from '@server/helpers/core-utils' |
4 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 4 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
@@ -16,7 +16,7 @@ import { VideoModel } from '../../../models/video/video' | |||
16 | import { VideoFileModel } from '../../../models/video/video-file' | 16 | import { VideoFileModel } from '../../../models/video/video-file' |
17 | import { createHlsJobIfEnabled } from './video-transcoding' | 17 | import { createHlsJobIfEnabled } from './video-transcoding' |
18 | 18 | ||
19 | async function processVideoFileImport (job: Bull.Job) { | 19 | async function processVideoFileImport (job: Job) { |
20 | const payload = job.data as VideoFileImportPayload | 20 | const payload = job.data as VideoFileImportPayload |
21 | logger.info('Processing video file import in job %d.', job.id) | 21 | logger.info('Processing video file import in job %d.', job.id) |
22 | 22 | ||
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index a5fa204f5..bdbf07a06 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { move, remove, stat } from 'fs-extra' | 2 | import { move, remove, stat } from 'fs-extra' |
3 | import { getLowercaseExtension } from '@server/helpers/core-utils' | 3 | import { getLowercaseExtension } from '@server/helpers/core-utils' |
4 | import { retryTransactionWrapper } from '@server/helpers/database-utils' | 4 | import { retryTransactionWrapper } from '@server/helpers/database-utils' |
@@ -37,7 +37,7 @@ import { federateVideoIfNeeded } from '../../activitypub/videos' | |||
37 | import { Notifier } from '../../notifier' | 37 | import { Notifier } from '../../notifier' |
38 | import { generateVideoMiniature } from '../../thumbnail' | 38 | import { generateVideoMiniature } from '../../thumbnail' |
39 | 39 | ||
40 | async function processVideoImport (job: Bull.Job) { | 40 | async function processVideoImport (job: Job) { |
41 | const payload = job.data as VideoImportPayload | 41 | const payload = job.data as VideoImportPayload |
42 | 42 | ||
43 | if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload) | 43 | if (payload.type === 'youtube-dl') return processYoutubeDLImport(job, payload) |
@@ -52,7 +52,7 @@ export { | |||
52 | 52 | ||
53 | // --------------------------------------------------------------------------- | 53 | // --------------------------------------------------------------------------- |
54 | 54 | ||
55 | async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentPayload) { | 55 | async function processTorrentImport (job: Job, payload: VideoImportTorrentPayload) { |
56 | logger.info('Processing torrent video import in job %d.', job.id) | 56 | logger.info('Processing torrent video import in job %d.', job.id) |
57 | 57 | ||
58 | const videoImport = await getVideoImportOrDie(payload.videoImportId) | 58 | const videoImport = await getVideoImportOrDie(payload.videoImportId) |
@@ -68,7 +68,7 @@ async function processTorrentImport (job: Bull.Job, payload: VideoImportTorrentP | |||
68 | return processFile(() => downloadWebTorrentVideo(target, VIDEO_IMPORT_TIMEOUT), videoImport, options) | 68 | return processFile(() => downloadWebTorrentVideo(target, VIDEO_IMPORT_TIMEOUT), videoImport, options) |
69 | } | 69 | } |
70 | 70 | ||
71 | async function processYoutubeDLImport (job: Bull.Job, payload: VideoImportYoutubeDLPayload) { | 71 | async function processYoutubeDLImport (job: Job, payload: VideoImportYoutubeDLPayload) { |
72 | logger.info('Processing youtubeDL video import in job %d.', job.id) | 72 | logger.info('Processing youtubeDL video import in job %d.', job.id) |
73 | 73 | ||
74 | const videoImport = await getVideoImportOrDie(payload.videoImportId) | 74 | const videoImport = await getVideoImportOrDie(payload.videoImportId) |
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 9ccf724c2..a04cfa2c9 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { pathExists, readdir, remove } from 'fs-extra' | 2 | import { pathExists, readdir, remove } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils' | 4 | import { ffprobePromise, getAudioStream, getDurationFromVideoFile, getVideoFileResolution } from '@server/helpers/ffprobe-utils' |
@@ -17,7 +17,7 @@ import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models' | |||
17 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' | 17 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' |
18 | import { logger } from '../../../helpers/logger' | 18 | import { logger } from '../../../helpers/logger' |
19 | 19 | ||
20 | async function processVideoLiveEnding (job: Bull.Job) { | 20 | async function processVideoLiveEnding (job: Job) { |
21 | const payload = job.data as VideoLiveEndingPayload | 21 | const payload = job.data as VideoLiveEndingPayload |
22 | 22 | ||
23 | function logError () { | 23 | function logError () { |
diff --git a/server/lib/job-queue/handlers/video-redundancy.ts b/server/lib/job-queue/handlers/video-redundancy.ts index 6296dab05..9cb7a6589 100644 --- a/server/lib/job-queue/handlers/video-redundancy.ts +++ b/server/lib/job-queue/handlers/video-redundancy.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { logger } from '../../../helpers/logger' | ||
3 | import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler' | 2 | import { VideosRedundancyScheduler } from '@server/lib/schedulers/videos-redundancy-scheduler' |
4 | import { VideoRedundancyPayload } from '@shared/models' | 3 | import { VideoRedundancyPayload } from '@shared/models' |
4 | import { logger } from '../../../helpers/logger' | ||
5 | 5 | ||
6 | async function processVideoRedundancy (job: Bull.Job) { | 6 | async function processVideoRedundancy (job: Job) { |
7 | const payload = job.data as VideoRedundancyPayload | 7 | const payload = job.data as VideoRedundancyPayload |
8 | logger.info('Processing video redundancy in job %d.', job.id) | 8 | logger.info('Processing video redundancy in job %d.', job.id) |
9 | 9 | ||
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 5a93c4ed1..20880cdc1 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bull from 'bull' | 1 | import { Job } from 'bull' |
2 | import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' | 2 | import { TranscodeOptionsType } from '@server/helpers/ffmpeg-utils' |
3 | import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' | 3 | import { addTranscodingJob, getTranscodingJobPriority } from '@server/lib/video' |
4 | import { VideoPathManager } from '@server/lib/video-path-manager' | 4 | import { VideoPathManager } from '@server/lib/video-path-manager' |
@@ -25,7 +25,7 @@ import { | |||
25 | transcodeNewWebTorrentResolution | 25 | transcodeNewWebTorrentResolution |
26 | } from '../../transcoding/video-transcoding' | 26 | } from '../../transcoding/video-transcoding' |
27 | 27 | ||
28 | type HandlerFunction = (job: Bull.Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void> | 28 | type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<void> |
29 | 29 | ||
30 | const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = { | 30 | const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = { |
31 | 'new-resolution-to-hls': handleHLSJob, | 31 | 'new-resolution-to-hls': handleHLSJob, |
@@ -36,7 +36,7 @@ const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = | |||
36 | 36 | ||
37 | const lTags = loggerTagsFactory('transcoding') | 37 | const lTags = loggerTagsFactory('transcoding') |
38 | 38 | ||
39 | async function processVideoTranscoding (job: Bull.Job) { | 39 | async function processVideoTranscoding (job: Job) { |
40 | const payload = job.data as VideoTranscodingPayload | 40 | const payload = job.data as VideoTranscodingPayload |
41 | logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID)) | 41 | logger.info('Processing transcoding job %d.', job.id, lTags(payload.videoUUID)) |
42 | 42 | ||
@@ -64,7 +64,7 @@ async function processVideoTranscoding (job: Bull.Job) { | |||
64 | // Job handlers | 64 | // Job handlers |
65 | // --------------------------------------------------------------------------- | 65 | // --------------------------------------------------------------------------- |
66 | 66 | ||
67 | async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) { | 67 | async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, video: MVideoFullLight, user: MUser) { |
68 | logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid)) | 68 | logger.info('Handling HLS transcoding job for %s.', video.uuid, lTags(video.uuid)) |
69 | 69 | ||
70 | const videoFileInput = payload.copyCodecs | 70 | const videoFileInput = payload.copyCodecs |
@@ -90,7 +90,7 @@ async function handleHLSJob (job: Bull.Job, payload: HLSTranscodingPayload, vide | |||
90 | } | 90 | } |
91 | 91 | ||
92 | async function handleNewWebTorrentResolutionJob ( | 92 | async function handleNewWebTorrentResolutionJob ( |
93 | job: Bull.Job, | 93 | job: Job, |
94 | payload: NewResolutionTranscodingPayload, | 94 | payload: NewResolutionTranscodingPayload, |
95 | video: MVideoFullLight, | 95 | video: MVideoFullLight, |
96 | user: MUserId | 96 | user: MUserId |
@@ -104,7 +104,7 @@ async function handleNewWebTorrentResolutionJob ( | |||
104 | await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload) | 104 | await retryTransactionWrapper(onNewWebTorrentFileResolution, video, user, payload) |
105 | } | 105 | } |
106 | 106 | ||
107 | async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { | 107 | async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { |
108 | logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid)) | 108 | logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid)) |
109 | 109 | ||
110 | await mergeAudioVideofile(video, payload.resolution, job) | 110 | await mergeAudioVideofile(video, payload.resolution, job) |
@@ -114,7 +114,7 @@ async function handleWebTorrentMergeAudioJob (job: Bull.Job, payload: MergeAudio | |||
114 | await retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user) | 114 | await retryTransactionWrapper(onVideoFileOptimizer, video, payload, 'video', user) |
115 | } | 115 | } |
116 | 116 | ||
117 | async function handleWebTorrentOptimizeJob (job: Bull.Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { | 117 | async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { |
118 | logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid)) | 118 | logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid)) |
119 | 119 | ||
120 | const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job) | 120 | const { transcodeType } = await optimizeOriginalVideofile(video, video.getMaxQualityFile(), job) |
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts index 7a3a1bf82..4cda12b57 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/lib/job-queue/job-queue.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bull from 'bull' | 1 | import Bull, { Job, JobOptions, Queue } from 'bull' |
2 | import { jobStates } from '@server/helpers/custom-validators/jobs' | 2 | import { jobStates } from '@server/helpers/custom-validators/jobs' |
3 | import { CONFIG } from '@server/initializers/config' | 3 | import { CONFIG } from '@server/initializers/config' |
4 | import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy' | 4 | import { processVideoRedundancy } from '@server/lib/job-queue/handlers/video-redundancy' |
@@ -30,12 +30,12 @@ import { processActivityPubHttpUnicast } from './handlers/activitypub-http-unica | |||
30 | import { refreshAPObject } from './handlers/activitypub-refresher' | 30 | import { refreshAPObject } from './handlers/activitypub-refresher' |
31 | import { processActorKeys } from './handlers/actor-keys' | 31 | import { processActorKeys } from './handlers/actor-keys' |
32 | import { processEmail } from './handlers/email' | 32 | import { processEmail } from './handlers/email' |
33 | import { processMoveToObjectStorage } from './handlers/move-to-object-storage' | ||
33 | import { processVideoFileImport } from './handlers/video-file-import' | 34 | import { processVideoFileImport } from './handlers/video-file-import' |
34 | import { processVideoImport } from './handlers/video-import' | 35 | import { processVideoImport } from './handlers/video-import' |
35 | import { processVideoLiveEnding } from './handlers/video-live-ending' | 36 | import { processVideoLiveEnding } from './handlers/video-live-ending' |
36 | import { processVideoTranscoding } from './handlers/video-transcoding' | 37 | import { processVideoTranscoding } from './handlers/video-transcoding' |
37 | import { processVideosViews } from './handlers/video-views' | 38 | import { processVideosViews } from './handlers/video-views' |
38 | import { processMoveToObjectStorage } from './handlers/move-to-object-storage' | ||
39 | 39 | ||
40 | type CreateJobArgument = | 40 | type CreateJobArgument = |
41 | { type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } | | 41 | { type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } | |
@@ -59,7 +59,7 @@ export type CreateJobOptions = { | |||
59 | priority?: number | 59 | priority?: number |
60 | } | 60 | } |
61 | 61 | ||
62 | const handlers: { [id in JobType]: (job: Bull.Job) => Promise<any> } = { | 62 | const handlers: { [id in JobType]: (job: Job) => Promise<any> } = { |
63 | 'activitypub-http-broadcast': processActivityPubHttpBroadcast, | 63 | 'activitypub-http-broadcast': processActivityPubHttpBroadcast, |
64 | 'activitypub-http-unicast': processActivityPubHttpUnicast, | 64 | 'activitypub-http-unicast': processActivityPubHttpUnicast, |
65 | 'activitypub-http-fetcher': processActivityPubHttpFetcher, | 65 | 'activitypub-http-fetcher': processActivityPubHttpFetcher, |
@@ -99,7 +99,7 @@ class JobQueue { | |||
99 | 99 | ||
100 | private static instance: JobQueue | 100 | private static instance: JobQueue |
101 | 101 | ||
102 | private queues: { [id in JobType]?: Bull.Queue } = {} | 102 | private queues: { [id in JobType]?: Queue } = {} |
103 | private initialized = false | 103 | private initialized = false |
104 | private jobRedisPrefix: string | 104 | private jobRedisPrefix: string |
105 | 105 | ||
@@ -160,7 +160,7 @@ class JobQueue { | |||
160 | return | 160 | return |
161 | } | 161 | } |
162 | 162 | ||
163 | const jobArgs: Bull.JobOptions = { | 163 | const jobArgs: JobOptions = { |
164 | backoff: { delay: 60 * 1000, type: 'exponential' }, | 164 | backoff: { delay: 60 * 1000, type: 'exponential' }, |
165 | attempts: JOB_ATTEMPTS[obj.type], | 165 | attempts: JOB_ATTEMPTS[obj.type], |
166 | timeout: JOB_TTL[obj.type], | 166 | timeout: JOB_TTL[obj.type], |
@@ -177,11 +177,11 @@ class JobQueue { | |||
177 | count: number | 177 | count: number |
178 | asc?: boolean | 178 | asc?: boolean |
179 | jobType: JobType | 179 | jobType: JobType |
180 | }): Promise<Bull.Job[]> { | 180 | }): Promise<Job[]> { |
181 | const { state, start, count, asc, jobType } = options | 181 | const { state, start, count, asc, jobType } = options |
182 | 182 | ||
183 | const states = state ? [ state ] : jobStates | 183 | const states = state ? [ state ] : jobStates |
184 | let results: Bull.Job[] = [] | 184 | let results: Job[] = [] |
185 | 185 | ||
186 | const filteredJobTypes = this.filterJobTypes(jobType) | 186 | const filteredJobTypes = this.filterJobTypes(jobType) |
187 | 187 | ||
diff --git a/server/lib/live/shared/muxing-session.ts b/server/lib/live/shared/muxing-session.ts index 0c9fb0cb6..a6907142d 100644 --- a/server/lib/live/shared/muxing-session.ts +++ b/server/lib/live/shared/muxing-session.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | import * as Bluebird from 'bluebird' | 2 | import { mapSeries } from 'bluebird' |
3 | import * as chokidar from 'chokidar' | 3 | import { FSWatcher, watch } from 'chokidar' |
4 | import { FfmpegCommand } from 'fluent-ffmpeg' | 4 | import { FfmpegCommand } from 'fluent-ffmpeg' |
5 | import { appendFile, ensureDir, readFile, stat } from 'fs-extra' | 5 | import { appendFile, ensureDir, readFile, stat } from 'fs-extra' |
6 | import { basename, join } from 'path' | 6 | import { basename, join } from 'path' |
@@ -67,8 +67,8 @@ class MuxingSession extends EventEmitter { | |||
67 | 67 | ||
68 | private segmentsToProcessPerPlaylist: { [playlistId: string]: string[] } = {} | 68 | private segmentsToProcessPerPlaylist: { [playlistId: string]: string[] } = {} |
69 | 69 | ||
70 | private tsWatcher: chokidar.FSWatcher | 70 | private tsWatcher: FSWatcher |
71 | private masterWatcher: chokidar.FSWatcher | 71 | private masterWatcher: FSWatcher |
72 | 72 | ||
73 | private readonly isAbleToUploadVideoWithCache = memoizee((userId: number) => { | 73 | private readonly isAbleToUploadVideoWithCache = memoizee((userId: number) => { |
74 | return isAbleToUploadVideo(userId, 1000) | 74 | return isAbleToUploadVideo(userId, 1000) |
@@ -197,7 +197,7 @@ class MuxingSession extends EventEmitter { | |||
197 | } | 197 | } |
198 | 198 | ||
199 | private watchMasterFile (outPath: string) { | 199 | private watchMasterFile (outPath: string) { |
200 | this.masterWatcher = chokidar.watch(outPath + '/' + this.streamingPlaylist.playlistFilename) | 200 | this.masterWatcher = watch(outPath + '/' + this.streamingPlaylist.playlistFilename) |
201 | 201 | ||
202 | this.masterWatcher.on('add', () => { | 202 | this.masterWatcher.on('add', () => { |
203 | this.emit('master-playlist-created', { videoId: this.videoId }) | 203 | this.emit('master-playlist-created', { videoId: this.videoId }) |
@@ -210,7 +210,7 @@ class MuxingSession extends EventEmitter { | |||
210 | private watchTSFiles (outPath: string) { | 210 | private watchTSFiles (outPath: string) { |
211 | const startStreamDateTime = new Date().getTime() | 211 | const startStreamDateTime = new Date().getTime() |
212 | 212 | ||
213 | this.tsWatcher = chokidar.watch(outPath + '/*.ts') | 213 | this.tsWatcher = watch(outPath + '/*.ts') |
214 | 214 | ||
215 | const playlistIdMatcher = /^([\d+])-/ | 215 | const playlistIdMatcher = /^([\d+])-/ |
216 | 216 | ||
@@ -306,7 +306,7 @@ class MuxingSession extends EventEmitter { | |||
306 | } | 306 | } |
307 | 307 | ||
308 | private processSegments (hlsVideoPath: string, segmentPaths: string[]) { | 308 | private processSegments (hlsVideoPath: string, segmentPaths: string[]) { |
309 | Bluebird.mapSeries(segmentPaths, async previousSegment => { | 309 | mapSeries(segmentPaths, async previousSegment => { |
310 | // Add sha hash of previous segments, because ffmpeg should have finished generating them | 310 | // Add sha hash of previous segments, because ffmpeg should have finished generating them |
311 | await LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment) | 311 | await LiveSegmentShaStore.Instance.addSegmentSha(this.videoUUID, previousSegment) |
312 | 312 | ||
diff --git a/server/lib/local-actor.ts b/server/lib/local-actor.ts index 77667f6b0..821a92b91 100644 --- a/server/lib/local-actor.ts +++ b/server/lib/local-actor.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import { queue } from 'async' | 2 | import { queue } from 'async' |
3 | import * as LRUCache from 'lru-cache' | 3 | import LRUCache from 'lru-cache' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { getLowercaseExtension } from '@server/helpers/core-utils' | 5 | import { getLowercaseExtension } from '@server/helpers/core-utils' |
6 | import { buildUUID } from '@server/helpers/uuid' | 6 | import { buildUUID } from '@server/helpers/uuid' |
diff --git a/server/lib/peertube-socket.ts b/server/lib/peertube-socket.ts index 0740e378e..901435dea 100644 --- a/server/lib/peertube-socket.ts +++ b/server/lib/peertube-socket.ts | |||
@@ -1,23 +1,23 @@ | |||
1 | import { Server } from 'http' | 1 | import { Server as HTTPServer } from 'http' |
2 | import * as SocketIO from 'socket.io' | 2 | import { Namespace, Server as SocketServer, Socket } from 'socket.io' |
3 | import { isIdValid } from '@server/helpers/custom-validators/misc' | ||
3 | import { MVideo } from '@server/types/models' | 4 | import { MVideo } from '@server/types/models' |
4 | import { UserNotificationModelForApi } from '@server/types/models/user' | 5 | import { UserNotificationModelForApi } from '@server/types/models/user' |
5 | import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' | 6 | import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' |
6 | import { logger } from '../helpers/logger' | 7 | import { logger } from '../helpers/logger' |
7 | import { authenticateSocket } from '../middlewares' | 8 | import { authenticateSocket } from '../middlewares' |
8 | import { isIdValid } from '@server/helpers/custom-validators/misc' | ||
9 | 9 | ||
10 | class PeerTubeSocket { | 10 | class PeerTubeSocket { |
11 | 11 | ||
12 | private static instance: PeerTubeSocket | 12 | private static instance: PeerTubeSocket |
13 | 13 | ||
14 | private userNotificationSockets: { [ userId: number ]: SocketIO.Socket[] } = {} | 14 | private userNotificationSockets: { [ userId: number ]: Socket[] } = {} |
15 | private liveVideosNamespace: SocketIO.Namespace | 15 | private liveVideosNamespace: Namespace |
16 | 16 | ||
17 | private constructor () {} | 17 | private constructor () {} |
18 | 18 | ||
19 | init (server: Server) { | 19 | init (server: HTTPServer) { |
20 | const io = new SocketIO.Server(server) | 20 | const io = new SocketServer(server) |
21 | 21 | ||
22 | io.of('/user-notifications') | 22 | io.of('/user-notifications') |
23 | .use(authenticateSocket) | 23 | .use(authenticateSocket) |
diff --git a/server/lib/plugins/hooks.ts b/server/lib/plugins/hooks.ts index 5e97b52a0..327aaece2 100644 --- a/server/lib/plugins/hooks.ts +++ b/server/lib/plugins/hooks.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import Bluebird from 'bluebird' |
2 | import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models' | 2 | import { ServerActionHookName, ServerFilterHookName } from '../../../shared/models' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { PluginManager } from './plugin-manager' | 4 | import { PluginManager } from './plugin-manager' |
diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.ts index 8487672ba..e26776f45 100644 --- a/server/lib/plugins/plugin-helpers-builder.ts +++ b/server/lib/plugins/plugin-helpers-builder.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { buildLogger } from '@server/helpers/logger' | 3 | import { buildLogger } from '@server/helpers/logger' |
4 | import { CONFIG } from '@server/initializers/config' | 4 | import { CONFIG } from '@server/initializers/config' |
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index 6599bccca..d4d2a7edc 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import decache from 'decache' | 1 | import decache from 'decache' |
2 | import * as express from 'express' | 2 | import express from 'express' |
3 | import { createReadStream, createWriteStream } from 'fs' | 3 | import { createReadStream, createWriteStream } from 'fs' |
4 | import { ensureDir, outputFile, readJSON } from 'fs-extra' | 4 | import { ensureDir, outputFile, readJSON } from 'fs-extra' |
5 | import { basename, join } from 'path' | 5 | import { basename, join } from 'path' |
diff --git a/server/lib/plugins/register-helpers.ts b/server/lib/plugins/register-helpers.ts index af533effd..acca9309a 100644 --- a/server/lib/plugins/register-helpers.ts +++ b/server/lib/plugins/register-helpers.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { logger } from '@server/helpers/logger' | 2 | import { logger } from '@server/helpers/logger' |
3 | import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth' | 3 | import { onExternalUserAuthenticated } from '@server/lib/auth/external-auth' |
4 | import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory' | 4 | import { VideoConstantManagerFactory } from '@server/lib/plugins/video-constant-manager-factory' |
diff --git a/server/lib/redis.ts b/server/lib/redis.ts index 62641e313..d1d88d853 100644 --- a/server/lib/redis.ts +++ b/server/lib/redis.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { createClient, RedisClient } from 'redis' | 2 | import { createClient, RedisClient } from 'redis' |
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | import { generateRandomString } from '../helpers/utils' | 4 | import { generateRandomString } from '../helpers/utils' |
diff --git a/server/lib/schedulers/abstract-scheduler.ts b/server/lib/schedulers/abstract-scheduler.ts index 0e6088911..f3d51a22e 100644 --- a/server/lib/schedulers/abstract-scheduler.ts +++ b/server/lib/schedulers/abstract-scheduler.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import Bluebird from 'bluebird' | ||
1 | import { logger } from '../../helpers/logger' | 2 | import { logger } from '../../helpers/logger' |
2 | import * as Bluebird from 'bluebird' | ||
3 | 3 | ||
4 | export abstract class AbstractScheduler { | 4 | export abstract class AbstractScheduler { |
5 | 5 | ||
diff --git a/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts b/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts index 1acea7998..099fa5651 100644 --- a/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts +++ b/server/lib/schedulers/remove-dangling-resumable-uploads-scheduler.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as bluebird from 'bluebird' | 1 | import { map } from 'bluebird' |
2 | import { readdir, remove, stat } from 'fs-extra' | 2 | import { readdir, remove, stat } from 'fs-extra' |
3 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 3 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
4 | import { getResumableUploadPath } from '@server/helpers/upload' | 4 | import { getResumableUploadPath } from '@server/helpers/upload' |
@@ -32,7 +32,7 @@ export class RemoveDanglingResumableUploadsScheduler extends AbstractScheduler { | |||
32 | logger.debug('Reading resumable video upload folder %s with %d files', path, metafiles.length, lTags()) | 32 | logger.debug('Reading resumable video upload folder %s with %d files', path, metafiles.length, lTags()) |
33 | 33 | ||
34 | try { | 34 | try { |
35 | await bluebird.map(metafiles, metafile => { | 35 | await map(metafiles, metafile => { |
36 | return this.deleteIfOlderThan(metafile, this.lastExecutionTimeMs) | 36 | return this.deleteIfOlderThan(metafile, this.lastExecutionTimeMs) |
37 | }, { concurrency: 5 }) | 37 | }, { concurrency: 5 }) |
38 | } catch (error) { | 38 | } catch (error) { |
diff --git a/server/lib/search.ts b/server/lib/search.ts index b643a4055..2f4c5eed9 100644 --- a/server/lib/search.ts +++ b/server/lib/search.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { CONFIG } from '@server/initializers/config' | 2 | import { CONFIG } from '@server/initializers/config' |
3 | import { AccountBlocklistModel } from '@server/models/account/account-blocklist' | 3 | import { AccountBlocklistModel } from '@server/models/account/account-blocklist' |
4 | import { getServerActor } from '@server/models/application/application' | 4 | import { getServerActor } from '@server/models/application/application' |
diff --git a/server/lib/signup.ts b/server/lib/signup.ts index 8fa81e601..3c1397a12 100644 --- a/server/lib/signup.ts +++ b/server/lib/signup.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { UserModel } from '../models/user/user' | 1 | import { IPv4, IPv6, parse, subnetMatch } from 'ipaddr.js' |
2 | import * as ipaddr from 'ipaddr.js' | ||
3 | import { CONFIG } from '../initializers/config' | 2 | import { CONFIG } from '../initializers/config' |
3 | import { UserModel } from '../models/user/user' | ||
4 | 4 | ||
5 | const isCidr = require('is-cidr') | 5 | const isCidr = require('is-cidr') |
6 | 6 | ||
@@ -22,7 +22,7 @@ async function isSignupAllowed (): Promise<{ allowed: boolean, errorMessage?: st | |||
22 | function isSignupAllowedForCurrentIP (ip: string) { | 22 | function isSignupAllowedForCurrentIP (ip: string) { |
23 | if (!ip) return false | 23 | if (!ip) return false |
24 | 24 | ||
25 | const addr = ipaddr.parse(ip) | 25 | const addr = parse(ip) |
26 | const excludeList = [ 'blacklist' ] | 26 | const excludeList = [ 'blacklist' ] |
27 | let matched = '' | 27 | let matched = '' |
28 | 28 | ||
@@ -32,23 +32,23 @@ function isSignupAllowedForCurrentIP (ip: string) { | |||
32 | } | 32 | } |
33 | 33 | ||
34 | if (addr.kind() === 'ipv4') { | 34 | if (addr.kind() === 'ipv4') { |
35 | const addrV4 = ipaddr.IPv4.parse(ip) | 35 | const addrV4 = IPv4.parse(ip) |
36 | const rangeList = { | 36 | const rangeList = { |
37 | whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v4(cidr)) | 37 | whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v4(cidr)) |
38 | .map(cidr => ipaddr.IPv4.parseCIDR(cidr)), | 38 | .map(cidr => IPv4.parseCIDR(cidr)), |
39 | blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v4(cidr)) | 39 | blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v4(cidr)) |
40 | .map(cidr => ipaddr.IPv4.parseCIDR(cidr)) | 40 | .map(cidr => IPv4.parseCIDR(cidr)) |
41 | } | 41 | } |
42 | matched = ipaddr.subnetMatch(addrV4, rangeList, 'unknown') | 42 | matched = subnetMatch(addrV4, rangeList, 'unknown') |
43 | } else if (addr.kind() === 'ipv6') { | 43 | } else if (addr.kind() === 'ipv6') { |
44 | const addrV6 = ipaddr.IPv6.parse(ip) | 44 | const addrV6 = IPv6.parse(ip) |
45 | const rangeList = { | 45 | const rangeList = { |
46 | whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v6(cidr)) | 46 | whitelist: CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isCidr.v6(cidr)) |
47 | .map(cidr => ipaddr.IPv6.parseCIDR(cidr)), | 47 | .map(cidr => IPv6.parseCIDR(cidr)), |
48 | blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v6(cidr)) | 48 | blacklist: CONFIG.SIGNUP.FILTERS.CIDR.BLACKLIST.filter(cidr => isCidr.v6(cidr)) |
49 | .map(cidr => ipaddr.IPv6.parseCIDR(cidr)) | 49 | .map(cidr => IPv6.parseCIDR(cidr)) |
50 | } | 50 | } |
51 | matched = ipaddr.subnetMatch(addrV6, rangeList, 'unknown') | 51 | matched = subnetMatch(addrV6, rangeList, 'unknown') |
52 | } | 52 | } |
53 | 53 | ||
54 | return !excludeList.includes(matched) | 54 | return !excludeList.includes(matched) |
diff --git a/server/lib/stat-manager.ts b/server/lib/stat-manager.ts index 3c5e0a93e..03063793d 100644 --- a/server/lib/stat-manager.ts +++ b/server/lib/stat-manager.ts | |||
@@ -1,14 +1,14 @@ | |||
1 | import { mapSeries } from 'bluebird' | ||
1 | import { CONFIG } from '@server/initializers/config' | 2 | import { CONFIG } from '@server/initializers/config' |
2 | import { UserModel } from '@server/models/user/user' | ||
3 | import { ActorFollowModel } from '@server/models/actor/actor-follow' | 3 | import { ActorFollowModel } from '@server/models/actor/actor-follow' |
4 | import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' | 4 | import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' |
5 | import { UserModel } from '@server/models/user/user' | ||
5 | import { VideoModel } from '@server/models/video/video' | 6 | import { VideoModel } from '@server/models/video/video' |
6 | import { VideoChannelModel } from '@server/models/video/video-channel' | 7 | import { VideoChannelModel } from '@server/models/video/video-channel' |
7 | import { VideoCommentModel } from '@server/models/video/video-comment' | 8 | import { VideoCommentModel } from '@server/models/video/video-comment' |
8 | import { VideoFileModel } from '@server/models/video/video-file' | 9 | import { VideoFileModel } from '@server/models/video/video-file' |
9 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' | 10 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' |
10 | import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models' | 11 | import { ActivityType, ServerStats, VideoRedundancyStrategyWithManual } from '@shared/models' |
11 | import * as Bluebird from 'bluebird' | ||
12 | 12 | ||
13 | class StatsManager { | 13 | class StatsManager { |
14 | 14 | ||
@@ -107,7 +107,7 @@ class StatsManager { | |||
107 | 107 | ||
108 | strategies.push({ strategy: 'manual', size: null }) | 108 | strategies.push({ strategy: 'manual', size: null }) |
109 | 109 | ||
110 | return Bluebird.mapSeries(strategies, r => { | 110 | return mapSeries(strategies, r => { |
111 | return VideoRedundancyModel.getStats(r.strategy) | 111 | return VideoRedundancyModel.getStats(r.strategy) |
112 | .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size })) | 112 | .then(stats => Object.assign(stats, { strategy: r.strategy, totalSize: r.size })) |
113 | }) | 113 | }) |
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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { Socket } from 'socket.io' | 2 | import { Socket } from 'socket.io' |
3 | import { getAccessToken } from '@server/lib/auth/oauth-model' | 3 | import { getAccessToken } from '@server/lib/auth/oauth-model' |
4 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' | 4 | import { 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 | ||
4 | import * as express from 'express' | 4 | import express from 'express' |
5 | import { OutgoingHttpHeaders } from 'http' | 5 | import { OutgoingHttpHeaders } from 'http' |
6 | import { isTestInstance, parseDurationToMs } from '@server/helpers/core-utils' | 6 | import { isTestInstance, parseDurationToMs } from '@server/helpers/core-utils' |
7 | import { logger } from '@server/helpers/logger' | 7 | import { 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 @@ | |||
1 | import * as helmet from 'helmet' | 1 | import { contentSecurityPolicy } from 'helmet' |
2 | import { CONFIG } from '../initializers/config' | 2 | import { CONFIG } from '../initializers/config' |
3 | 3 | ||
4 | const baseDirectives = Object.assign({}, | 4 | const 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 | ||
25 | const baseCSP = helmet.contentSecurityPolicy({ | 25 | const baseCSP = contentSecurityPolicy({ |
26 | directives: baseDirectives, | 26 | directives: baseDirectives, |
27 | reportOnly: CONFIG.CSP.REPORT_ONLY | 27 | reportOnly: CONFIG.CSP.REPORT_ONLY |
28 | }) | 28 | }) |
29 | 29 | ||
30 | const embedCSP = helmet.contentSecurityPolicy({ | 30 | const 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | 2 | ||
3 | function openapiOperationDoc (options: { | 3 | function 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details' | 2 | import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details' |
3 | import { HttpStatusCode } from '@shared/models' | 3 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { PAGINATION } from '../initializers/constants' | 2 | import { PAGINATION } from '../initializers/constants' |
3 | 3 | ||
4 | function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) { | 4 | function 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' | 2 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
3 | import { getHostWithPort } from '../helpers/express-utils' | 3 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { SortType } from '../models/utils' | 2 | import { SortType } from '../models/utils' |
3 | 3 | ||
4 | const setDefaultSort = setDefaultSortFactory('-createdAt') | 4 | const 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { UserRight } from '../../shared' | 2 | import { UserRight } from '../../shared' |
3 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
4 | import { logger } from '../helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { | 3 | import { |
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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { param } from 'express-validator' | 2 | import { param } from 'express-validator' |
3 | import { isAccountNameValid } from '../../helpers/custom-validators/accounts' | 3 | import { isAccountNameValid } from '../../helpers/custom-validators/accounts' |
4 | import { logger } from '../../helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { getServerActor } from '@server/models/application/application' | 2 | import { getServerActor } from '@server/models/application/application' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import { PAGINATION } from '@server/initializers/constants' | 3 | import { PAGINATION } from '@server/initializers/constants' |
4 | import { logger } from '../../../helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { | 3 | import { |
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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { isActorImageFile } from '@server/helpers/custom-validators/actor-images' | 3 | import { isActorImageFile } from '@server/helpers/custom-validators/actor-images' |
4 | import { cleanUpReqFiles } from '../../helpers/express-utils' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param } from 'express-validator' | 2 | import { body, param } from 'express-validator' |
3 | import { getServerActor } from '@server/models/application/application' | 3 | import { getServerActor } from '@server/models/application/application' |
4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk' | 3 | import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk' |
4 | import { HttpStatusCode, UserRight } from '@shared/models' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { isIntOrNull } from '@server/helpers/custom-validators/misc' | 3 | import { isIntOrNull } from '@server/helpers/custom-validators/misc' |
4 | import { isEmailEnabled } from '@server/initializers/config' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { param, query } from 'express-validator' | 2 | import { param, query } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { isEachUniqueHandleValid, isFollowStateValid, isRemoteHandleValid } from '@server/helpers/custom-validators/follows' | 3 | import { isEachUniqueHandleValid, isFollowStateValid, isRemoteHandleValid } from '@server/helpers/custom-validators/follows' |
4 | import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { param, query } from 'express-validator' | 2 | import { param, query } from 'express-validator' |
3 | import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs' | 3 | import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs' |
4 | import { logger, loggerTagsFactory } from '../../helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import { isValidLogLevel } from '../../helpers/custom-validators/logs' | 3 | import { isValidLogLevel } from '../../helpers/custom-validators/logs' |
4 | import { isDateValid } from '../../helpers/custom-validators/misc' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { loadVideo } from '@server/lib/model-loaders' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import { PAGINATION } from '@server/initializers/constants' | 3 | import { PAGINATION } from '@server/initializers/constants' |
4 | import { logger } from '../../helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query, ValidationChain } from 'express-validator' | 2 | import { body, param, query, ValidationChain } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { PluginType } from '../../../shared/models/plugins/plugin.type' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies' | 3 | import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies' |
4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import { isSearchTargetValid } from '@server/helpers/custom-validators/search' | 3 | import { isSearchTargetValid } from '@server/helpers/custom-validators/search' |
4 | import { isHostValid } from '@server/helpers/custom-validators/servers' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { param, query, validationResult } from 'express-validator' | 2 | import { param, query, validationResult } from 'express-validator' |
3 | import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' | 3 | import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' |
4 | import { logger } from '../../../helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { VideoChannelModel } from '@server/models/video/video-channel' | 2 | import { VideoChannelModel } from '@server/models/video/video-channel' |
3 | import { MChannelBannerAccountDefault } from '@server/types/models' | 3 | import { MChannelBannerAccountDefault } from '@server/types/models' |
4 | import { HttpStatusCode } from '@shared/models' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { VideoCommentModel } from '@server/models/video/video-comment' | 2 | import { VideoCommentModel } from '@server/models/video/video-comment' |
3 | import { MVideoId } from '@server/types/models' | 3 | import { MVideoId } from '@server/types/models' |
4 | import { HttpStatusCode } from '@shared/models' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { VideoImportModel } from '@server/models/video/video-import' | 2 | import { VideoImportModel } from '@server/models/video/video-import' |
3 | import { HttpStatusCode } from '@shared/models' | 3 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' | 2 | import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' |
3 | import { HttpStatusCode } from '@shared/models' | 3 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' | 2 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' |
3 | import { MVideoPlaylist } from '@server/types/models' | 3 | import { MVideoPlaylist } from '@server/types/models' |
4 | import { HttpStatusCode } from '@shared/models' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { param } from 'express-validator' | 2 | import { param } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { isSafePath } from '../../helpers/custom-validators/misc' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, query } from 'express-validator' | 2 | import { body, query } from 'express-validator' |
3 | import { exists, isDateValid } from '../../helpers/custom-validators/misc' | 3 | import { exists, isDateValid } from '../../helpers/custom-validators/misc' |
4 | import { logger } from '../../helpers/logger' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, query } from 'express-validator' | 2 | import { body, query } from 'express-validator' |
3 | import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc' | 3 | import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc' |
4 | import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { omit } from 'lodash' | 3 | import { omit } from 'lodash' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, query } from 'express-validator' | 2 | import { body, query } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param } from 'express-validator' | 2 | import { body, param } from 'express-validator' |
3 | import { UserRight } from '../../../../shared' | 3 | import { UserRight } from '../../../../shared' |
4 | import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { VIDEO_CHANNELS } from '@server/initializers/constants' | 3 | import { VIDEO_CHANNELS } from '@server/initializers/constants' |
4 | import { MChannelAccountDefault, MUser } from '@server/types/models' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { MUserAccountUrl } from '@server/types/models' | 3 | import { MUserAccountUrl } from '@server/types/models' |
4 | import { UserRight } from '../../../../shared' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { isPreImportVideoAccepted } from '@server/lib/moderation' | 3 | import { isPreImportVideoAccepted } from '@server/lib/moderation' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' | 3 | import { CONSTRAINTS_FIELDS } from '@server/initializers/constants' |
4 | import { isLocalLiveVideoAccepted } from '@server/lib/moderation' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { param } from 'express-validator' | 2 | import { param } from 'express-validator' |
3 | import { isIdValid } from '@server/helpers/custom-validators/misc' | 3 | import { isIdValid } from '@server/helpers/custom-validators/misc' |
4 | import { checkUserCanTerminateOwnershipChange } from '@server/helpers/custom-validators/video-ownership' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query, ValidationChain } from 'express-validator' | 2 | import { body, param, query, ValidationChain } from 'express-validator' |
3 | import { ExpressPromiseHandler } from '@server/types/express' | 3 | import { ExpressPromiseHandler } from '@server/types/express' |
4 | import { MUserAccountId } from '@server/types/models' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { VideoRateType } from '../../../../shared/models/videos' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { param } from 'express-validator' | 2 | import { param } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { isIdValid } from '../../../helpers/custom-validators/misc' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { toIntOrNull } from '../../../helpers/custom-validators/misc' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { body, header, param, query, ValidationChain } from 'express-validator' | 2 | import { body, header, param, query, ValidationChain } from 'express-validator' |
3 | import { getResumableUploadPath } from '@server/helpers/upload' | 3 | import { getResumableUploadPath } from '@server/helpers/upload' |
4 | import { isAbleToUploadVideo } from '@server/lib/user' | 4 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger' | 4 | import { 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 @@ | |||
1 | import * as memoizee from 'memoizee' | 1 | import memoizee from 'memoizee' |
2 | import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' | 2 | import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript' |
3 | import { AttributesOnly } from '@shared/core-utils' | 3 | import { AttributesOnly } from '@shared/core-utils' |
4 | import { AccountModel } from '../account/account' | 4 | import { 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 @@ | |||
1 | import { Model } from 'sequelize-typescript' | 1 | import { Model } from 'sequelize-typescript' |
2 | import * as Bluebird from 'bluebird' | ||
3 | import { logger } from '@server/helpers/logger' | 2 | import { logger } from '@server/helpers/logger' |
4 | 3 | ||
5 | type ModelCacheType = | 4 | type 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 @@ | |||
1 | import { remove } from 'fs-extra' | 1 | import { remove } from 'fs-extra' |
2 | import * as memoizee from 'memoizee' | 2 | import memoizee from 'memoizee' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { FindOptions, Op, Transaction } from 'sequelize' | 4 | import { FindOptions, Op, Transaction } from 'sequelize' |
5 | import { | 5 | import { |
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 @@ | |||
1 | import * as memoizee from 'memoizee' | 1 | import memoizee from 'memoizee' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { Op } from 'sequelize' | 3 | import { Op } from 'sequelize' |
4 | import { | 4 | import { |
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import { literal, Op } from 'sequelize' |
2 | import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table } from 'sequelize-typescript' | 2 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Model, Table } from 'sequelize-typescript' |
3 | import { AttributesOnly } from '@shared/core-utils' | 3 | import { AttributesOnly } from '@shared/core-utils' |
4 | import { VideoModel } from './video' | 4 | import { 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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import Bluebird from 'bluebird' |
2 | import { remove } from 'fs-extra' | 2 | import { remove } from 'fs-extra' |
3 | import { maxBy, minBy } from 'lodash' | 3 | import { maxBy, minBy } from 'lodash' |
4 | import { join } from 'path' | 4 | import { 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 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { readdir } from 'fs-extra' | 5 | import { readdir } from 'fs-extra' |
6 | import * as magnetUtil from 'magnet-uri' | 6 | import magnetUtil from 'magnet-uri' |
7 | import { basename, join } from 'path' | 7 | import { basename, join } from 'path' |
8 | import { | 8 | import { |
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 @@ | |||
1 | import 'mocha' | 1 | import 'mocha' |
2 | import * as request from 'supertest' | 2 | import request from 'supertest' |
3 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/extra-utils' | 3 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/extra-utils' |
4 | import { HttpStatusCode } from '@shared/models' | 4 | import { 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 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as magnetUtil from 'magnet-uri' | 4 | import magnetUtil from 'magnet-uri' |
5 | import * as WebTorrent from 'webtorrent' | 5 | import WebTorrent from 'webtorrent' |
6 | import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 6 | import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' |
7 | 7 | ||
8 | describe('Test tracker', function () { | 8 | describe('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 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import * as request from 'supertest' | 5 | import request from 'supertest' |
6 | import { | 6 | import { |
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 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import * as xmlParser from 'fast-xml-parser' | 5 | import { parse, validate } from 'fast-xml-parser' |
6 | import { | 6 | import { |
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' | |||
4 | registerTSPaths() | 4 | registerTSPaths() |
5 | 5 | ||
6 | import { OptionValues, program } from 'commander' | 6 | import { OptionValues, program } from 'commander' |
7 | import * as prompt from 'prompt' | ||
8 | import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './cli' | 7 | import { assignToken, buildServer, getNetrc, getSettings, writeSettings } from './cli' |
9 | import { isUserUsernameValid } from '../helpers/custom-validators/users' | 8 | import { isUserUsernameValid } from '../helpers/custom-validators/users' |
10 | import * as CliTable3 from 'cli-table3' | 9 | import CliTable3 from 'cli-table3' |
10 | |||
11 | import prompt = require('prompt') | ||
11 | 12 | ||
12 | async function delInstance (url: string) { | 13 | async 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' | |||
6 | import { remove } from 'fs-extra' | 6 | import { remove } from 'fs-extra' |
7 | import { truncate } from 'lodash' | 7 | import { truncate } from 'lodash' |
8 | import { join } from 'path' | 8 | import { join } from 'path' |
9 | import * as prompt from 'prompt' | ||
10 | import { promisify } from 'util' | 9 | import { promisify } from 'util' |
11 | import { YoutubeDL } from '@server/helpers/youtube-dl' | 10 | import { YoutubeDL } from '@server/helpers/youtube-dl' |
12 | import { sha256 } from '../helpers/core-utils' | 11 | import { sha256 } from '../helpers/core-utils' |
@@ -22,6 +21,8 @@ import { | |||
22 | } from './cli' | 21 | } from './cli' |
23 | import { PeerTubeServer } from '@shared/extra-utils' | 22 | import { PeerTubeServer } from '@shared/extra-utils' |
24 | 23 | ||
24 | import prompt = require('prompt') | ||
25 | |||
25 | const processOptions = { | 26 | const 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' | |||
7 | import { assignToken, buildServer, getServerCredentials } from './cli' | 7 | import { assignToken, buildServer, getServerCredentials } from './cli' |
8 | import { PluginType } from '../../shared/models' | 8 | import { PluginType } from '../../shared/models' |
9 | import { isAbsolute } from 'path' | 9 | import { isAbsolute } from 'path' |
10 | import * as CliTable3 from 'cli-table3' | 10 | import CliTable3 from 'cli-table3' |
11 | 11 | ||
12 | program | 12 | program |
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 @@ | |||
1 | import { registerTSPaths } from '../helpers/register-ts-paths' | 1 | import { registerTSPaths } from '../helpers/register-ts-paths' |
2 | registerTSPaths() | 2 | registerTSPaths() |
3 | 3 | ||
4 | import * as CliTable3 from 'cli-table3' | 4 | import CliTable3 from 'cli-table3' |
5 | import { Command, program } from 'commander' | 5 | import { Command, program } from 'commander' |
6 | import { uniq } from 'lodash' | 6 | import { uniq } from 'lodash' |
7 | import { URL } from 'url' | 7 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import express from 'express' |
2 | import { UserRole } from '@shared/models' | 2 | import { UserRole } from '@shared/models' |
3 | import { MOAuthToken, MUser } from '../models' | 3 | import { MOAuthToken, MUser } from '../models' |
4 | 4 | ||