Remove unnecessary logs
This commit is contained in:
parent
2ec349aa85
commit
a85d530384
45 changed files with 46 additions and 352 deletions
|
@ -52,8 +52,6 @@ const abuseReportValidator = [
|
|||
.custom(areAbusePredefinedReasonsValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking abuseReport parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const body: AbuseCreate = req.body
|
||||
|
@ -76,8 +74,6 @@ const abuseGetValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking abuseGetValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesAbuseExist(req.params.id, res)) return
|
||||
|
||||
|
@ -97,8 +93,6 @@ const abuseUpdateValidator = [
|
|||
.custom(isAbuseModerationCommentValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking abuseUpdateValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesAbuseExist(req.params.id, res)) return
|
||||
|
||||
|
@ -139,8 +133,6 @@ const abuseListForAdminsValidator = [
|
|||
.custom(exists),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking abuseListForAdminsValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -161,8 +153,6 @@ const abuseListForUserValidator = [
|
|||
.custom(isAbuseStateValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking abuseListForUserValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -174,8 +164,6 @@ const getAbuseValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking getAbuseValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesAbuseExist(req.params.id, res)) return
|
||||
|
||||
|
@ -198,8 +186,6 @@ const getAbuseValidator = [
|
|||
|
||||
const checkAbuseValidForMessagesValidator = [
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking checkAbuseValidForMessagesValidator parameters', { parameters: req.body })
|
||||
|
||||
const abuse = res.locals.abuse
|
||||
if (abuse.ReporterAccount.isOwned() === false) {
|
||||
return res.fail({ message: 'This abuse was created by a user of your instance.' })
|
||||
|
@ -214,8 +200,6 @@ const addAbuseMessageValidator = [
|
|||
.custom(isAbuseMessageValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking addAbuseMessageValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -227,8 +211,6 @@ const deleteAbuseMessageValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking deleteAbuseMessageValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const user = res.locals.oauth.token.user
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import express from 'express'
|
||||
import { param } from 'express-validator'
|
||||
import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors, doesAccountNameWithHostExist, doesLocalAccountNameExist } from './shared'
|
||||
|
||||
const localAccountValidator = [
|
||||
|
@ -9,8 +8,6 @@ const localAccountValidator = [
|
|||
.custom(isAccountNameValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking localAccountValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesLocalAccountNameExist(req.params.name, res)) return
|
||||
|
||||
|
@ -23,8 +20,6 @@ const accountNameWithHostGetValidator = [
|
|||
.exists(),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import express from 'express'
|
||||
import { query } from 'express-validator'
|
||||
import { PAGINATION } from '@server/initializers/constants'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors } from '../shared'
|
||||
|
||||
const apPaginationValidator = [
|
||||
|
@ -13,8 +12,6 @@ const apPaginationValidator = [
|
|||
.isInt({ min: 0, max: PAGINATION.OUTBOX.COUNT.MAX }).withMessage(`Should have a valid page size (max: ${PAGINATION.OUTBOX.COUNT.MAX})`),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking pagination parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
|
|
@ -26,7 +26,7 @@ const signatureValidator = [
|
|||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking Linked Data Signature parameter', { parameters: { signature: req.body.signature } })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (areValidationErrors(req, res, { omitLog: true })) return
|
||||
|
||||
return next()
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ import express from 'express'
|
|||
import { body } from 'express-validator'
|
||||
import { isActorImageFile } from '@server/helpers/custom-validators/actor-images'
|
||||
import { cleanUpReqFiles } from '../../helpers/express-utils'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
|
@ -13,8 +12,6 @@ const updateActorImageValidatorFactory = (fieldname: string) => ([
|
|||
),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking updateActorImageValidator parameters', { files: req.files })
|
||||
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
|
||||
|
||||
return next()
|
||||
|
|
|
@ -5,7 +5,6 @@ import { toArray } from '@server/helpers/custom-validators/misc'
|
|||
import { getServerActor } from '@server/models/application/application'
|
||||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { WEBSERVER } from '../../initializers/constants'
|
||||
import { AccountBlocklistModel } from '../../models/account/account-blocklist'
|
||||
import { ServerModel } from '../../models/server/server'
|
||||
|
@ -17,8 +16,6 @@ const blockAccountValidator = [
|
|||
.exists(),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking blockAccountByAccountValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesAccountNameWithHostExist(req.body.accountName, res)) return
|
||||
|
||||
|
@ -42,8 +39,6 @@ const unblockAccountByAccountValidator = [
|
|||
.exists(),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking unblockAccountByAccountValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
|
||||
|
||||
|
@ -60,8 +55,6 @@ const unblockAccountByServerValidator = [
|
|||
.exists(),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking unblockAccountByServerValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesAccountNameWithHostExist(req.params.accountName, res)) return
|
||||
|
||||
|
@ -78,8 +71,6 @@ const blockServerValidator = [
|
|||
.custom(isHostValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking serverGetValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const host: string = req.body.host
|
||||
|
@ -104,8 +95,6 @@ const unblockServerByAccountValidator = [
|
|||
.custom(isHostValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking unblockServerByAccountValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const user = res.locals.oauth.token.User
|
||||
|
@ -120,8 +109,6 @@ const unblockServerByServerValidator = [
|
|||
.custom(isHostValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking unblockServerByServerValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const serverActor = await getServerActor()
|
||||
|
@ -143,8 +130,6 @@ const blocklistStatusValidator = [
|
|||
.custom(areValidActorHandles).withMessage('Should have a valid accounts array'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking blocklistStatusValidator parameters', { query: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
|
|
@ -3,7 +3,6 @@ import { body } from 'express-validator'
|
|||
import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk'
|
||||
import { HttpStatusCode, UserRight } from '@shared/models'
|
||||
import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors, doesAccountNameWithHostExist } from './shared'
|
||||
|
||||
const bulkRemoveCommentsOfValidator = [
|
||||
|
@ -13,8 +12,6 @@ const bulkRemoveCommentsOfValidator = [
|
|||
.custom(isBulkRemoveCommentsOfScopeValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking bulkRemoveCommentsOfValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesAccountNameWithHostExist(req.body.accountName, res)) return
|
||||
|
||||
|
|
|
@ -2,13 +2,12 @@ import express from 'express'
|
|||
import { body } from 'express-validator'
|
||||
import { isIntOrNull } from '@server/helpers/custom-validators/misc'
|
||||
import { CONFIG, isEmailEnabled } from '@server/initializers/config'
|
||||
import { HttpStatusCode } from '@shared/models/http/http-error-codes'
|
||||
import { CustomConfig } from '../../../shared/models/server/custom-config.model'
|
||||
import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
|
||||
import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { isThemeRegistered } from '../../lib/plugins/theme-utils'
|
||||
import { areValidationErrors } from './shared'
|
||||
import { HttpStatusCode } from '@shared/models/http/http-error-codes'
|
||||
|
||||
const customConfigUpdateValidator = [
|
||||
body('instance.name').exists(),
|
||||
|
@ -105,8 +104,6 @@ const customConfigUpdateValidator = [
|
|||
body('search.searchIndex.isDefaultSearch').isBoolean(),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!checkInvalidConfigIfEmailDisabled(req.body, res)) return
|
||||
if (!checkInvalidTranscodingConfig(req.body, res)) return
|
||||
|
|
|
@ -3,7 +3,6 @@ import { param, query } from 'express-validator'
|
|||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
|
||||
import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import {
|
||||
areValidationErrors,
|
||||
checkCanSeeVideo,
|
||||
|
@ -24,8 +23,6 @@ const feedsFormatValidator = [
|
|||
.custom(isValidRSSFeed).withMessage('Should have a valid format (rss, atom, json)'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking feeds format parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -74,8 +71,6 @@ const videoFeedsValidator = [
|
|||
.optional(),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking feeds parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (req.query.accountId && !await doesAccountIdExist(req.query.accountId, res)) return
|
||||
|
@ -95,8 +90,6 @@ const videoSubscriptionFeedsValidator = [
|
|||
.custom(exists),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking subscription feeds parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (!await doesAccountIdExist(req.query.accountId, res)) return
|
||||
|
@ -113,8 +106,6 @@ const videoCommentsFeedsValidator = [
|
|||
.custom(isIdOrUUIDValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking feeds parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (req.query.videoId && (req.query.videoChannelId || req.query.videoChannelName)) {
|
||||
|
|
|
@ -50,8 +50,6 @@ const followValidator = [
|
|||
})
|
||||
}
|
||||
|
||||
logger.debug('Checking follow parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const body: ServerFollowCreate = req.body
|
||||
|
@ -73,8 +71,6 @@ const removeFollowingValidator = [
|
|||
.custom(value => isHostValid(value) || isRemoteHandleValid(value)),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking unfollowing parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const serverActor = await getServerActor()
|
||||
|
@ -103,8 +99,6 @@ const getFollowerValidator = [
|
|||
.custom(isValidActorHandle),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking get follower parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
let follow: MActorFollowActorsDefault
|
||||
|
@ -132,8 +126,6 @@ const getFollowerValidator = [
|
|||
|
||||
const acceptFollowerValidator = [
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking accept follower parameters', { parameters: req.params })
|
||||
|
||||
const follow = res.locals.follow
|
||||
if (follow.state !== 'pending' && follow.state !== 'rejected') {
|
||||
return res.fail({ message: 'Follow is not in pending/rejected state.' })
|
||||
|
@ -145,8 +137,6 @@ const acceptFollowerValidator = [
|
|||
|
||||
const rejectFollowerValidator = [
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking reject follower parameters', { parameters: req.params })
|
||||
|
||||
const follow = res.locals.follow
|
||||
if (follow.state !== 'pending' && follow.state !== 'accepted') {
|
||||
return res.fail({ message: 'Follow is not in pending/accepted state.' })
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import express from 'express'
|
||||
import { param, query } from 'express-validator'
|
||||
import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs'
|
||||
import { logger, loggerTagsFactory } from '../../helpers/logger'
|
||||
import { loggerTagsFactory } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const lTags = loggerTagsFactory('validators', 'jobs')
|
||||
|
@ -16,9 +16,7 @@ const listJobsValidator = [
|
|||
.custom(isValidJobType),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking listJobsValidator parameters.', { parameters: req.params, ...lTags() })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (areValidationErrors(req, res, lTags())) return
|
||||
|
||||
return next()
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
isValidLogLevel
|
||||
} from '../../helpers/custom-validators/logs'
|
||||
import { isDateValid, toArray } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const createClientLogValidator = [
|
||||
|
@ -39,8 +38,6 @@ const createClientLogValidator = [
|
|||
.custom(isValidClientLogUserAgent),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking createClientLogValidator parameters.', { parameters: req.query })
|
||||
|
||||
if (CONFIG.LOG.ACCEPT_CLIENT_LOG !== true) {
|
||||
return res.sendStatus(HttpStatusCode.FORBIDDEN_403)
|
||||
}
|
||||
|
@ -66,8 +63,6 @@ const getLogsValidator = [
|
|||
.custom(isDateValid).withMessage('Should have an end date that conforms to ISO 8601'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking getLogsValidator parameters.', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -82,8 +77,6 @@ const getAuditLogsValidator = [
|
|||
.custom(isDateValid).withMessage('Should have a end date that conforms to ISO 8601'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking getAuditLogsValidator parameters.', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
|
|
@ -4,7 +4,6 @@ import { isValidPlayerMode } from '@server/helpers/custom-validators/metrics'
|
|||
import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors, doesVideoExist } from './shared'
|
||||
|
||||
const addPlaybackMetricValidator = [
|
||||
|
@ -35,8 +34,6 @@ const addPlaybackMetricValidator = [
|
|||
.custom(isIdOrUUIDValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking addPlaybackMetricValidator parameters.', { parameters: req.query })
|
||||
|
||||
if (!CONFIG.OPEN_TELEMETRY.METRICS.ENABLED) return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
|
||||
|
||||
const body: PlaybackMetricCreate = req.body
|
||||
|
|
|
@ -7,7 +7,6 @@ import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
|
|||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { isTestOrDevInstance } from '../../helpers/core-utils'
|
||||
import { isIdOrUUIDValid, isUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { WEBSERVER } from '../../initializers/constants'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
|
@ -52,8 +51,6 @@ const oembedValidator = [
|
|||
.isIn([ 'xml', 'json' ]),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking oembed parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (req.query.format !== undefined && req.query.format !== 'json') {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import express from 'express'
|
||||
import { query } from 'express-validator'
|
||||
import { PAGINATION } from '@server/initializers/constants'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const paginationValidator = paginationValidatorBuilder()
|
||||
|
@ -16,9 +15,7 @@ function paginationValidatorBuilder (tags: string[] = []) {
|
|||
.isInt({ min: 0, max: PAGINATION.GLOBAL.COUNT.MAX }).withMessage(`Should have a number count (max: ${PAGINATION.GLOBAL.COUNT.MAX})`),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking pagination parameters', { parameters: req.query, tags })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (areValidationErrors(req, res, { tags })) return
|
||||
|
||||
return next()
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import { PluginType } from '../../../shared/models/plugins/plugin.type'
|
|||
import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model'
|
||||
import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
|
||||
import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { CONFIG } from '../../initializers/config'
|
||||
import { PluginManager } from '../../lib/plugins/plugin-manager'
|
||||
import { PluginModel } from '../../models/server/plugin'
|
||||
|
@ -26,8 +25,6 @@ const getPluginValidator = (pluginType: PluginType, withVersion = true) => {
|
|||
|
||||
return validators.concat([
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking getPluginValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const npmName = PluginModel.buildNpmName(req.params.pluginName, pluginType)
|
||||
|
@ -58,8 +55,6 @@ const getExternalAuthValidator = [
|
|||
.custom(exists),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking getExternalAuthValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const plugin = res.locals.registeredPlugin
|
||||
|
@ -89,8 +84,6 @@ const pluginStaticDirectoryValidator = [
|
|||
.custom(isSafePath),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking pluginStaticDirectoryValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -108,8 +101,6 @@ const listPluginsValidator = [
|
|||
.custom(isBooleanValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking listPluginsValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -128,8 +119,6 @@ const installOrUpdatePluginValidator = [
|
|||
.custom(isSafePath),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking installOrUpdatePluginValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const body: InstallOrUpdatePlugin = req.body
|
||||
|
@ -149,8 +138,6 @@ const uninstallPluginValidator = [
|
|||
.custom(isNpmPluginNameValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking uninstallPluginValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -162,8 +149,6 @@ const existingPluginValidator = [
|
|||
.custom(isNpmPluginNameValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking enabledPluginValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const plugin = await PluginModel.loadByNpmName(req.params.npmName)
|
||||
|
@ -184,8 +169,6 @@ const updatePluginSettingsValidator = [
|
|||
.exists(),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking enabledPluginValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -205,8 +188,6 @@ const listAvailablePluginsValidator = [
|
|||
.custom(isPluginVersionValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking enabledPluginValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (CONFIG.PLUGINS.INDEX.ENABLED === false) {
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
toIntOrNull
|
||||
} from '../../helpers/custom-validators/misc'
|
||||
import { isHostValid } from '../../helpers/custom-validators/servers'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
|
||||
import { ServerModel } from '../../models/server/server'
|
||||
import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from './shared'
|
||||
|
@ -29,8 +28,6 @@ const videoFileRedundancyGetValidator = [
|
|||
.custom(exists),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoFileRedundancyGetValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return
|
||||
|
||||
|
@ -72,8 +69,6 @@ const videoPlaylistRedundancyGetValidator = [
|
|||
.custom(exists),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return
|
||||
|
||||
|
@ -112,8 +107,6 @@ const updateServerRedundancyValidator = [
|
|||
.custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed boolean'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking updateServerRedundancy parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const server = await ServerModel.loadByHost(req.params.host)
|
||||
|
@ -135,8 +128,6 @@ const listVideoRedundanciesValidator = [
|
|||
.custom(isVideoRedundancyTarget),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking listVideoRedundanciesValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -149,8 +140,6 @@ const addVideoRedundancyValidator = [
|
|||
.custom(isIdOrUUIDValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking addVideoRedundancyValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (!await doesVideoExist(req.body.videoId, res, 'only-video')) return
|
||||
|
@ -180,8 +169,6 @@ const removeVideoRedundancyValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking removeVideoRedundancyValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const redundancy = await VideoRedundancyModel.loadByIdWithVideo(parseInt(req.params.redundancyId, 10))
|
||||
|
|
|
@ -3,7 +3,6 @@ import { query } from 'express-validator'
|
|||
import { isSearchTargetValid } from '@server/helpers/custom-validators/search'
|
||||
import { isHostValid } from '@server/helpers/custom-validators/servers'
|
||||
import { areUUIDsValid, isDateValid, isNotEmptyStringArray, toCompleteUUIDs } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const videosSearchValidator = [
|
||||
|
@ -47,8 +46,6 @@ const videosSearchValidator = [
|
|||
.custom(isSearchTargetValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videos search query', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -74,8 +71,6 @@ const videoChannelsListSearchValidator = [
|
|||
.custom(isNotEmptyStringArray).withMessage('Should have valid array of handles'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking video channels search query', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -102,8 +97,6 @@ const videoPlaylistsListSearchValidator = [
|
|||
.custom(areUUIDsValid).withMessage('Should have valid array of uuid'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking video playlists search query', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
|
|
@ -13,8 +13,6 @@ const serverGetValidator = [
|
|||
body('host').custom(isHostValid).withMessage('Should have a valid host'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking serverGetValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const server = await ServerModel.loadByHost(req.body.host)
|
||||
|
@ -40,8 +38,6 @@ const contactAdministratorValidator = [
|
|||
.custom(isValidContactBody),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking contactAdministratorValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (CONFIG.CONTACT_FORM.ENABLED === false) {
|
||||
|
|
|
@ -3,7 +3,32 @@ import { param, validationResult } from 'express-validator'
|
|||
import { isIdOrUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
|
||||
function areValidationErrors (req: express.Request, res: express.Response) {
|
||||
function areValidationErrors (
|
||||
req: express.Request,
|
||||
res: express.Response,
|
||||
options: {
|
||||
omitLog?: boolean
|
||||
omitBodyLog?: boolean
|
||||
tags?: string[]
|
||||
} = {}) {
|
||||
const { omitLog = false, omitBodyLog = false, tags = [] } = options
|
||||
|
||||
if (!omitLog) {
|
||||
logger.debug(
|
||||
'Checking %s - %s parameters',
|
||||
req.method, req.originalUrl,
|
||||
{
|
||||
body: omitBodyLog
|
||||
? 'omitted'
|
||||
: req.body,
|
||||
params: req.params,
|
||||
query: req.query,
|
||||
files: req.files,
|
||||
tags
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const errors = validationResult(req)
|
||||
|
||||
if (!errors.isEmpty()) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import express from 'express'
|
||||
import { query } from 'express-validator'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
|
||||
import { SORTABLE_COLUMNS } from '../../initializers/constants'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
|
@ -15,9 +15,7 @@ function checkSort (sortableColumns: string[], tags: string[] = []) {
|
|||
.isIn(sortableColumns),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking sort parameters', { parameters: req.query, tags })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (areValidationErrors(req, res, { tags })) return
|
||||
|
||||
return next()
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ import { param } from 'express-validator'
|
|||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { isSafePath } from '../../helpers/custom-validators/misc'
|
||||
import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { PluginManager } from '../../lib/plugins/plugin-manager'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
|
@ -16,8 +15,6 @@ const serveThemeCSSValidator = [
|
|||
.custom(isSafePath),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking serveThemeCSS parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const theme = PluginManager.Instance.getRegisteredThemeByShortName(req.params.themeName)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import express from 'express'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { exists, isDateValid, isIdValid } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const userHistoryListValidator = [
|
||||
|
@ -10,8 +9,6 @@ const userHistoryListValidator = [
|
|||
.custom(exists),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking userHistoryListValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -24,8 +21,6 @@ const userHistoryRemoveAllValidator = [
|
|||
.custom(isDateValid).withMessage('Should have a before date that conforms to ISO 8601'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking userHistoryRemoveAllValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -37,8 +32,6 @@ const userHistoryRemoveElementValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking userHistoryRemoveElementValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
|
|
@ -2,7 +2,6 @@ import express from 'express'
|
|||
import { body, query } from 'express-validator'
|
||||
import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc'
|
||||
import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
const listUserNotificationsValidator = [
|
||||
|
@ -12,8 +11,6 @@ const listUserNotificationsValidator = [
|
|||
.isBoolean().withMessage('Should have a valid unread boolean'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking listUserNotificationsValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -47,8 +44,6 @@ const updateNotificationSettingsValidator = [
|
|||
.custom(isUserNotificationSettingValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking updateNotificationSettingsValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -61,8 +56,6 @@ const markAsReadUserNotificationsValidator = [
|
|||
.custom(isNotEmptyIntArray).withMessage('Should have a valid array of notification ids'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking markAsReadUserNotificationsValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
|
|
@ -3,7 +3,6 @@ import { body, param, query } from 'express-validator'
|
|||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
|
||||
import { toArray } from '../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { WEBSERVER } from '../../initializers/constants'
|
||||
import { ActorFollowModel } from '../../models/actor/actor-follow'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
@ -14,8 +13,6 @@ const userSubscriptionListValidator = [
|
|||
.not().isEmpty(),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking userSubscriptionListValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -27,8 +24,6 @@ const userSubscriptionAddValidator = [
|
|||
.custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking userSubscriptionAddValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -41,8 +36,6 @@ const areSubscriptionsExistValidator = [
|
|||
.custom(areValidActorHandles).withMessage('Should have a valid array of URIs'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking areSubscriptionsExistValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -54,8 +47,6 @@ const userSubscriptionGetValidator = [
|
|||
.custom(isValidActorHandle),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking userSubscriptionGetValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
let [ name, host ] = req.params.uri.split('@')
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import express from 'express'
|
||||
import { body, param, query } from 'express-validator'
|
||||
import { omit } from 'lodash'
|
||||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { MUserDefault } from '@server/types/models'
|
||||
import { HttpStatusCode, UserRegister, UserRight, UserRole } from '@shared/models'
|
||||
|
@ -41,8 +40,6 @@ const usersListValidator = [
|
|||
.isBoolean().withMessage('Should be a valid blocked boolena'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersList parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -76,9 +73,7 @@ const usersAddValidator = [
|
|||
.custom(isUserAdminFlagsValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersAdd parameters', { parameters: omit(req.body, 'password') })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (areValidationErrors(req, res, { omitBodyLog: true })) return
|
||||
if (!await checkUserNameOrEmailDoesNotAlreadyExist(req.body.username, req.body.email, res)) return
|
||||
|
||||
const authUser = res.locals.oauth.token.User
|
||||
|
@ -126,9 +121,7 @@ const usersRegisterValidator = [
|
|||
.custom(isVideoChannelDisplayNameValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersRegister parameters', { parameters: omit(req.body, 'password') })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (areValidationErrors(req, res, { omitBodyLog: true })) return
|
||||
if (!await checkUserNameOrEmailDoesNotAlreadyExist(req.body.username, req.body.email, res)) return
|
||||
|
||||
const body: UserRegister = req.body
|
||||
|
@ -159,8 +152,6 @@ const usersRemoveValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersRemove parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await checkUserIdExist(req.params.id, res)) return
|
||||
|
||||
|
@ -181,8 +172,6 @@ const usersBlockingValidator = [
|
|||
.custom(isUserBlockedReasonValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersBlocking parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await checkUserIdExist(req.params.id, res)) return
|
||||
|
||||
|
@ -236,9 +225,7 @@ const usersUpdateValidator = [
|
|||
.custom(isUserAdminFlagsValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersUpdate parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (areValidationErrors(req, res, { omitBodyLog: true })) return
|
||||
if (!await checkUserIdExist(req.params.id, res)) return
|
||||
|
||||
const user = res.locals.user
|
||||
|
@ -300,8 +287,6 @@ const usersUpdateMeValidator = [
|
|||
.custom(v => isUserAutoPlayNextVideoValid(v)).withMessage('Should have a valid autoPlayNextVideo boolean'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersUpdateMe parameters', { parameters: omit(req.body, 'password') })
|
||||
|
||||
const user = res.locals.oauth.token.User
|
||||
|
||||
if (req.body.password || req.body.email) {
|
||||
|
@ -321,7 +306,7 @@ const usersUpdateMeValidator = [
|
|||
}
|
||||
}
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (areValidationErrors(req, res, { omitBodyLog: true })) return
|
||||
|
||||
return next()
|
||||
}
|
||||
|
@ -335,8 +320,6 @@ const usersGetValidator = [
|
|||
.isBoolean().withMessage('Should have a valid withStats boolean'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersGet parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await checkUserIdExist(req.params.id, res, req.query.withStats)) return
|
||||
|
||||
|
@ -348,8 +331,6 @@ const usersVideoRatingValidator = [
|
|||
isValidVideoIdParam('videoId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersVideoRating parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res, 'id')) return
|
||||
|
||||
|
@ -369,8 +350,6 @@ const usersVideosValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersVideosValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (req.query.channelId && !await doesVideoChannelIdExist(req.query.channelId, res)) return
|
||||
|
@ -423,8 +402,6 @@ const usersAskResetPasswordValidator = [
|
|||
.isEmail(),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersAskResetPassword parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const exists = await checkUserEmailExist(req.body.email, res, false)
|
||||
|
@ -447,8 +424,6 @@ const usersResetPasswordValidator = [
|
|||
.custom(isUserPasswordValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersResetPassword parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await checkUserIdExist(req.params.id, res)) return
|
||||
|
||||
|
@ -470,9 +445,8 @@ const usersAskSendVerifyEmailValidator = [
|
|||
body('email').isEmail().not().isEmpty().withMessage('Should have a valid email'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking askUsersSendVerifyEmail parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const exists = await checkUserEmailExist(req.body.email, res, false)
|
||||
if (!exists) {
|
||||
logger.debug('User with email %s does not exist (asking verify email).', req.body.email)
|
||||
|
@ -495,8 +469,6 @@ const usersVerifyEmailValidator = [
|
|||
.customSanitizer(toBooleanOrNull),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking usersVerifyEmail parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await checkUserIdExist(req.params.id, res)) return
|
||||
|
||||
|
@ -515,7 +487,9 @@ const usersVerifyEmailValidator = [
|
|||
]
|
||||
|
||||
const userAutocompleteValidator = [
|
||||
param('search').isString().not().isEmpty().withMessage('Should have a search parameter')
|
||||
param('search')
|
||||
.isString()
|
||||
.not().isEmpty()
|
||||
]
|
||||
|
||||
const ensureAuthUserOwnsAccountValidator = [
|
||||
|
|
|
@ -3,15 +3,12 @@ import { body, query } from 'express-validator'
|
|||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors, doesVideoBlacklistExist, doesVideoExist, isValidVideoIdParam } from '../shared'
|
||||
|
||||
const videosBlacklistRemoveValidator = [
|
||||
isValidVideoIdParam('videoId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking blacklistRemove parameters.', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return
|
||||
if (!await doesVideoBlacklistExist(res.locals.videoAll.id, res)) return
|
||||
|
@ -32,8 +29,6 @@ const videosBlacklistAddValidator = [
|
|||
.custom(isVideoBlacklistReasonValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videosBlacklistAdd parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return
|
||||
|
||||
|
@ -57,8 +52,6 @@ const videosBlacklistUpdateValidator = [
|
|||
.custom(isVideoBlacklistReasonValid).withMessage('Should have a valid reason'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videosBlacklistUpdate parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return
|
||||
if (!await doesVideoBlacklistExist(res.locals.videoAll.id, res)) return
|
||||
|
@ -78,8 +71,6 @@ const videosBlacklistFiltersValidator = [
|
|||
.isEmpty().withMessage('Should have a valid search'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videos blacklist filters query', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
|
|
@ -3,7 +3,6 @@ import { body, param } from 'express-validator'
|
|||
import { UserRight } from '@shared/models'
|
||||
import { isVideoCaptionFile, isVideoCaptionLanguageValid } from '../../../helpers/custom-validators/video-captions'
|
||||
import { cleanUpReqFiles } from '../../../helpers/express-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { CONSTRAINTS_FIELDS, MIMETYPES } from '../../../initializers/constants'
|
||||
import {
|
||||
areValidationErrors,
|
||||
|
@ -30,8 +29,6 @@ const addVideoCaptionValidator = [
|
|||
),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking addVideoCaption parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return cleanUpReqFiles(req)
|
||||
|
||||
|
@ -50,8 +47,6 @@ const deleteVideoCaptionValidator = [
|
|||
.custom(isVideoCaptionLanguageValid).not().isEmpty().withMessage('Should have a valid caption language'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking deleteVideoCaption parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return
|
||||
if (!await doesVideoCaptionExist(res.locals.videoAll, req.params.captionLanguage, res)) return
|
||||
|
@ -68,8 +63,6 @@ const listVideoCaptionsValidator = [
|
|||
isValidVideoIdParam('videoId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking listVideoCaptions parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res, 'only-video')) return
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import * as express from 'express'
|
||||
import { body, param } from 'express-validator'
|
||||
import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { CONFIG } from '@server/initializers/config'
|
||||
import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync'
|
||||
import { HttpStatusCode, VideoChannelSyncCreate } from '@shared/models'
|
||||
|
@ -27,8 +26,6 @@ export const videoChannelSyncValidator = [
|
|||
.isInt(),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoChannelSync parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const body: VideoChannelSyncCreate = req.body
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
isVideoChannelSupportValid,
|
||||
isVideoChannelUsernameValid
|
||||
} from '../../../helpers/custom-validators/video-channels'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { ActorModel } from '../../../models/actor/actor'
|
||||
import { VideoChannelModel } from '../../../models/video/video-channel'
|
||||
import { areValidationErrors, checkUserQuota, doesVideoChannelNameWithHostExist } from '../shared'
|
||||
|
@ -31,8 +30,6 @@ export const videoChannelsAddValidator = [
|
|||
.custom(isVideoChannelSupportValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoChannelsAdd parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const actor = await ActorModel.loadLocalByName(req.body.name)
|
||||
|
@ -72,8 +69,6 @@ export const videoChannelsUpdateValidator = [
|
|||
.custom(isBooleanValid).withMessage('Should have a valid bulkVideosSupportUpdate boolean field'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoChannelsUpdate parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -82,8 +77,6 @@ export const videoChannelsUpdateValidator = [
|
|||
|
||||
export const videoChannelsRemoveValidator = [
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoChannelsRemove parameters', { parameters: req.params })
|
||||
|
||||
if (!await checkVideoChannelIsNotTheLastOne(res.locals.videoChannel, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -95,8 +88,6 @@ export const videoChannelsNameWithHostValidator = [
|
|||
.exists(),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoChannelsNameWithHostValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (!await doesVideoChannelNameWithHostExist(req.params.nameWithHost, res)) return
|
||||
|
@ -147,8 +138,6 @@ export const videoChannelsListValidator = [
|
|||
.not().isEmpty(),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking video channels search query', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -164,8 +153,6 @@ export const videoChannelImportVideosValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoChannelImport parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const body: VideosImportInChannelCreate = req.body
|
||||
|
|
|
@ -43,8 +43,6 @@ const listVideoCommentsValidator = [
|
|||
.custom(exists),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking listVideoCommentsValidator parameters.', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -55,8 +53,6 @@ const listVideoCommentThreadsValidator = [
|
|||
isValidVideoIdParam('videoId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking listVideoCommentThreads parameters.', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res, 'only-video')) return
|
||||
|
||||
|
@ -73,8 +69,6 @@ const listVideoThreadCommentsValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking listVideoThreadComments parameters.', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res, 'only-video')) return
|
||||
if (!await doesVideoCommentThreadExist(req.params.threadId, res.locals.onlyVideo, res)) return
|
||||
|
@ -92,8 +86,6 @@ const addVideoCommentThreadValidator = [
|
|||
.custom(isValidVideoCommentText),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking addVideoCommentThread parameters.', { parameters: req.params, body: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return
|
||||
|
||||
|
@ -114,8 +106,6 @@ const addVideoCommentReplyValidator = [
|
|||
body('text').custom(isValidVideoCommentText),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking addVideoCommentReply parameters.', { parameters: req.params, body: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return
|
||||
|
||||
|
@ -136,8 +126,6 @@ const videoCommentGetValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res, 'id')) return
|
||||
if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoId, res)) return
|
||||
|
@ -153,8 +141,6 @@ const removeVideoCommentValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking removeVideoCommentValidator parameters.', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return
|
||||
if (!await doesVideoCommentExist(req.params.commentId, res.locals.videoAll, res)) return
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
import express from 'express'
|
||||
import { param } from 'express-validator'
|
||||
import { isIdValid } from '@server/helpers/custom-validators/misc'
|
||||
import { MVideo } from '@server/types/models'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared'
|
||||
import { isIdValid } from '@server/helpers/custom-validators/misc'
|
||||
import { param } from 'express-validator'
|
||||
|
||||
const videoFilesDeleteWebTorrentValidator = [
|
||||
isValidVideoIdParam('id'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoFilesDeleteWebTorrent parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.id, res)) return
|
||||
|
||||
|
@ -44,8 +41,6 @@ const videoFilesDeleteWebTorrentFileValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoFilesDeleteWebTorrentFile parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.id, res)) return
|
||||
|
||||
|
@ -78,8 +73,6 @@ const videoFilesDeleteHLSValidator = [
|
|||
isValidVideoIdParam('id'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoFilesDeleteHLS parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.id, res)) return
|
||||
|
||||
|
@ -112,8 +105,6 @@ const videoFilesDeleteHLSFileValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoFilesDeleteHLSFile parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.id, res)) return
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ const videoImportAddValidator = getCommonVideoEditAttributes().concat([
|
|||
),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoImportAddValidator parameters', { parameters: req.body })
|
||||
|
||||
const user = res.locals.oauth.token.User
|
||||
const torrentFile = req.files?.['torrentfile'] ? req.files['torrentfile'][0] : undefined
|
||||
|
||||
|
@ -98,8 +96,6 @@ const getMyVideoImportsValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking getMyVideoImportsValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -111,8 +107,6 @@ const videoImportDeleteValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoImportDeleteValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (!await doesVideoImportExist(parseInt(req.params.id), res)) return
|
||||
|
@ -134,8 +128,6 @@ const videoImportCancelValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoImportCancelValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (!await doesVideoImportExist(parseInt(req.params.id), res)) return
|
||||
|
|
|
@ -6,6 +6,7 @@ import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
|
|||
import { Hooks } from '@server/lib/plugins/hooks'
|
||||
import { VideoModel } from '@server/models/video/video'
|
||||
import { VideoLiveModel } from '@server/models/video/video-live'
|
||||
import { VideoLiveSessionModel } from '@server/models/video/video-live-session'
|
||||
import {
|
||||
HttpStatusCode,
|
||||
LiveVideoCreate,
|
||||
|
@ -28,14 +29,11 @@ import {
|
|||
isValidVideoIdParam
|
||||
} from '../shared'
|
||||
import { getCommonVideoEditAttributes } from './videos'
|
||||
import { VideoLiveSessionModel } from '@server/models/video/video-live-session'
|
||||
|
||||
const videoLiveGetValidator = [
|
||||
isValidVideoIdParam('videoId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoLiveGetValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res, 'all')) return
|
||||
|
||||
|
@ -79,8 +77,6 @@ const videoLiveAddValidator = getCommonVideoEditAttributes().concat([
|
|||
.custom(isLiveLatencyModeValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoLiveAddValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
|
||||
|
||||
if (CONFIG.LIVE.ENABLED !== true) {
|
||||
|
@ -163,8 +159,6 @@ const videoLiveUpdateValidator = [
|
|||
.custom(isLiveLatencyModeValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoLiveUpdateValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const body: LiveVideoUpdate = req.body
|
||||
|
@ -197,8 +191,6 @@ const videoLiveUpdateValidator = [
|
|||
|
||||
const videoLiveListSessionsValidator = [
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoLiveListSessionsValidator parameters', { parameters: req.params })
|
||||
|
||||
// Check the user can manage the live
|
||||
const user = res.locals.oauth.token.User
|
||||
if (!checkUserCanManageVideo(user, res.locals.videoAll, UserRight.GET_ANY_LIVE, res)) return
|
||||
|
@ -211,8 +203,6 @@ const videoLiveFindReplaySessionValidator = [
|
|||
isValidVideoIdParam('videoId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoLiveFindReplaySessionValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res, 'id')) return
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import express from 'express'
|
|||
import { param } from 'express-validator'
|
||||
import { isIdValid } from '@server/helpers/custom-validators/misc'
|
||||
import { checkUserCanTerminateOwnershipChange } from '@server/helpers/custom-validators/video-ownership'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { AccountModel } from '@server/models/account/account'
|
||||
import { MVideoWithAllFiles } from '@server/types/models'
|
||||
import { HttpStatusCode, UserRight, VideoChangeOwnershipAccept, VideoChangeOwnershipStatus, VideoState } from '@shared/models'
|
||||
|
@ -20,8 +19,6 @@ const videosChangeOwnershipValidator = [
|
|||
isValidVideoIdParam('videoId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking changeOwnership parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res)) return
|
||||
|
||||
|
@ -44,8 +41,6 @@ const videosTerminateChangeOwnershipValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking changeOwnership parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesChangeVideoOwnershipExist(req.params.id, res)) return
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ import {
|
|||
} from '../../../helpers/custom-validators/video-playlists'
|
||||
import { isVideoImageValid } from '../../../helpers/custom-validators/videos'
|
||||
import { cleanUpReqFiles } from '../../../helpers/express-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
|
||||
import { VideoPlaylistElementModel } from '../../../models/video/video-playlist-element'
|
||||
import { MVideoPlaylist } from '../../../types/models/video/video-playlist'
|
||||
|
@ -48,8 +47,6 @@ const videoPlaylistsAddValidator = getCommonPlaylistEditAttributes().concat([
|
|||
.custom(isVideoPlaylistNameValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoPlaylistsAddValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
|
||||
|
||||
const body: VideoPlaylistCreate = req.body
|
||||
|
@ -76,8 +73,6 @@ const videoPlaylistsUpdateValidator = getCommonPlaylistEditAttributes().concat([
|
|||
.custom(isVideoPlaylistNameValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoPlaylistsUpdateValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
|
||||
|
||||
if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return cleanUpReqFiles(req)
|
||||
|
@ -118,8 +113,6 @@ const videoPlaylistsDeleteValidator = [
|
|||
isValidPlaylistIdParam('playlistId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoPlaylistsDeleteValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (!await doesVideoPlaylistExist(req.params.playlistId, res)) return
|
||||
|
@ -142,8 +135,6 @@ const videoPlaylistsGetValidator = (fetchType: VideoPlaylistFetchType) => {
|
|||
isValidPlaylistIdParam('playlistId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoPlaylistsGetValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (!await doesVideoPlaylistExist(req.params.playlistId, res, fetchType)) return
|
||||
|
@ -189,8 +180,6 @@ const videoPlaylistsSearchValidator = [
|
|||
.not().isEmpty(),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoPlaylists search query', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -211,8 +200,6 @@ const videoPlaylistsAddVideoValidator = [
|
|||
.custom(isVideoPlaylistTimestampValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoPlaylistsAddVideoValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return
|
||||
|
@ -241,8 +228,6 @@ const videoPlaylistsUpdateOrRemoveVideoValidator = [
|
|||
.custom(isVideoPlaylistTimestampValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoPlaylistsRemoveVideoValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return
|
||||
|
@ -271,8 +256,6 @@ const videoPlaylistElementAPGetValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoPlaylistElementAPGetValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const playlistElementId = parseInt(req.params.playlistElementId + '', 10)
|
||||
|
@ -312,8 +295,6 @@ const videoPlaylistsReorderVideosValidator = [
|
|||
.isInt({ min: 1 }),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoPlaylistsReorderVideosValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
if (!await doesVideoPlaylistExist(req.params.playlistId, res, 'all')) return
|
||||
|
@ -346,8 +327,6 @@ const commonVideoPlaylistFiltersValidator = [
|
|||
.custom(isVideoPlaylistTypeValid),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking commonVideoPlaylistFiltersValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
@ -360,8 +339,6 @@ const doVideosInPlaylistExistValidator = [
|
|||
.custom(v => isArrayOf(v, isIdValid)).withMessage('Should have a valid video ids array'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking areVideosInPlaylistExistValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
|
|
@ -6,7 +6,6 @@ import { isAccountNameValid } from '../../../helpers/custom-validators/accounts'
|
|||
import { isIdValid } from '../../../helpers/custom-validators/misc'
|
||||
import { isRatingValid } from '../../../helpers/custom-validators/video-rates'
|
||||
import { isVideoRatingTypeValid } from '../../../helpers/custom-validators/videos'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
|
||||
import { areValidationErrors, checkCanSeeVideo, doesVideoExist, isValidVideoIdParam } from '../shared'
|
||||
|
||||
|
@ -17,8 +16,6 @@ const videoUpdateRateValidator = [
|
|||
.custom(isVideoRatingTypeValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoRate parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.id, res)) return
|
||||
|
||||
|
@ -36,8 +33,6 @@ const getAccountVideoRateValidatorFactory = function (rateType: VideoRateType) {
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoCommentGetValidator parameters.', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const rate = await AccountVideoRateModel.loadLocalAndPopulateVideo(rateType, req.params.name, +req.params.videoId)
|
||||
|
@ -61,8 +56,6 @@ const videoRatingValidator = [
|
|||
.custom(isRatingValid).withMessage('Value must be one of "like" or "dislike"'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking rating parameter', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
|
|
|
@ -2,7 +2,6 @@ import express from 'express'
|
|||
import { param } from 'express-validator'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { isIdValid } from '../../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { VideoShareModel } from '../../../models/video/video-share'
|
||||
import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared'
|
||||
|
||||
|
@ -13,8 +12,6 @@ const videosShareValidator = [
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoShare parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.id, res)) return
|
||||
|
||||
|
|
|
@ -3,15 +3,12 @@ import { getVideoWithAttributes } from '@server/helpers/video'
|
|||
import { VideoSourceModel } from '@server/models/video/video-source'
|
||||
import { MVideoFullLight } from '@server/types/models'
|
||||
import { HttpStatusCode, UserRight } from '@shared/models'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors, checkUserCanManageVideo, doesVideoExist, isValidVideoIdParam } from '../shared'
|
||||
|
||||
const videoSourceGetValidator = [
|
||||
isValidVideoIdParam('id'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoSourceGet parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.id, res, 'for-api')) return
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import { isDateValid } from '@server/helpers/custom-validators/misc'
|
|||
import { isValidStatTimeserieMetric } from '@server/helpers/custom-validators/video-stats'
|
||||
import { STATS_TIMESERIE } from '@server/initializers/constants'
|
||||
import { HttpStatusCode, UserRight, VideoStatsTimeserieQuery } from '@shared/models'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors, checkUserCanManageVideo, doesVideoExist, isValidVideoIdParam } from '../shared'
|
||||
|
||||
const videoOverallStatsValidator = [
|
||||
|
@ -19,8 +18,6 @@ const videoOverallStatsValidator = [
|
|||
.custom(isDateValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoOverallStatsValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await commonStatsCheck(req, res)) return
|
||||
|
||||
|
@ -32,8 +29,6 @@ const videoRetentionStatsValidator = [
|
|||
isValidVideoIdParam('videoId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoRetentionStatsValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await commonStatsCheck(req, res)) return
|
||||
|
||||
|
@ -63,8 +58,6 @@ const videoTimeserieStatsValidator = [
|
|||
.custom(isDateValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoTimeserieStatsValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await commonStatsCheck(req, res)) return
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import { CONFIG } from '@server/initializers/config'
|
|||
import { approximateIntroOutroAdditionalSize, getTaskFile } from '@server/lib/video-studio'
|
||||
import { isAudioFile } from '@shared/extra-utils'
|
||||
import { HttpStatusCode, UserRight, VideoState, VideoStudioCreateEdition, VideoStudioTask } from '@shared/models'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors, checkUserCanManageVideo, checkUserQuota, doesVideoExist } from '../shared'
|
||||
|
||||
const videoStudioAddEditionValidator = [
|
||||
|
@ -23,8 +22,6 @@ const videoStudioAddEditionValidator = [
|
|||
.custom(isValidStudioTasksArray).withMessage('Should have a valid array of tasks'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoStudioAddEditionValidator parameters.', { parameters: req.params, body: req.body, files: req.files })
|
||||
|
||||
if (CONFIG.VIDEO_STUDIO.ENABLED !== true) {
|
||||
res.fail({
|
||||
status: HttpStatusCode.BAD_REQUEST_400,
|
||||
|
|
|
@ -4,7 +4,6 @@ import { isValidCreateTranscodingType } from '@server/helpers/custom-validators/
|
|||
import { CONFIG } from '@server/initializers/config'
|
||||
import { VideoJobInfoModel } from '@server/models/video/video-job-info'
|
||||
import { HttpStatusCode } from '@shared/models'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared'
|
||||
|
||||
const createTranscodingValidator = [
|
||||
|
@ -14,8 +13,6 @@ const createTranscodingValidator = [
|
|||
.custom(isValidCreateTranscodingType),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking createTranscodingValidator parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res, 'all')) return
|
||||
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
import express from 'express'
|
||||
import { body, param } from 'express-validator'
|
||||
import { isVideoTimeValid } from '@server/helpers/custom-validators/video-view'
|
||||
import { getCachedVideoDuration } from '@server/lib/video'
|
||||
import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer'
|
||||
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
|
||||
import { exists, isIdValid, isIntOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared'
|
||||
import { getCachedVideoDuration } from '@server/lib/video'
|
||||
|
||||
const getVideoLocalViewerValidator = [
|
||||
param('localViewerId')
|
||||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking getVideoLocalViewerValidator parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
const localViewer = await LocalVideoViewerModel.loadFullById(+req.params.localViewerId)
|
||||
|
@ -40,8 +37,6 @@ const videoViewValidator = [
|
|||
.custom(isIntOrNull),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoView parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.videoId, res, 'only-immutable-attributes')) return
|
||||
|
||||
|
|
|
@ -72,8 +72,6 @@ const videosAddLegacyValidator = getCommonVideoEditAttributes().concat([
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files })
|
||||
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
|
||||
|
||||
const videoFile: express.VideoUploadFile = req.files['videofile'][0]
|
||||
|
@ -202,7 +200,7 @@ const videosAddResumableInitValidator = getCommonVideoEditAttributes().concat([
|
|||
files: req.files
|
||||
})
|
||||
|
||||
if (areValidationErrors(req, res)) return cleanup()
|
||||
if (areValidationErrors(req, res, { omitLog: true })) return cleanup()
|
||||
|
||||
const files = { videofile: [ videoFileMetadata ] }
|
||||
if (!await commonVideoChecksPass({ req, res, user, videoFileSize: videoFileMetadata.size, files })) return cleanup()
|
||||
|
@ -231,8 +229,6 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
|
|||
.custom(isIdValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videosUpdate parameters', { parameters: req.body })
|
||||
|
||||
if (areValidationErrors(req, res)) return cleanUpReqFiles(req)
|
||||
if (areErrorsInScheduleUpdate(req, res)) return cleanUpReqFiles(req)
|
||||
if (!await doesVideoExist(req.params.id, res)) return cleanUpReqFiles(req)
|
||||
|
@ -284,8 +280,6 @@ const videosCustomGetValidator = (
|
|||
isValidVideoIdParam('id'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videosGet parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.id, res, fetchType)) return
|
||||
|
||||
|
@ -311,8 +305,6 @@ const videoFileMetadataGetValidator = getCommonVideoEditAttributes().concat([
|
|||
.custom(isIdValid).not().isEmpty().withMessage('Should have a valid videoFileId'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videoFileMetadataGet parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoFileOfVideoExist(+req.params.videoFileId, req.params.id, res)) return
|
||||
|
||||
|
@ -324,8 +316,6 @@ const videosRemoveValidator = [
|
|||
isValidVideoIdParam('id'),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking videosRemove parameters', { parameters: req.params })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
if (!await doesVideoExist(req.params.id, res)) return
|
||||
|
||||
|
@ -485,8 +475,6 @@ const commonVideosFiltersValidator = [
|
|||
.custom(exists),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking commons video filters query', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
// FIXME: deprecated in 4.0, to remove
|
||||
|
|
|
@ -3,7 +3,6 @@ import { query } from 'express-validator'
|
|||
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
|
||||
import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger'
|
||||
import { getHostWithPort } from '../../helpers/express-utils'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { ActorModel } from '../../models/actor/actor'
|
||||
import { areValidationErrors } from './shared'
|
||||
|
||||
|
@ -12,8 +11,6 @@ const webfingerValidator = [
|
|||
.custom(isWebfingerLocalResourceValid),
|
||||
|
||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking webfinger parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
// Remove 'acct:' from the beginning of the string
|
||||
|
|
Loading…
Reference in a new issue