+ const body: UserRegister = req.body
+ if (body.channel) {
+ if (!body.channel.name || !body.channel.displayName) {
+ return res.status(400)
+ .send({ error: 'Channel is optional but if you specify it, channel.name and channel.displayName are required.' })
+ .end()
+ }
+
+ if (body.channel.name === body.username) {
+ return res.status(400)
+ .send({ error: 'Channel name cannot be the same than user username.' })
+ .end()
+ }
+
+ const existing = await ActorModel.loadLocalByName(body.channel.name)
+ if (existing) {
+ return res.status(409)
+ .send({ error: `Channel with name ${body.channel.name} already exists.` })
+ .end()
+ }
+ }
+