mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Send follow/accept
This commit is contained in:
parent
7a7724e66e
commit
ce548a10db
9 changed files with 160 additions and 19 deletions
32
server/middlewares/validators/pods.ts
Normal file
32
server/middlewares/validators/pods.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import * as express from 'express'
|
||||
import { body } from 'express-validator/check'
|
||||
import { isEachUniqueHostValid } from '../../helpers/custom-validators/pods'
|
||||
import { isTestInstance } from '../../helpers/core-utils'
|
||||
import { CONFIG } from '../../initializers/constants'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { checkErrors } from './utils'
|
||||
|
||||
const followValidator = [
|
||||
body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
// Force https if the administrator wants to make friends
|
||||
if (isTestInstance() === false && CONFIG.WEBSERVER.SCHEME === 'http') {
|
||||
return res.status(400)
|
||||
.json({
|
||||
error: 'Cannot follow non HTTPS web server.'
|
||||
})
|
||||
.end()
|
||||
}
|
||||
|
||||
logger.debug('Checking follow parameters', { parameters: req.body })
|
||||
|
||||
checkErrors(req, res, next)
|
||||
}
|
||||
]
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
followValidator
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue