Allow empty targets

This commit is contained in:
Andris Reinman 2018-01-09 14:18:48 +02:00
parent 58b6bf2999
commit 33287d57ed

View file

@ -998,7 +998,7 @@ module.exports = (db, server) => {
* }
*
* @apiParam {String} address E-mail Address
* @apiParam {String[]} targets An array of forwarding targets. The value could either be an email address or a relay url to next MX server ("smtp://mx2.zone.eu:25")
* @apiParam {String[]} [targets] An array of forwarding targets. The value could either be an email address or a relay url to next MX server ("smtp://mx2.zone.eu:25")
* @apiParam {Number} [forwards] Daily allowed forwarding count for this address
* @apiParam {Boolean} [allowWildcard=false] If <code>true</code> then address value can be in the form of <code>*@example.com</code>, otherwise using * is not allowed
* @apiParam {Object} [autoreply] Autoreply information
@ -1049,14 +1049,12 @@ module.exports = (db, server) => {
.required(),
Joi.string().regex(/^\w+@\*$/, 'special address')
],
targets: Joi.array()
.items(
Joi.string().email(),
Joi.string().uri({
scheme: [/smtps?/, /https?/]
})
)
.min(1),
targets: Joi.array().items(
Joi.string().email(),
Joi.string().uri({
scheme: [/smtps?/, /https?/]
})
),
forwards: Joi.number()
.min(0)
.default(0),
@ -1102,7 +1100,7 @@ module.exports = (db, server) => {
let address = tools.normalizeAddress(result.value.address);
let addrview = address.substr(0, address.indexOf('@')).replace(/\./g, '') + address.substr(address.indexOf('@'));
let targets = result.value.targets;
let targets = result.value.targets || [];
let forwards = result.value.forwards;
if (result.value.autoreply) {