const scrollObservable = fromEvent(this.container || window, 'scroll')
.pipe(
- startWith(null),
+ startWith(null as string), // FIXME: typings
throttleTime(200, undefined, throttleOptions),
map(() => this.getScrollInfo()),
distinctUntilChanged((o1, o2) => o1.current === o2.current),
<div class="video-info-privacy">
<ng-container *ngIf="displayOptions.privacyText">{{ video.privacy.label }}</ng-container>
- <ng-container *ngIf="displayOptions.privacyText && displayOptions.state"> - </ng-container>
+ <ng-container *ngIf="displayOptions.privacyText && getStateLabel(video)"> - </ng-container>
<ng-container *ngIf="displayOptions.state">{{ getStateLabel(video) }}</ng-container>
</div>
)
// Video did change
- forkJoin(
+ forkJoin([
videoObs,
this.videoCaptionService.listCaptions(videoId)
- )
+ ])
.pipe(
// If 401, the video is private or blacklisted so redirect to 404
catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ]))
-import 'express-validator'
import { isUserDescriptionValid, isUserUsernameValid } from './users'
import { exists } from './misc'
import 'multer'
import * as validator from 'validator'
import { sep } from 'path'
+import toBoolean = require('validator/lib/toBoolean')
function exists (value: any) {
return value !== undefined && value !== null
}
function toIntOrNull (value: string) {
- if (value === 'null') return null
+ const v = toValueOrNull(value)
+
+ if (v === null || v === undefined) return v
+ if (typeof v === 'number') return v
+
+ return validator.toInt(v)
+}
+
+function toBooleanOrNull (value: any) {
+ const v = toValueOrNull(value)
+
+ if (v === null || v === undefined) return v
+ if (typeof v === 'boolean') return v
- return validator.toInt(value)
+ return toBoolean(v)
}
function toValueOrNull (value: string) {
isIdOrUUIDValid,
isDateValid,
toValueOrNull,
+ toBooleanOrNull,
isBooleanValid,
toIntOrNull,
toArray,
import * as validator from 'validator'
-import 'express-validator'
-
import { isArray } from './misc'
function isNumberArray (value: any) {
import * as validator from 'validator'
-import 'express-validator'
-
-import { isArray, exists } from './misc'
+import { exists, isArray } from './misc'
import { isTestInstance } from '../core-utils'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
-import 'express-validator'
import * as validator from 'validator'
import { UserRole } from '../../../shared'
import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants'
-import 'express-validator'
-import 'multer'
import * as validator from 'validator'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
import { exists } from './misc'
-import 'express-validator'
import 'multer'
import * as validator from 'validator'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
-import 'express-validator'
import 'multer'
import * as validator from 'validator'
import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers/constants'
-import { Response } from 'express'
-import 'express-validator'
import { values } from 'lodash'
-import 'multer'
import * as validator from 'validator'
-import { UserRight, VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared'
+import { VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared'
import {
CONSTRAINTS_FIELDS,
MIMETYPES,
VIDEO_RATE_TYPES,
VIDEO_STATES
} from '../../initializers/constants'
-import { VideoModel } from '../../models/video/video'
import { exists, isArray, isDateValid, isFileValid } from './misc'
-import { UserModel } from '../../models/account/user'
import * as magnetUtil from 'magnet-uri'
const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
import * as express from 'express'
import * as OAuthServer from 'express-oauth-server'
-import 'express-validator'
import { OAUTH_LIFETIME } from '../initializers/constants'
import { logger } from '../helpers/logger'
import { Socket } from 'socket.io'
-import 'express-validator'
import * as express from 'express'
-
import { PAGINATION } from '../initializers/constants'
function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
import * as express from 'express'
-import 'express-validator'
import { getHostWithPort } from '../helpers/express-utils'
function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) {
import * as express from 'express'
-import 'express-validator'
import { SortType } from '../models/utils'
function setDefaultSort (req: express.Request, res: express.Response, next: express.NextFunction) {
import * as express from 'express'
-import 'express-validator'
import { UserRight } from '../../shared'
import { logger } from '../helpers/logger'
import * as express from 'express'
-import { param } from 'express-validator/check'
+import { param } from 'express-validator'
import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import * as express from 'express'
-import { body } from 'express-validator/check'
+import { body } from 'express-validator'
import {
isSignatureCreatorValid, isSignatureTypeValid,
isSignatureValueValid
import * as express from 'express'
-import { body } from 'express-validator/check'
+import { body } from 'express-validator'
import { isAvatarFile } from '../../helpers/custom-validators/users'
import { areValidationErrors } from './utils'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
-import { body, param } from 'express-validator/check'
+import { body, param } from 'express-validator'
import * as express from 'express'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import * as express from 'express'
-import { body } from 'express-validator/check'
+import { body } from 'express-validator'
import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users'
import { logger } from '../../helpers/logger'
import { CustomConfig } from '../../../shared/models/server/custom-config.model'
import * as express from 'express'
-import { param, query } from 'express-validator/check'
+import { param, query } from 'express-validator'
import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import * as express from 'express'
-import { body, param } from 'express-validator/check'
+import { body, param } from 'express-validator'
import { isTestInstance } from '../../helpers/core-utils'
import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
import { logger } from '../../helpers/logger'
import * as express from 'express'
-import { param } from 'express-validator/check'
+import { param } from 'express-validator'
import { isValidJobState } from '../../helpers/custom-validators/jobs'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { isDateValid } from '../../helpers/custom-validators/misc'
-import { query } from 'express-validator/check'
+import { query } from 'express-validator'
import { isValidLogLevel } from '../../helpers/custom-validators/logs'
const getLogsValidator = [
import * as express from 'express'
-import { query } from 'express-validator/check'
+import { query } from 'express-validator'
import { join } from 'path'
import { isTestInstance } from '../../helpers/core-utils'
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
import * as express from 'express'
-import { query } from 'express-validator/check'
+import { query } from 'express-validator'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import * as express from 'express'
-import { body, param, query } from 'express-validator/check'
+import { body, param, query } from 'express-validator'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
import { PluginManager } from '../../lib/plugins/plugin-manager'
-import { isBooleanValid, isSafePath } from '../../helpers/custom-validators/misc'
+import { isBooleanValid, isSafePath, toBooleanOrNull } from '../../helpers/custom-validators/misc'
import { PluginModel } from '../../models/server/plugin'
import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model'
import { PluginType } from '../../../shared/models/plugins/plugin.type'
.custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
query('uninstalled')
.optional()
- .toBoolean()
+ .customSanitizer(toBooleanOrNull)
.custom(isBooleanValid).withMessage('Should have a valid uninstalled attribute'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
import * as express from 'express'
-import 'express-validator'
-import { body, param } from 'express-validator/check'
-import { exists, isBooleanValid, isIdOrUUIDValid, toIntOrNull } from '../../helpers/custom-validators/misc'
+import { body, param } from 'express-validator'
+import { exists, isBooleanValid, isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
const updateServerRedundancyValidator = [
param('host').custom(isHostValid).withMessage('Should have a valid host'),
body('redundancyAllowed')
- .toBoolean()
+ .customSanitizer(toBooleanOrNull)
.custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed attribute'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
import * as express from 'express'
import { areValidationErrors } from './utils'
import { logger } from '../../helpers/logger'
-import { query } from 'express-validator/check'
+import { query } from 'express-validator'
import { isDateValid } from '../../helpers/custom-validators/misc'
const videosSearchValidator = [
import { areValidationErrors } from './utils'
import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers'
import { ServerModel } from '../../models/server/server'
-import { body } from 'express-validator/check'
+import { body } from 'express-validator'
import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
import { Emailer } from '../../lib/emailer'
import { Redis } from '../../lib/redis'
import * as express from 'express'
-import { param } from 'express-validator/check'
+import { param } from 'express-validator'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
import * as express from 'express'
-import 'express-validator'
-import { body } from 'express-validator/check'
+import { body } from 'express-validator'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { isDateValid } from '../../helpers/custom-validators/misc'
import * as express from 'express'
-import 'express-validator'
-import { body, query } from 'express-validator/check'
+import { body, query } from 'express-validator'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
-import { isNotEmptyIntArray } from '../../helpers/custom-validators/misc'
+import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc'
const listUserNotificationsValidator = [
query('unread')
.optional()
- .toBoolean()
+ .customSanitizer(toBooleanOrNull)
.isBoolean().withMessage('Should have a valid unread boolean'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
import * as express from 'express'
-import 'express-validator'
-import { body, param, query } from 'express-validator/check'
+import { body, param, query } from 'express-validator'
import { logger } from '../../helpers/logger'
import { areValidationErrors } from './utils'
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
import * as Bluebird from 'bluebird'
import * as express from 'express'
-import 'express-validator'
-import { body, param } from 'express-validator/check'
+import { body, param } from 'express-validator'
import { omit } from 'lodash'
-import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
+import { isIdOrUUIDValid, toIntOrNull } from '../../helpers/custom-validators/misc'
import {
isUserAdminFlagsValid,
isUserAutoPlayVideoValid,
.not().isEmpty().withMessage('Should have a valid verification string'),
body('isPendingEmail')
.optional()
- .toBoolean(),
+ .customSanitizer(toIntOrNull),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersVerifyEmail parameters', { parameters: req.params })
import * as express from 'express'
-import { query, validationResult } from 'express-validator/check'
+import { query, validationResult } from 'express-validator'
import { logger } from '../../helpers/logger'
function areValidationErrors (req: express.Request, res: express.Response) {
import * as express from 'express'
-import 'express-validator'
-import { body, param } from 'express-validator/check'
+import { body, param } from 'express-validator'
import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
import { logger } from '../../../helpers/logger'
import { areValidationErrors } from '../utils'
import * as express from 'express'
-import { body, param, query } from 'express-validator/check'
-import { isBooleanValid, isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
+import { body, param, query } from 'express-validator'
+import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
import { logger } from '../../../helpers/logger'
import { areValidationErrors } from '../utils'
import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist'
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
body('unfederate')
.optional()
- .toBoolean()
+ .customSanitizer(toBooleanOrNull)
.custom(isBooleanValid).withMessage('Should have a valid unfederate boolean'),
body('reason')
.optional()
import * as express from 'express'
import { areValidationErrors } from '../utils'
import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
-import { body, param } from 'express-validator/check'
+import { body, param } from 'express-validator'
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
import { UserRight } from '../../../../shared'
import { logger } from '../../../helpers/logger'
import * as express from 'express'
-import { body, param } from 'express-validator/check'
+import { body, param } from 'express-validator'
import { UserRight } from '../../../../shared'
import {
isVideoChannelDescriptionValid,
import * as express from 'express'
-import { body, param } from 'express-validator/check'
+import { body, param } from 'express-validator'
import { UserRight } from '../../../../shared'
import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments'
import * as express from 'express'
-import { body } from 'express-validator/check'
-import { isIdValid } from '../../../helpers/custom-validators/misc'
+import { body } from 'express-validator'
+import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
import { logger } from '../../../helpers/logger'
import { areValidationErrors } from '../utils'
import { getCommonVideoEditAttributes } from './videos'
const videoImportAddValidator = getCommonVideoEditAttributes().concat([
body('channelId')
- .toInt()
+ .customSanitizer(toIntOrNull)
.custom(isIdValid).withMessage('Should have correct video channel id'),
body('targetUrl')
.optional()
import * as express from 'express'
-import { body, param, query, ValidationChain } from 'express-validator/check'
+import { body, param, query, ValidationChain } from 'express-validator'
import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared'
import { logger } from '../../../helpers/logger'
import { UserModel } from '../../../models/account/user'
import { areValidationErrors } from '../utils'
import { isVideoImage } from '../../../helpers/custom-validators/videos'
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
-import { isArrayOf, isIdOrUUIDValid, isIdValid, isUUIDValid, toIntArray, toValueOrNull } from '../../../helpers/custom-validators/misc'
+import {
+ isArrayOf,
+ isIdOrUUIDValid,
+ isIdValid,
+ isUUIDValid,
+ toIntArray,
+ toIntOrNull,
+ toValueOrNull
+} from '../../../helpers/custom-validators/misc'
import {
isVideoPlaylistDescriptionValid,
isVideoPlaylistNameValid,
.custom(isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'),
body('privacy')
.optional()
- .toInt()
+ .customSanitizer(toIntOrNull)
.custom(isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'),
body('videoChannelId')
.optional()
- .customSanitizer(toValueOrNull)
- .toInt()
+ .customSanitizer(toIntOrNull)
] as (ValidationChain | express.Handler)[]
}
import * as express from 'express'
-import 'express-validator'
-import { body, param, query } from 'express-validator/check'
+import { body, param, query } from 'express-validator'
import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
import { isRatingValid } from '../../../helpers/custom-validators/video-rates'
import { isVideoRatingTypeValid } from '../../../helpers/custom-validators/videos'
import * as express from 'express'
-import 'express-validator'
-import { param } from 'express-validator/check'
+import { param } from 'express-validator'
import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
import { logger } from '../../../helpers/logger'
import { VideoShareModel } from '../../../models/video/video-share'
-import { body, param } from 'express-validator/check'
+import { body, param } from 'express-validator'
import * as express from 'express'
-import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
+import { isIdOrUUIDValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
import { areValidationErrors } from '../utils'
import { logger } from '../../../helpers/logger'
import { doesVideoExist } from '../../../helpers/middlewares'
const videoWatchingValidator = [
param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
body('currentTime')
- .toInt()
+ .customSanitizer(toIntOrNull)
.isInt().withMessage('Should have correct current time'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
import * as express from 'express'
-import 'express-validator'
-import { body, param, query, ValidationChain } from 'express-validator/check'
+import { body, param, query, ValidationChain } from 'express-validator'
import { UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared'
import {
isBooleanValid,
isIdValid,
isUUIDValid,
toArray,
+ toBooleanOrNull,
toIntOrNull,
toValueOrNull
} from '../../../helpers/custom-validators/misc'
),
body('name').custom(isVideoNameValid).withMessage('Should have a valid name'),
body('channelId')
- .toInt()
+ .customSanitizer(toIntOrNull)
.custom(isIdValid).withMessage('Should have correct video channel id'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
.custom(isVideoNameValid).withMessage('Should have a valid name'),
body('channelId')
.optional()
- .toInt()
+ .customSanitizer(toIntOrNull)
.custom(isIdValid).withMessage('Should have correct video channel id'),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
.custom(isVideoLanguageValid).withMessage('Should have a valid language'),
body('nsfw')
.optional()
- .toBoolean()
+ .customSanitizer(toBooleanOrNull)
.custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'),
body('waitTranscoding')
.optional()
- .toBoolean()
+ .customSanitizer(toBooleanOrNull)
.custom(isBooleanValid).withMessage('Should have a valid wait transcoding attribute'),
body('privacy')
.optional()
- .toInt()
+ .customSanitizer(toValueOrNull)
.custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'),
body('description')
.optional()
.custom(isVideoTagsValid).withMessage('Should have correct tags'),
body('commentsEnabled')
.optional()
- .toBoolean()
+ .customSanitizer(toBooleanOrNull)
.custom(isBooleanValid).withMessage('Should have comments enabled boolean'),
body('downloadEnabled')
.optional()
- .toBoolean()
+ .customSanitizer(toBooleanOrNull)
.custom(isBooleanValid).withMessage('Should have downloading enabled boolean'),
body('originallyPublishedAt')
- .optional()
- .customSanitizer(toValueOrNull)
- .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'),
+ .optional()
+ .customSanitizer(toValueOrNull)
+ .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'),
body('scheduleUpdate')
.optional()
.customSanitizer(toValueOrNull),
.custom(isDateValid).withMessage('Should have a valid schedule update date'),
body('scheduleUpdate.privacy')
.optional()
- .toInt()
+ .customSanitizer(toValueOrNull)
.custom(isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy')
] as (ValidationChain | express.Handler)[]
}
import * as express from 'express'
-import { query } from 'express-validator/check'
+import { query } from 'express-validator'
import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger'
import { logger } from '../../helpers/logger'
import { ActorModel } from '../../models/activitypub/actor'
support: 'my super support text',
tags: [ 'tag1', 'tag2' ],
privacy: VideoPrivacy.PUBLIC,
- channelId: channelId
+ channelId
}
})