mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Fix issues on server start
This commit is contained in:
parent
1e1265b36c
commit
e34c85e527
14 changed files with 96 additions and 65 deletions
|
@ -3,6 +3,7 @@ import * as validator from 'validator'
|
|||
import { exists, isUUIDValid } from '../misc'
|
||||
import { isActivityPubUrlValid } from './misc'
|
||||
import { isUserUsernameValid } from '../users'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
|
||||
|
||||
function isAccountEndpointsObjectValid (endpointObject: any) {
|
||||
return isAccountSharedInboxValid(endpointObject.sharedInbox)
|
||||
|
@ -34,7 +35,8 @@ function isAccountPublicKeyValid (publicKey: string) {
|
|||
return exists(publicKey) &&
|
||||
typeof publicKey === 'string' &&
|
||||
publicKey.startsWith('-----BEGIN PUBLIC KEY-----') &&
|
||||
publicKey.endsWith('-----END PUBLIC KEY-----')
|
||||
publicKey.endsWith('-----END PUBLIC KEY-----') &&
|
||||
validator.isLength(publicKey, CONSTRAINTS_FIELDS.ACCOUNTS.PUBLIC_KEY)
|
||||
}
|
||||
|
||||
function isAccountIdValid (id: string) {
|
||||
|
@ -73,7 +75,8 @@ function isAccountPrivateKeyValid (privateKey: string) {
|
|||
return exists(privateKey) &&
|
||||
typeof privateKey === 'string' &&
|
||||
privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') &&
|
||||
privateKey.endsWith('-----END RSA PRIVATE KEY-----')
|
||||
privateKey.endsWith('-----END RSA PRIVATE KEY-----') &&
|
||||
validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACCOUNTS.PRIVATE_KEY)
|
||||
}
|
||||
|
||||
function isRemoteAccountValid (remoteAccount: any) {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import * as validator from 'validator'
|
||||
import { exists } from '../misc'
|
||||
import { isTestInstance } from '../../core-utils'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
|
||||
|
||||
function isActivityPubUrlValid (url: string) {
|
||||
const isURLOptions = {
|
||||
|
@ -9,7 +12,12 @@ function isActivityPubUrlValid (url: string) {
|
|||
protocols: [ 'http', 'https' ]
|
||||
}
|
||||
|
||||
return exists(url) && validator.isURL(url, isURLOptions)
|
||||
// We validate 'localhost', so we don't have the top level domain
|
||||
if (isTestInstance()) {
|
||||
isURLOptions.require_tld = false
|
||||
}
|
||||
|
||||
return exists(url) && validator.isURL(url, isURLOptions) && validator.isLength(url, CONSTRAINTS_FIELDS.ACCOUNTS.URL)
|
||||
}
|
||||
|
||||
function isBaseActivityValid (activity: any, type: string) {
|
||||
|
|
|
@ -10,7 +10,8 @@ import {
|
|||
isVideoTruncatedDescriptionValid,
|
||||
isVideoDurationValid,
|
||||
isVideoNameValid,
|
||||
isVideoTagValid
|
||||
isVideoTagValid,
|
||||
isVideoUrlValid
|
||||
} from '../videos'
|
||||
import { isVideoChannelDescriptionValid, isVideoChannelNameValid } from '../video-channels'
|
||||
import { isBaseActivityValid } from './misc'
|
||||
|
@ -93,7 +94,7 @@ function isRemoteVideoContentValid (mediaType: string, content: string) {
|
|||
|
||||
function isRemoteVideoIconValid (icon: any) {
|
||||
return icon.type === 'Image' &&
|
||||
validator.isURL(icon.url) &&
|
||||
isVideoUrlValid(icon.url) &&
|
||||
icon.mediaType === 'image/jpeg' &&
|
||||
validator.isInt(icon.width, { min: 0 }) &&
|
||||
validator.isInt(icon.height, { min: 0 })
|
||||
|
@ -111,7 +112,7 @@ function setValidRemoteVideoUrls (video: any) {
|
|||
function isRemoteVideoUrlValid (url: any) {
|
||||
return url.type === 'Link' &&
|
||||
ACTIVITY_PUB.VIDEO_URL_MIME_TYPES.indexOf(url.mimeType) !== -1 &&
|
||||
validator.isURL(url.url) &&
|
||||
isVideoUrlValid(url.url) &&
|
||||
validator.isInt(url.width, { min: 0 }) &&
|
||||
validator.isInt(url.size, { min: 0 })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue