From 33287d57edf45b1f577986da4e88db5141c75115 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Tue, 9 Jan 2018 14:18:48 +0200 Subject: [PATCH] Allow empty targets --- lib/api/addresses.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/api/addresses.js b/lib/api/addresses.js index d3b4f7fc..ec87842f 100644 --- a/lib/api/addresses.js +++ b/lib/api/addresses.js @@ -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 true then address value can be in the form of *@example.com, 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) {