import { isBooleanValid } from '../../../helpers/custom-validators/misc'
import { doesLocalVideoChannelNameExist, doesVideoChannelNameWithHostExist } from '../../../helpers/middlewares'
import { MChannelAccountDefault, MUser } from '@server/typings/models'
+import { VIDEO_CHANNELS } from '@server/initializers/constants'
const videoChannelsAddValidator = [
body('name').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'),
return false
}
+ const count = await VideoChannelModel.countByAccount(res.locals.oauth.token.User.Account.id)
+ if (count > VIDEO_CHANNELS.MAX_PER_USER) {
+ res.status(400)
+ .send({ error: `You cannot create more than ${VIDEO_CHANNELS.MAX_PER_USER} channels` })
+ .end()
+ return false
+ }
+
return next()
}
]