mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Refactor requests
This commit is contained in:
@@ -6,7 +6,7 @@ import { AbuseModel } from '@server/models/abuse/abuse'
|
||||
import { AbuseMessageModel } from '@server/models/abuse/abuse-message'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
|
||||
import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import { AbuseCreate, AbuseState, UserRight } from '../../../shared'
|
||||
import { getFormattedObjects } from '../../helpers/utils'
|
||||
import { sequelizeTypescript } from '../../initializers/database'
|
||||
|
||||
@@ -4,7 +4,7 @@ import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bu
|
||||
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/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
|
||||
const bulkRouter = express.Router()
|
||||
|
||||
|
||||
@@ -1,7 +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/core-utils'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import { UserRight } from '@shared/models'
|
||||
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as cors from 'cors'
|
||||
import * as express from 'express'
|
||||
import * as RateLimit from 'express-rate-limit'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../shared/models'
|
||||
import { badRequest } from '../../helpers/express-utils'
|
||||
import { CONFIG } from '../../initializers/config'
|
||||
import { abuseRouter } from './abuse'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as express from 'express'
|
||||
import { OAuthClientLocal } from '../../../shared'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { CONFIG } from '../../initializers/config'
|
||||
import { asyncMiddleware, openapiOperationDoc } from '../../middlewares'
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
updatePluginSettingsValidator
|
||||
} from '@server/middlewares/validators/plugins'
|
||||
import { PluginModel } from '@server/models/server/plugin'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import {
|
||||
InstallOrUpdatePlugin,
|
||||
ManagePlugin,
|
||||
|
||||
@@ -6,7 +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/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import { ResultList, VideoChannel } from '@shared/models'
|
||||
import { VideoChannelsSearchQuery } from '../../../../shared/models/search'
|
||||
import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils'
|
||||
|
||||
@@ -11,7 +11,7 @@ import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@ser
|
||||
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/core-utils'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import { ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models'
|
||||
import {
|
||||
asyncMiddleware,
|
||||
|
||||
@@ -6,7 +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/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import { ResultList, Video } from '@shared/models'
|
||||
import { VideosSearchQuery } from '../../../../shared/models/search'
|
||||
import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils'
|
||||
|
||||
@@ -3,7 +3,7 @@ import { asyncMiddleware, contactAdministratorValidator } from '../../../middlew
|
||||
import { Redis } from '../../../lib/redis'
|
||||
import { Emailer } from '../../../lib/emailer'
|
||||
import { ContactForm } from '../../../../shared/models/server'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
|
||||
const contactRouter = express.Router()
|
||||
|
||||
@@ -15,7 +15,7 @@ contactRouter.post('/contact',
|
||||
async function contactAdministrator (req: express.Request, res: express.Response) {
|
||||
const data = req.body as ContactForm
|
||||
|
||||
await Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body)
|
||||
Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body)
|
||||
|
||||
await Redis.Instance.setContactFormIp(req.ip)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as express from 'express'
|
||||
import { InboxManager } from '@server/lib/activitypub/inbox-manager'
|
||||
import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
|
||||
import { Debug, SendDebugCommand } from '@shared/models'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { UserRight } from '../../../../shared/models/users'
|
||||
import { authenticate, ensureUserHasRight } from '../../../middlewares'
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as express from 'express'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { UserRight } from '../../../../shared/models/users'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { getFormattedObjects } from '../../../helpers/utils'
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import * as express from 'express'
|
||||
import { JobQueue } from '@server/lib/job-queue'
|
||||
import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { UserRight } from '../../../../shared/models/users'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy'
|
||||
import {
|
||||
asyncMiddleware,
|
||||
authenticate,
|
||||
@@ -10,16 +15,11 @@ import {
|
||||
videoRedundanciesSortValidator
|
||||
} from '../../../middlewares'
|
||||
import {
|
||||
listVideoRedundanciesValidator,
|
||||
updateServerRedundancyValidator,
|
||||
addVideoRedundancyValidator,
|
||||
removeVideoRedundancyValidator
|
||||
listVideoRedundanciesValidator,
|
||||
removeVideoRedundancyValidator,
|
||||
updateServerRedundancyValidator
|
||||
} from '../../../middlewares/validators/redundancy'
|
||||
import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
|
||||
import { JobQueue } from '@server/lib/job-queue'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
const serverRedundancyRouter = express.Router()
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'multer'
|
||||
import * as express from 'express'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { UserNotificationModel } from '@server/models/user/user-notification'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { UserNotificationModel } from '@server/models/user/user-notification'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { UserRight } from '../../../../shared/models/users'
|
||||
import { getFormattedObjects } from '../../../helpers/utils'
|
||||
import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist'
|
||||
@@ -25,7 +26,6 @@ import {
|
||||
} from '../../../middlewares/validators'
|
||||
import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
|
||||
import { ServerBlocklistModel } from '../../../models/server/server-blocklist'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
|
||||
const serverBlocklistRouter = express.Router()
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
|
||||
import { MUser, MUserAccountDefault } from '@server/types/models'
|
||||
import { UserCreate, UserCreateResult, UserRight, UserRole, UserUpdate } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
|
||||
import { UserRegister } from '../../../../shared/models/users/user-register.model'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as express from 'express'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { ActorImageType, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model'
|
||||
import { createReqFiles } from '../../../helpers/express-utils'
|
||||
import { getFormattedObjects } from '../../../helpers/utils'
|
||||
|
||||
@@ -22,7 +22,7 @@ import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist
|
||||
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/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
|
||||
const myBlocklistRouter = express.Router()
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
import { getFormattedObjects } from '../../../helpers/utils'
|
||||
import { UserVideoHistoryModel } from '../../../models/user/user-video-history'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
|
||||
const myVideosHistoryRouter = express.Router()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'multer'
|
||||
import * as express from 'express'
|
||||
import { UserNotificationModel } from '@server/models/user/user-notification'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { UserNotificationSetting } from '../../../../shared/models/users'
|
||||
import { getFormattedObjects } from '../../../helpers/utils'
|
||||
import {
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as express from 'express'
|
||||
import { sendUndoFollow } from '@server/lib/activitypub/send'
|
||||
import { VideoChannelModel } from '@server/models/video/video-channel'
|
||||
import { VideosCommonQuery } from '@shared/models'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
|
||||
import { getFormattedObjects } from '../../../helpers/utils'
|
||||
import { WEBSERVER } from '../../../initializers/constants'
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { MChannelBannerAccountDefault } from '@server/types/models'
|
||||
import { ActorImageType, VideoChannelCreate, VideoChannelUpdate, VideosCommonQuery } from '../../../shared'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
|
||||
import { resetSequelizeInstance } from '../../helpers/database-utils'
|
||||
import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'
|
||||
import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models'
|
||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model'
|
||||
import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model'
|
||||
import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model'
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
videosBlacklistUpdateValidator
|
||||
} from '../../../middlewares'
|
||||
import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
|
||||
const blacklistRouter = express.Router()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as express from 'express'
|
||||
import { MVideoCaption } from '@server/types/models'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
|
||||
import { createReqFiles } from '../../../helpers/express-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as express from 'express'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models'
|
||||
import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model'
|
||||
import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
|
||||
|
||||
@@ -6,7 +6,7 @@ import { openapiOperationDoc } from '@server/middlewares/doc'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { MVideoAccountLight } from '@server/types/models'
|
||||
import { VideosCommonQuery } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs'
|
||||
import { HttpStatusCode } from '../../../../shared/models'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
|
||||
import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
|
||||
@@ -11,7 +11,7 @@ import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator
|
||||
import { VideoLiveModel } from '@server/models/video/video-live'
|
||||
import { MVideoDetails, MVideoFullLight } from '@server/types/models'
|
||||
import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail'
|
||||
|
||||
@@ -19,7 +19,7 @@ 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/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
|
||||
const ownershipVideoRouter = express.Router()
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUp
|
||||
import { AccountModel } from '../../../models/account/account'
|
||||
import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
|
||||
const rateVideoRouter = express.Router()
|
||||
|
||||
|
||||
@@ -2,10 +2,11 @@ import * as express from 'express'
|
||||
import { Transaction } from 'sequelize/types'
|
||||
import { changeVideoChannelShare } from '@server/lib/activitypub/share'
|
||||
import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
|
||||
import { openapiOperationDoc } from '@server/middlewares/doc'
|
||||
import { FilteredModelAttributes } from '@server/types'
|
||||
import { MVideoFullLight } from '@server/types/models'
|
||||
import { VideoUpdate } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs'
|
||||
import { HttpStatusCode } from '../../../../shared/models'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
|
||||
import { resetSequelizeInstance } from '../../../helpers/database-utils'
|
||||
import { createReqFiles } from '../../../helpers/express-utils'
|
||||
@@ -20,7 +21,6 @@ import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
|
||||
import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares'
|
||||
import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
|
||||
import { VideoModel } from '../../../models/video/video'
|
||||
import { openapiOperationDoc } from '@server/middlewares/doc'
|
||||
|
||||
const lTags = loggerTagsFactory('api', 'video')
|
||||
const auditLogger = auditLoggerFactory('videos')
|
||||
|
||||
@@ -11,7 +11,7 @@ import { openapiOperationDoc } from '@server/middlewares/doc'
|
||||
import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
|
||||
import { uploadx } from '@uploadx/core'
|
||||
import { VideoCreate, VideoState } from '../../../../shared'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs'
|
||||
import { HttpStatusCode } from '../../../../shared/models'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
|
||||
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
||||
import { createReqFiles } from '../../../helpers/express-utils'
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
videoWatchingValidator
|
||||
} from '../../../middlewares'
|
||||
import { UserVideoHistoryModel } from '../../../models/user/user-video-history'
|
||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
|
||||
const watchingRouter = express.Router()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user