From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/controllers/api/bulk.ts | 6 +++--- server/controllers/api/config.ts | 2 +- server/controllers/api/custom-page.ts | 3 +-- server/controllers/api/overviews.ts | 10 +++++----- server/controllers/api/plugins.ts | 2 +- server/controllers/api/search/search-video-channels.ts | 3 +-- server/controllers/api/search/search-video-playlists.ts | 5 ++--- server/controllers/api/search/search-videos.ts | 3 +-- server/controllers/api/server/contact.ts | 8 ++++---- server/controllers/api/server/index.ts | 8 ++++---- server/controllers/api/server/logs.ts | 12 ++++++------ server/controllers/api/users/me.ts | 2 +- server/controllers/api/users/my-blocklist.ts | 10 +++++----- server/controllers/api/users/my-history.ts | 6 +++--- server/controllers/api/users/my-video-playlists.ts | 2 +- server/controllers/api/videos/blacklist.ts | 2 +- server/controllers/api/videos/comment.ts | 2 +- server/controllers/api/videos/ownership.ts | 14 +++++++------- server/controllers/api/videos/rate.ts | 4 ++-- server/controllers/api/videos/watching.ts | 2 +- server/controllers/download.ts | 3 +-- 21 files changed, 52 insertions(+), 57 deletions(-) (limited to 'server/controllers') diff --git a/server/controllers/api/bulk.ts b/server/controllers/api/bulk.ts index 10d83571d..62121ece5 100644 --- a/server/controllers/api/bulk.ts +++ b/server/controllers/api/bulk.ts @@ -1,10 +1,10 @@ import * as express from 'express' -import { asyncMiddleware, authenticate } from '../../middlewares' +import { removeComment } from '@server/lib/video-comment' import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk' import { VideoCommentModel } from '@server/models/video/video-comment' -import { removeComment } from '@server/lib/video-comment' -import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' import { HttpStatusCode } from '@shared/models' +import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' +import { asyncMiddleware, authenticate } from '../../middlewares' const bulkRouter = express.Router() diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 9bd8c21c5..ee733a38c 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -1,8 +1,8 @@ -import { ServerConfigManager } from '@server/lib/server-config-manager' import * as express from 'express' import { remove, writeJSON } from 'fs-extra' import { snakeCase } from 'lodash' import validator from 'validator' +import { ServerConfigManager } from '@server/lib/server-config-manager' import { UserRight } from '../../../shared' import { About } from '../../../shared/models/server/about.model' import { CustomConfig } from '../../../shared/models/server/custom-config.model' diff --git a/server/controllers/api/custom-page.ts b/server/controllers/api/custom-page.ts index cc1aa8427..68d8c2ea4 100644 --- a/server/controllers/api/custom-page.ts +++ b/server/controllers/api/custom-page.ts @@ -1,8 +1,7 @@ import * as express from 'express' import { ServerConfigManager } from '@server/lib/server-config-manager' import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' -import { HttpStatusCode } from '@shared/models' -import { UserRight } from '@shared/models' +import { HttpStatusCode, UserRight } from '@shared/models' import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' const customPageRouter = express.Router() diff --git a/server/controllers/api/overviews.ts b/server/controllers/api/overviews.ts index ad879aad6..aaa341d54 100644 --- a/server/controllers/api/overviews.ts +++ b/server/controllers/api/overviews.ts @@ -1,12 +1,12 @@ import * as express from 'express' +import * as memoizee from 'memoizee' +import { logger } from '@server/helpers/logger' +import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews' import { buildNSFWFilter } from '../../helpers/express-utils' -import { VideoModel } from '../../models/video/video' +import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants' import { asyncMiddleware, optionalAuthenticate, videosOverviewValidator } from '../../middlewares' import { TagModel } from '../../models/video/tag' -import { CategoryOverview, ChannelOverview, TagOverview, VideosOverview } from '../../../shared/models/overviews' -import { MEMOIZE_TTL, OVERVIEWS } from '../../initializers/constants' -import * as memoizee from 'memoizee' -import { logger } from '@server/helpers/logger' +import { VideoModel } from '../../models/video/video' const overviewsRouter = express.Router() diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts index 4b213c246..3a9ef34e8 100644 --- a/server/controllers/api/plugins.ts +++ b/server/controllers/api/plugins.ts @@ -23,8 +23,8 @@ import { updatePluginSettingsValidator } from '@server/middlewares/validators/plugins' import { PluginModel } from '@server/models/server/plugin' -import { HttpStatusCode } from '@shared/models' import { + HttpStatusCode, InstallOrUpdatePlugin, ManagePlugin, PeertubePluginIndexList, diff --git a/server/controllers/api/search/search-video-channels.ts b/server/controllers/api/search/search-video-channels.ts index fe9178e69..c8f0a0a0b 100644 --- a/server/controllers/api/search/search-video-channels.ts +++ b/server/controllers/api/search/search-video-channels.ts @@ -6,8 +6,7 @@ import { WEBSERVER } from '@server/initializers/constants' import { Hooks } from '@server/lib/plugins/hooks' import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' import { getServerActor } from '@server/models/application/application' -import { HttpStatusCode } from '@shared/models' -import { ResultList, VideoChannel } from '@shared/models' +import { HttpStatusCode, ResultList, VideoChannel } from '@shared/models' import { VideoChannelsSearchQuery } from '../../../../shared/models/search' import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' import { logger } from '../../../helpers/logger' diff --git a/server/controllers/api/search/search-video-playlists.ts b/server/controllers/api/search/search-video-playlists.ts index a0e2c1747..f55b1fba3 100644 --- a/server/controllers/api/search/search-video-playlists.ts +++ b/server/controllers/api/search/search-video-playlists.ts @@ -5,14 +5,14 @@ import { logger } from '@server/helpers/logger' import { doJSONRequest } from '@server/helpers/requests' import { getFormattedObjects } from '@server/helpers/utils' import { CONFIG } from '@server/initializers/config' +import { WEBSERVER } from '@server/initializers/constants' import { getOrCreateAPVideoPlaylist } from '@server/lib/activitypub/playlists/get' import { Hooks } from '@server/lib/plugins/hooks' import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' import { getServerActor } from '@server/models/application/application' import { VideoPlaylistModel } from '@server/models/video/video-playlist' import { MVideoPlaylistFullSummary } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' -import { ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models' +import { HttpStatusCode, ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models' import { asyncMiddleware, openapiOperationDoc, @@ -23,7 +23,6 @@ import { videoPlaylistsListSearchValidator, videoPlaylistsSearchSortValidator } from '../../../middlewares' -import { WEBSERVER } from '@server/initializers/constants' const searchPlaylistsRouter = express.Router() diff --git a/server/controllers/api/search/search-videos.ts b/server/controllers/api/search/search-videos.ts index 0e6fd9c72..a4153f3f8 100644 --- a/server/controllers/api/search/search-videos.ts +++ b/server/controllers/api/search/search-videos.ts @@ -6,8 +6,7 @@ import { WEBSERVER } from '@server/initializers/constants' import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' import { Hooks } from '@server/lib/plugins/hooks' import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' -import { HttpStatusCode } from '@shared/models' -import { ResultList, Video } from '@shared/models' +import { HttpStatusCode, ResultList, Video } from '@shared/models' import { VideosSearchQuery } from '../../../../shared/models/search' import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' import { logger } from '../../../helpers/logger' diff --git a/server/controllers/api/server/contact.ts b/server/controllers/api/server/contact.ts index ae36dd599..b315e99cf 100644 --- a/server/controllers/api/server/contact.ts +++ b/server/controllers/api/server/contact.ts @@ -1,9 +1,9 @@ import * as express from 'express' -import { asyncMiddleware, contactAdministratorValidator } from '../../../middlewares' -import { Redis } from '../../../lib/redis' -import { Emailer } from '../../../lib/emailer' -import { ContactForm } from '../../../../shared/models/server' import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' +import { ContactForm } from '../../../../shared/models/server' +import { Emailer } from '../../../lib/emailer' +import { Redis } from '../../../lib/redis' +import { asyncMiddleware, contactAdministratorValidator } from '../../../middlewares' const contactRouter = express.Router() diff --git a/server/controllers/api/server/index.ts b/server/controllers/api/server/index.ts index 6b8793a19..32fefefc0 100644 --- a/server/controllers/api/server/index.ts +++ b/server/controllers/api/server/index.ts @@ -1,11 +1,11 @@ import * as express from 'express' +import { contactRouter } from './contact' +import { debugRouter } from './debug' import { serverFollowsRouter } from './follows' -import { statsRouter } from './stats' +import { logsRouter } from './logs' import { serverRedundancyRouter } from './redundancy' import { serverBlocklistRouter } from './server-blocklist' -import { contactRouter } from './contact' -import { logsRouter } from './logs' -import { debugRouter } from './debug' +import { statsRouter } from './stats' const serverRouter = express.Router() diff --git a/server/controllers/api/server/logs.ts b/server/controllers/api/server/logs.ts index 4b543d686..f78607d35 100644 --- a/server/controllers/api/server/logs.ts +++ b/server/controllers/api/server/logs.ts @@ -1,14 +1,14 @@ import * as express from 'express' -import { UserRight } from '../../../../shared/models/users' -import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' -import { mtimeSortFilesDesc } from '../../../../shared/core-utils/logs/logs' import { readdir, readFile } from 'fs-extra' -import { AUDIT_LOG_FILENAME, MAX_LOGS_OUTPUT_CHARACTERS, LOG_FILENAME } from '../../../initializers/constants' import { join } from 'path' -import { getAuditLogsValidator, getLogsValidator } from '../../../middlewares/validators/logs' +import { logger } from '@server/helpers/logger' +import { mtimeSortFilesDesc } from '../../../../shared/core-utils/logs/logs' import { LogLevel } from '../../../../shared/models/server/log-level.type' +import { UserRight } from '../../../../shared/models/users' import { CONFIG } from '../../../initializers/config' -import { logger } from '@server/helpers/logger' +import { AUDIT_LOG_FILENAME, LOG_FILENAME, MAX_LOGS_OUTPUT_CHARACTERS } from '../../../initializers/constants' +import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' +import { getAuditLogsValidator, getLogsValidator } from '../../../middlewares/validators/logs' const logsRouter = express.Router() diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index c9610c59f..ac6faca9c 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -2,6 +2,7 @@ import 'multer' import * as express from 'express' import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' import { Hooks } from '@server/lib/plugins/hooks' +import { AttributesOnly } from '@shared/core-utils' import { ActorImageType, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' @@ -31,7 +32,6 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat import { UserModel } from '../../../models/user/user' import { VideoModel } from '../../../models/video/video' import { VideoImportModel } from '../../../models/video/video-import' -import { AttributesOnly } from '@shared/core-utils' const auditLogger = auditLoggerFactory('users') diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts index fe11b6e77..24fff83e3 100644 --- a/server/controllers/api/users/my-blocklist.ts +++ b/server/controllers/api/users/my-blocklist.ts @@ -1,6 +1,10 @@ -import * as express from 'express' import 'multer' +import * as express from 'express' +import { logger } from '@server/helpers/logger' +import { UserNotificationModel } from '@server/models/user/user-notification' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { getFormattedObjects } from '../../../helpers/utils' +import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -18,11 +22,7 @@ import { unblockServerByAccountValidator } from '../../../middlewares/validators' import { AccountBlocklistModel } from '../../../models/account/account-blocklist' -import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' import { ServerBlocklistModel } from '../../../models/server/server-blocklist' -import { UserNotificationModel } from '@server/models/user/user-notification' -import { logger } from '@server/helpers/logger' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const myBlocklistRouter = express.Router() diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts index 85e04925e..a6e723103 100644 --- a/server/controllers/api/users/my-history.ts +++ b/server/controllers/api/users/my-history.ts @@ -1,4 +1,7 @@ import * as express from 'express' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' +import { getFormattedObjects } from '../../../helpers/utils' +import { sequelizeTypescript } from '../../../initializers/database' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -8,10 +11,7 @@ import { userHistoryListValidator, userHistoryRemoveValidator } from '../../../middlewares' -import { getFormattedObjects } from '../../../helpers/utils' import { UserVideoHistoryModel } from '../../../models/user/user-video-history' -import { sequelizeTypescript } from '../../../initializers/database' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const myVideosHistoryRouter = express.Router() diff --git a/server/controllers/api/users/my-video-playlists.ts b/server/controllers/api/users/my-video-playlists.ts index d0bd99463..76e741ba5 100644 --- a/server/controllers/api/users/my-video-playlists.ts +++ b/server/controllers/api/users/my-video-playlists.ts @@ -1,8 +1,8 @@ import * as express from 'express' +import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' import { asyncMiddleware, authenticate } from '../../../middlewares' import { doVideosInPlaylistExistValidator } from '../../../middlewares/validators/videos/video-playlists' import { VideoPlaylistModel } from '../../../models/video/video-playlist' -import { VideosExistInPlaylists } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' const myVideoPlaylistsRouter = express.Router() diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index a7f5f53d8..6bc768471 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts @@ -1,6 +1,7 @@ import * as express from 'express' import { blacklistVideo, unblacklistVideo } from '@server/lib/video-blacklist' import { UserRight, VideoBlacklistCreate } from '../../../../shared' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { logger } from '../../../helpers/logger' import { getFormattedObjects } from '../../../helpers/utils' import { sequelizeTypescript } from '../../../initializers/database' @@ -19,7 +20,6 @@ import { videosBlacklistUpdateValidator } from '../../../middlewares' import { VideoBlacklistModel } from '../../../models/video/video-blacklist' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const blacklistRouter = express.Router() diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index 90b633bb5..cb696f652 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts @@ -1,6 +1,6 @@ import * as express from 'express' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' import { getFormattedObjects } from '../../../helpers/utils' diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts index e6c94a45a..f48acbc68 100644 --- a/server/controllers/api/videos/ownership.ts +++ b/server/controllers/api/videos/ownership.ts @@ -1,6 +1,12 @@ import * as express from 'express' +import { MVideoFullLight } from '@server/types/models' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' +import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos' import { logger } from '../../../helpers/logger' +import { getFormattedObjects } from '../../../helpers/utils' import { sequelizeTypescript } from '../../../initializers/database' +import { sendUpdateVideo } from '../../../lib/activitypub/send' +import { changeVideoChannelShare } from '../../../lib/activitypub/share' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -11,15 +17,9 @@ import { videosChangeOwnershipValidator, videosTerminateChangeOwnershipValidator } from '../../../middlewares' +import { VideoModel } from '../../../models/video/video' import { VideoChangeOwnershipModel } from '../../../models/video/video-change-ownership' -import { VideoChangeOwnershipStatus, VideoState } from '../../../../shared/models/videos' import { VideoChannelModel } from '../../../models/video/video-channel' -import { getFormattedObjects } from '../../../helpers/utils' -import { changeVideoChannelShare } from '../../../lib/activitypub/share' -import { sendUpdateVideo } from '../../../lib/activitypub/send' -import { VideoModel } from '../../../models/video/video' -import { MVideoFullLight } from '@server/types/models' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const ownershipVideoRouter = express.Router() diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 134c9e5ca..96f6cd886 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts @@ -1,13 +1,13 @@ import * as express from 'express' import { UserVideoRateUpdate } from '../../../../shared' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { logger } from '../../../helpers/logger' import { VIDEO_RATE_TYPES } from '../../../initializers/constants' +import { sequelizeTypescript } from '../../../initializers/database' import { getLocalRateUrl, sendVideoRateChange } from '../../../lib/activitypub/video-rates' import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUpdateRateValidator } from '../../../middlewares' import { AccountModel } from '../../../models/account/account' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' -import { sequelizeTypescript } from '../../../initializers/database' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const rateVideoRouter = express.Router() diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts index 2899dbd9c..05c75e543 100644 --- a/server/controllers/api/videos/watching.ts +++ b/server/controllers/api/videos/watching.ts @@ -1,5 +1,6 @@ import * as express from 'express' import { UserWatchingVideo } from '../../../../shared' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -8,7 +9,6 @@ import { videoWatchingValidator } from '../../../middlewares' import { UserVideoHistoryModel } from '../../../models/user/user-video-history' -import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' const watchingRouter = express.Router() diff --git a/server/controllers/download.ts b/server/controllers/download.ts index 13bc66900..ddacc1b68 100644 --- a/server/controllers/download.ts +++ b/server/controllers/download.ts @@ -5,8 +5,7 @@ import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache import { Hooks } from '@server/lib/plugins/hooks' import { getVideoFilePath } from '@server/lib/video-paths' import { MStreamingPlaylist, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' -import { HttpStatusCode } from '@shared/models' -import { VideoStreamingPlaylistType } from '@shared/models' +import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models' import { STATIC_DOWNLOAD_PATHS } from '../initializers/constants' import { asyncMiddleware, videosDownloadValidator } from '../middlewares' -- cgit v1.2.3