.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
.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
.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
.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()
.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()
.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
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.' })
.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()
.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
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 = [
.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
.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
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 = [
.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()
(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()
}
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'
),
(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()
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'
.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
.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
.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
.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
.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
.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()
.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()
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 = [
.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
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(),
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
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,
.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()
.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
.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
.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)) {
})
}
- logger.debug('Checking follow parameters', { parameters: req.body })
-
if (areValidationErrors(req, res)) return
const body: ServerFollowCreate = req.body
.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()
.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
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.' })
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.' })
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')
.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()
}
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 = [
.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)
}
.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()
.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()
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 = [
.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
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'
.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') {
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()
.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()
}
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'
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)
.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
.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()
.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()
.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
.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()
.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)
.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()
.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) {
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'
.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
.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
.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)
.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()
.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
.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))
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 = [
.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()
.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()
.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()
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)
.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) {
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()) {
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'
.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()
}
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'
.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)
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 = [
.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()
.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()
.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()
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 = [
.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()
.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()
.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()
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'
.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()
.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()
.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()
.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('@')
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'
.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()
.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
.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
.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
.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
.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
.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) {
}
}
- if (areValidationErrors(req, res)) return
+ if (areValidationErrors(req, res, { omitBodyLog: true })) return
return next()
}
.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
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
.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
.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)
.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
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)
.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
]
const userAutocompleteValidator = [
- param('search').isString().not().isEmpty().withMessage('Should have a search parameter')
+ param('search')
+ .isString()
+ .not().isEmpty()
]
const ensureAuthUserOwnsAccountValidator = [
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
.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
.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
.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()
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,
),
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)
.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
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
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'
.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
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'
.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)
.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()
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()
.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
.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()
.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
.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()
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
.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
.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
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
.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
.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
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
.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
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
.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
),
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
.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()
.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
.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
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,
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
.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) {
.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
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
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
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'
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
.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
} 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'
.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
.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)
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
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
.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()
.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
.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
.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)
.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
.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()
.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()
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'
.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
.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)
.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()
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'
.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
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
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 = [
.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
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
.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
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 = [
.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,
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 = [
.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
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)
.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
.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]
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()
.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)
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
.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
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
.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
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'
.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