Skip to content

Commit 5ce9989

Browse files
authored
fix: ZMS-210 API and docs fallback values updates (#802)
* in APIs remove fallbacks to false and fallback to undefined. Update documentation * update docs * Updae autoreply test. Don't account for undefined fields (not present in response)
1 parent f0f35e1 commit 5ce9989

8 files changed

Lines changed: 63 additions & 103 deletions

File tree

docs/api/openapidocs.json

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"contact": {
77
"url": "https://github.com/zone-eu/wildduck"
88
},
9-
"version": "1.45.4"
9+
"version": "1.45.5"
1010
},
1111
"servers": [
1212
{
@@ -278,6 +278,10 @@
278278
},
279279
"description": "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"
280280
},
281+
"mtaRelay": {
282+
"type": "string",
283+
"description": "An address of an SMTP MTA relay. The value should be a relay url. If specified uses the this relay as the outbound MTA."
284+
},
281285
"spamLevel": {
282286
"type": "number",
283287
"description": "Relative scale for detecting spam. 0 means that everything is spam, 100 means that nothing is spam",
@@ -592,6 +596,10 @@
592596
},
593597
"description": "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"
594598
},
599+
"mtaRelay": {
600+
"type": "string",
601+
"description": "An address of an SMTP MTA relay. The value should be a relay url. If specified uses the this relay as the outbound MTA."
602+
},
595603
"spamLevel": {
596604
"type": "number",
597605
"description": "Relative scale for detecting spam. 0 means that everything is spam, 100 means that nothing is spam"
@@ -9339,7 +9347,7 @@
93399347
},
93409348
"retention": {
93419349
"type": "number",
9342-
"description": "Default retention time (in ms). false if not enabled"
9350+
"description": "Default retention time (in ms). Not present if not enabled"
93439351
},
93449352
"enabled2fa": {
93459353
"type": "array",
@@ -9384,6 +9392,10 @@
93849392
},
93859393
"description": "List of forwarding targets"
93869394
},
9395+
"mtaRelay": {
9396+
"type": "string",
9397+
"description": "MTA Relay url"
9398+
},
93879399
"spamLevel": {
93889400
"type": "number",
93899401
"description": "Relative scale for detecting spam. 0 means that everything is spam, 100 means that nothing is spam"
@@ -9440,7 +9452,6 @@
94409452
"username",
94419453
"name",
94429454
"address",
9443-
"retention",
94449455
"enabled2fa",
94459456
"autoreply",
94469457
"encryptMessages",
@@ -9723,7 +9734,6 @@
97239734
},
97249735
"required": [
97259736
"id",
9726-
"name",
97279737
"address",
97289738
"user",
97299739
"forwarded",
@@ -9853,7 +9863,6 @@
98539863
},
98549864
"required": [
98559865
"id",
9856-
"name",
98579866
"address",
98589867
"main",
98599868
"created",
@@ -9931,7 +9940,6 @@
99319940
"required": [
99329941
"success",
99339942
"id",
9934-
"name",
99359943
"address",
99369944
"main",
99379945
"created",
@@ -10079,11 +10087,7 @@
1007910087
}
1008010088
},
1008110089
"required": [
10082-
"status",
10083-
"name",
10084-
"subject",
10085-
"text",
10086-
"html"
10090+
"status"
1008710091
]
1008810092
},
1008910093
"GetForwardedAddressResponse": {
@@ -10150,7 +10154,6 @@
1015010154
"success",
1015110155
"id",
1015210156
"address",
10153-
"name",
1015410157
"limits",
1015510158
"autoreply",
1015610159
"created",
@@ -11542,26 +11545,12 @@
1154211545
"description": "File ID"
1154311546
},
1154411547
"filename": {
11545-
"oneOf": [
11546-
{
11547-
"type": "string"
11548-
},
11549-
{
11550-
"type": "boolean"
11551-
}
11552-
],
11553-
"description": "Filename. False if none"
11548+
"type": "string",
11549+
"description": "Filename"
1155411550
},
1155511551
"contentType": {
11556-
"oneOf": [
11557-
{
11558-
"type": "string"
11559-
},
11560-
{
11561-
"type": "boolean"
11562-
}
11563-
],
11564-
"description": "Content-Type of the file. False if none"
11552+
"type": "string",
11553+
"description": "Content-Type of the file"
1156511554
},
1156611555
"cid": {
1156711556
"type": "string",
@@ -11583,8 +11572,6 @@
1158311572
},
1158411573
"required": [
1158511574
"id",
11586-
"filename",
11587-
"contentType",
1158811575
"size",
1158911576
"created",
1159011577
"md5"
@@ -12136,18 +12123,14 @@
1213612123
"properties": {
1213712124
"time": {
1213812125
"type": "string",
12139-
"description": "Datestring of last use or false if password has not been used",
12126+
"description": "Datestring of last use or not present if password has not been used",
1214012127
"format": "date-time"
1214112128
},
1214212129
"event": {
1214312130
"type": "string",
1214412131
"description": "Event ID of the security log for the last authentication"
1214512132
}
12146-
},
12147-
"required": [
12148-
"time",
12149-
"event"
12150-
]
12133+
}
1215112134
},
1215212135
"GetASPsResult": {
1215312136
"type": "object",
@@ -12978,18 +12961,12 @@
1297812961
"start": {
1297912962
"type": "string",
1298012963
"description": "Datestring of the start of the autoreply or boolean false to disable start checks",
12981-
"format": "date-time",
12982-
"enum": [
12983-
false
12984-
]
12964+
"format": "date-time"
1298512965
},
1298612966
"end": {
1298712967
"type": "string",
1298812968
"description": "Datestring of the end of the autoreply or boolean false to disable end checks",
12989-
"format": "date-time",
12990-
"enum": [
12991-
false
12992-
]
12969+
"format": "date-time"
1299312970
},
1299412971
"created": {
1299512972
"type": "string",
@@ -12998,8 +12975,7 @@
1299812975
}
1299912976
},
1300012977
"required": [
13001-
"success",
13002-
"created"
12978+
"success"
1300312979
]
1300412980
},
1300512981
"Reference": {

lib/api/addresses.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ module.exports = (db, server, userHandler, settingsHandler) => {
245245
results: (listing.results || []).map(addressData => {
246246
let values = {
247247
id: addressData._id.toString(),
248-
name: addressData.name || false,
248+
name: addressData.name || undefined,
249249
address: addressData.address,
250250
user: addressData.user && addressData.user.toString(),
251251
forwarded: !!addressData.targets,
@@ -704,7 +704,7 @@ module.exports = (db, server, userHandler, settingsHandler) => {
704704
results: addresses.map(addressData => {
705705
let values = {
706706
id: addressData._id.toString(),
707-
name: addressData.name || false,
707+
name: addressData.name || undefined,
708708
address: addressData.address,
709709
main: addressData.address === userData.address,
710710
tags: addressData.tags || [],
@@ -747,7 +747,7 @@ module.exports = (db, server, userHandler, settingsHandler) => {
747747
model: Joi.object({
748748
success: successRes,
749749
id: addressId,
750-
name: Joi.string().required().description('Identity name'),
750+
name: Joi.string().description('Identity name'),
751751
address: addressEmail,
752752
main: booleanSchema.required().description('Indicates if this is the default address for the User'),
753753
created: Joi.date().required().description('Datestring of the time the address was created'),
@@ -850,7 +850,7 @@ module.exports = (db, server, userHandler, settingsHandler) => {
850850
let value = {
851851
success: true,
852852
id: addressData._id.toString(),
853-
name: addressData.name || false,
853+
name: addressData.name || undefined,
854854
address: addressData.address,
855855
main: addressData.address === userData.address,
856856
tags: addressData.tags || [],
@@ -1428,7 +1428,7 @@ module.exports = (db, server, userHandler, settingsHandler) => {
14281428
success: true,
14291429

14301430
results: addresses.map(addressData => {
1431-
let name = addressData.name || false;
1431+
let name = addressData.name || undefined;
14321432
try {
14331433
// try to decode
14341434
if (name) {
@@ -1439,7 +1439,7 @@ module.exports = (db, server, userHandler, settingsHandler) => {
14391439
}
14401440
return {
14411441
id: addressData._id.toString(),
1442-
name: addressData.name || false,
1442+
name: addressData.name || undefined,
14431443
address: addressData.address
14441444
};
14451445
})
@@ -2167,7 +2167,7 @@ module.exports = (db, server, userHandler, settingsHandler) => {
21672167
success: successRes,
21682168
id: addressId,
21692169
address: addressEmail,
2170-
name: Joi.string().required().description('Identity name'),
2170+
name: Joi.string().description('Identity name'),
21712171
targets: Joi.array().items(Joi.string()).description('List of forwarding targets'),
21722172
limits: AddressLimits,
21732173
autoreply: AutoreplyInfo,
@@ -2254,7 +2254,7 @@ module.exports = (db, server, userHandler, settingsHandler) => {
22542254
const values = {
22552255
success: true,
22562256
id: addressData._id.toString(),
2257-
name: addressData.name || false,
2257+
name: addressData.name || undefined,
22582258
address: addressData.address,
22592259
targets: addressData.targets && addressData.targets.map(t => t.value),
22602260
limits: {

lib/api/asps.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ module.exports = (db, server, userHandler) => {
5050
.required()
5151
.description('Allowed scopes for the Application Password'),
5252
lastUse: Joi.object({
53-
time: Joi.date().required().description('Datestring of last use or false if password has not been used'),
54-
event: Joi.string().required().description('Event ID of the security log for the last authentication')
53+
time: Joi.date().description('Datestring of last use or not present if password has not been used'),
54+
event: Joi.string().description('Event ID of the security log for the last authentication')
5555
})
5656
.required()
5757
.$_setFlag('objectName', 'LastUse')
@@ -170,8 +170,8 @@ module.exports = (db, server, userHandler) => {
170170
description: asp.description,
171171
scopes: asp.scopes.includes('*') ? [...consts.SCOPES] : asp.scopes,
172172
lastUse: {
173-
time: asp.used || false,
174-
event: asp.authEvent || false
173+
time: asp.used || undefined,
174+
event: asp.authEvent || undefined
175175
},
176176
expires: asp.expires,
177177
created: asp.created
@@ -209,8 +209,8 @@ module.exports = (db, server, userHandler) => {
209209
.required()
210210
.description('Allowed scopes for the Application Password'),
211211
lastUse: Joi.object({
212-
time: Joi.date().required().description('Datestring of last use or false if password has not been used'),
213-
event: Joi.string().required().description('Event ID of the security log for the last authentication')
212+
time: Joi.date().description('Datestring of last use or not present if password has not been used'),
213+
event: Joi.string().description('Event ID of the security log for the last authentication')
214214
})
215215
.required()
216216
.$_setFlag('objectName', 'LastUse')
@@ -286,8 +286,8 @@ module.exports = (db, server, userHandler) => {
286286
description: aspData.description,
287287
scopes: aspData.scopes.includes('*') ? [...consts.SCOPES] : aspData.scopes,
288288
lastUse: {
289-
time: aspData.used || false,
290-
event: aspData.authEvent || false
289+
time: aspData.used || undefined,
290+
event: aspData.authEvent || undefined
291291
},
292292
expires: asp.expires,
293293
created: aspData.created

lib/api/autoreply.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,9 @@ module.exports = (db, server) => {
181181
.trim()
182182
.max(128 * 1024)
183183
.description('HTML formatted content of the autoreply message'),
184-
start: Joi.date()
185-
.empty('')
186-
.allow(false)
187-
.description('Datestring of the start of the autoreply or boolean false to disable start checks'),
188-
end: Joi.date().empty('').allow(false).description('Datestring of the end of the autoreply or boolean false to disable end checks'),
189-
created: Joi.date().required().description('Datestring of when the Autoreply was created')
184+
start: Joi.date().empty('').description('Datestring of the start of the autoreply or boolean false to disable start checks'),
185+
end: Joi.date().empty('').description('Datestring of the end of the autoreply or boolean false to disable end checks'),
186+
created: Joi.date().description('Datestring of when the Autoreply was created')
190187
}).$_setFlag('objectName', 'GetAutoreplyResponse')
191188
}
192189
}
@@ -236,9 +233,9 @@ module.exports = (db, server) => {
236233
subject: entry.subject || '',
237234
text: entry.text || '',
238235
html: entry.html || '',
239-
start: entry.start || false,
240-
end: entry.end || false,
241-
created: entry.created || entry._id?.getTimestamp() || false
236+
start: entry.start || undefined,
237+
end: entry.end || undefined,
238+
created: entry.created || entry._id?.getTimestamp() || undefined
242239
});
243240
})
244241
);

lib/api/storage.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const ObjectId = require('mongodb').ObjectId;
66
const tools = require('../tools');
77
const roles = require('../roles');
88
const consts = require('../consts');
9-
const { nextPageCursorSchema, previousPageCursorSchema, pageNrSchema, sessSchema, sessIPSchema, booleanSchema } = require('../schemas');
9+
const { nextPageCursorSchema, previousPageCursorSchema, pageNrSchema, sessSchema, sessIPSchema } = require('../schemas');
1010
const { userId } = require('../schemas/request/general-schemas');
1111
const { successRes, totalRes, pageRes, previousCursorRes, nextCursorRes } = require('../schemas/response/general-schemas');
1212

@@ -157,14 +157,8 @@ module.exports = (db, server, storageHandler) => {
157157
.items(
158158
Joi.object({
159159
id: Joi.string().required().description('File ID'),
160-
filename: Joi.alternatives()
161-
.try(Joi.string().required(), booleanSchema.required())
162-
.required()
163-
.description('Filename. False if none'),
164-
contentType: Joi.alternatives()
165-
.try(Joi.string().required(), booleanSchema.required())
166-
.required()
167-
.description('Content-Type of the file. False if none'),
160+
filename: Joi.string().description('Filename'),
161+
contentType: Joi.string().description('Content-Type of the file'),
168162
cid: Joi.string().description('Content ID'),
169163
size: Joi.number().required().description('File size'),
170164
created: Joi.date().required().description('Created datestring'),
@@ -297,8 +291,8 @@ module.exports = (db, server, storageHandler) => {
297291
nextCursor: listing.hasNext ? listing.next : false,
298292
results: (listing.results || []).map(fileData => ({
299293
id: fileData._id.toString(),
300-
filename: fileData.filename || false,
301-
contentType: fileData.contentType || false,
294+
filename: fileData.filename || undefined,
295+
contentType: fileData.contentType || undefined,
302296
cid: fileData.metadata?.cid,
303297
size: fileData.length,
304298
created: fileData.uploadDate.toISOString(),

0 commit comments

Comments
 (0)