Allow disabling forwarder

This commit is contained in:
Louis Laureys 2020-05-08 01:23:53 +02:00
parent f438e68c42
commit d0576f4afe
5 changed files with 60 additions and 7 deletions

View file

@ -575,6 +575,13 @@ define({ "api": [
"field": "results.forwarded",
"description": "<p>If true then it is a forwarded address</p>"
},
{
"group": "Success 200",
"type": "Boolean",
"optional": false,
"field": "results.forwardedDisabled",
"description": "<p>If true then the forwarded address is disabled</p>"
},
{
"group": "Success 200",
"type": "String[]",
@ -787,8 +794,15 @@ define({ "api": [
"group": "Success 200",
"type": "String[]",
"optional": false,
"field": "results.tags",
"field": "tags",
"description": "<p>List of tags associated with the Address</p>"
},
{
"group": "Success 200",
"type": "Boolean",
"optional": false,
"field": "forwardedDisabled",
"description": "<p>If true then the forwarded address is disabled</p>"
}
]
},
@ -1493,6 +1507,13 @@ define({ "api": [
"field": "tags",
"description": "<p>A list of tags associated with this address</p>"
},
{
"group": "Parameter",
"type": "Boolean",
"optional": true,
"field": "forwardedDisabled",
"description": "<p>If true then disables forwarded address (stops forwarding messages)</p>"
},
{
"group": "Parameter",
"type": "Object",

View file

@ -575,6 +575,13 @@
"field": "results.forwarded",
"description": "<p>If true then it is a forwarded address</p>"
},
{
"group": "Success 200",
"type": "Boolean",
"optional": false,
"field": "results.forwardedDisabled",
"description": "<p>If true then the forwarded address is disabled</p>"
},
{
"group": "Success 200",
"type": "String[]",
@ -787,8 +794,15 @@
"group": "Success 200",
"type": "String[]",
"optional": false,
"field": "results.tags",
"field": "tags",
"description": "<p>List of tags associated with the Address</p>"
},
{
"group": "Success 200",
"type": "Boolean",
"optional": false,
"field": "forwardedDisabled",
"description": "<p>If true then the forwarded address is disabled</p>"
}
]
},
@ -1493,6 +1507,13 @@
"field": "tags",
"description": "<p>A list of tags associated with this address</p>"
},
{
"group": "Parameter",
"type": "Boolean",
"optional": true,
"field": "forwardedDisabled",
"description": "<p>If true then disables forwarded address (stops forwarding messages)</p>"
},
{
"group": "Parameter",
"type": "Object",

View file

@ -9,7 +9,7 @@ define({
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2020-05-08T07:54:54.784Z",
"time": "2020-05-08T12:34:11.199Z",
"url": "http://apidocjs.com",
"version": "0.22.1"
}

View file

@ -9,7 +9,7 @@
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2020-05-08T07:54:54.784Z",
"time": "2020-05-08T12:34:11.199Z",
"url": "http://apidocjs.com",
"version": "0.22.1"
}

View file

@ -40,6 +40,7 @@ module.exports = (db, server, userHandler) => {
* @apiSuccess {String} results.address E-mail address string
* @apiSuccess {String} results.user User ID this address belongs to if this is a User address
* @apiSuccess {Boolean} results.forwarded If true then it is a forwarded address
* @apiSuccess {Boolean} results.forwardedDisabled If true then the forwarded address is disabled
* @apiSuccess {String[]} [results.target] List of forwarding targets
*
* @apiError error Description of the error
@ -194,7 +195,8 @@ module.exports = (db, server, userHandler) => {
name: true,
user: true,
tags: true,
targets: true
targets: true,
forwardedDisabled: true
}
},
paginatedField: 'addrview',
@ -234,7 +236,8 @@ module.exports = (db, server, userHandler) => {
name: addressData.name || false,
address: addressData.address,
user: addressData.user,
forwarded: addressData.targets && true,
forwarded: !!addressData.targets,
forwardedDisabled: !!(addressData.targets && addressData.forwardedDisabled),
targets: addressData.targets && addressData.targets.map(t => t.value),
tags: addressData.tags || []
}))
@ -1604,6 +1607,7 @@ module.exports = (db, server, userHandler) => {
* @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") or an URL where mail contents are POSTed to. If set then overwrites previous targets array
* @apiParam {Number} [forwards] Daily allowed forwarding count for this address
* @apiParam {String[]} [tags] A list of tags associated with this address
* @apiParam {Boolean} [forwardedDisabled] If true then disables forwarded address (stops forwarding messages)
* @apiParam {Object} [autoreply] Autoreply information
* @apiParam {Boolean} [autoreply.status] If true, then autoreply is enabled for this address
* @apiParam {String} [autoreply.start] Either a date string or boolean false to disable start time checks
@ -1672,6 +1676,7 @@ module.exports = (db, server, userHandler) => {
.max(128 * 1024)
}),
tags: Joi.array().items(Joi.string().trim().max(128)),
forwardedDisabled: Joi.boolean().empty('').truthy(['Y', 'true', 'yes', 'on', '1', 1]).falsy(['N', 'false', 'no', 'off', '0', 0, '']),
sess: Joi.string().max(255),
ip: Joi.string().ip({
version: ['ipv4', 'ipv6'],
@ -1714,6 +1719,10 @@ module.exports = (db, server, userHandler) => {
updates.name = result.value.name;
}
if (result.value.forwardedDisabled !== undefined) {
updates.forwardedDisabled = result.value.forwardedDisabled;
}
if (result.value.autoreply) {
if (!result.value.autoreply.name && 'name' in req.params.autoreply) {
result.value.autoreply.name = '';
@ -2045,7 +2054,8 @@ module.exports = (db, server, userHandler) => {
* @apiSuccess {String} autoreply.text Autoreply plaintext content
* @apiSuccess {String} autoreply.html Autoreply HTML content
* @apiSuccess {String} created Datestring of the time the address was created
* @apiSuccess {String[]} results.tags List of tags associated with the Address
* @apiSuccess {String[]} tags List of tags associated with the Address
* @apiSuccess {Boolean} forwardedDisabled If true then the forwarded address is disabled
*
* @apiError error Description of the error
*
@ -2163,6 +2173,7 @@ module.exports = (db, server, userHandler) => {
},
autoreply: addressData.autoreply || { status: false },
tags: addressData.tags || [],
forwardedDisabled: addressData.targets && addressData.forwardedDisabled,
created: addressData.created
});