mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-03-04 03:45:19 +08:00
updated boolean check in api
This commit is contained in:
parent
5d2e011437
commit
768dd02da2
9 changed files with 109 additions and 59 deletions
|
@ -18,7 +18,8 @@ module.exports = (db, server, userHandler) => {
|
|||
.max(255)
|
||||
.required(),
|
||||
fresh: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
sess: Joi.string().max(255),
|
||||
ip: Joi.string().ip({
|
||||
|
|
|
@ -241,8 +241,12 @@ module.exports = (db, server) => {
|
|||
.required(),
|
||||
Joi.string().regex(/^\w+@\*$/, 'special address')
|
||||
],
|
||||
main: Joi.boolean().truthy(['Y', 'true', 'yes', 1]),
|
||||
allowWildcard: Joi.boolean().truthy(['Y', 'true', 'yes', 1])
|
||||
main: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
allowWildcard: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
});
|
||||
|
||||
const result = Joi.validate(req.params, schema, {
|
||||
|
@ -716,7 +720,8 @@ module.exports = (db, server) => {
|
|||
.length(24)
|
||||
.required(),
|
||||
main: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.required()
|
||||
});
|
||||
|
||||
|
@ -1058,10 +1063,13 @@ module.exports = (db, server) => {
|
|||
forwards: Joi.number()
|
||||
.min(0)
|
||||
.default(0),
|
||||
allowWildcard: Joi.boolean().truthy(['Y', 'true', 'yes', 1]),
|
||||
allowWildcard: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
autoreply: Joi.object().keys({
|
||||
status: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(true),
|
||||
start: Joi.date()
|
||||
.empty('')
|
||||
|
@ -1349,7 +1357,9 @@ module.exports = (db, server) => {
|
|||
.min(1),
|
||||
forwards: Joi.number().min(0),
|
||||
autoreply: Joi.object().keys({
|
||||
status: Joi.boolean().truthy(['Y', 'true', 'yes', 1]),
|
||||
status: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
start: Joi.date()
|
||||
.empty('')
|
||||
.allow(false),
|
||||
|
|
|
@ -224,7 +224,8 @@ module.exports = (db, server, userHandler) => {
|
|||
)
|
||||
.unique(),
|
||||
generateMobileconfig: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
expires: Joi.date(),
|
||||
sess: Joi.string().max(255),
|
||||
|
|
|
@ -58,7 +58,8 @@ module.exports = (db, server) => {
|
|||
.length(24)
|
||||
.required(),
|
||||
status: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
subject: Joi.string()
|
||||
.empty('')
|
||||
|
|
|
@ -503,21 +503,26 @@ module.exports = (db, server) => {
|
|||
.max(255)
|
||||
.empty(''),
|
||||
query_ha: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.empty(''),
|
||||
query_size: Joi.number().empty(''),
|
||||
|
||||
action_seen: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.empty(''),
|
||||
action_flag: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.empty(''),
|
||||
action_delete: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.empty(''),
|
||||
action_spam: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.empty(''),
|
||||
|
||||
action_mailbox: Joi.string()
|
||||
|
@ -784,21 +789,26 @@ module.exports = (db, server) => {
|
|||
.max(255)
|
||||
.empty(''),
|
||||
query_ha: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.empty(''),
|
||||
query_size: Joi.number().empty(''),
|
||||
|
||||
action_seen: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.empty(''),
|
||||
action_flag: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.empty(''),
|
||||
action_delete: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.empty(''),
|
||||
action_spam: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.empty(''),
|
||||
|
||||
action_mailbox: Joi.string()
|
||||
|
|
|
@ -79,7 +79,8 @@ module.exports = (db, server, mailboxHandler) => {
|
|||
.length(24)
|
||||
.required(),
|
||||
counters: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false)
|
||||
});
|
||||
|
||||
|
@ -531,7 +532,9 @@ module.exports = (db, server, mailboxHandler) => {
|
|||
.required(),
|
||||
path: Joi.string().regex(/\/{2,}|\/$/g, { invert: true }),
|
||||
retention: Joi.number().min(0),
|
||||
subscribed: Joi.boolean().truthy(['Y', 'true', 'yes', 1])
|
||||
subscribed: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
});
|
||||
|
||||
const result = Joi.validate(req.params, schema, {
|
||||
|
|
|
@ -408,10 +408,12 @@ module.exports = (db, server, messageHandler) => {
|
|||
.empty(''),
|
||||
attachments: Joi.boolean()
|
||||
.empty('')
|
||||
.truthy('true'),
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
flagged: Joi.boolean()
|
||||
.empty('')
|
||||
.truthy('true'),
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
limit: Joi.number()
|
||||
.default(20)
|
||||
.min(1)
|
||||
|
@ -834,10 +836,12 @@ module.exports = (db, server, messageHandler) => {
|
|||
.min(1)
|
||||
.required(),
|
||||
replaceCidLinks: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
markAsSeen: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false)
|
||||
});
|
||||
|
||||
|
@ -1566,14 +1570,23 @@ module.exports = (db, server, messageHandler) => {
|
|||
message: Joi.string()
|
||||
.regex(/^\d+(,\d+)*$|^\d+:\d+$|/i)
|
||||
.required(),
|
||||
seen: Joi.boolean().truthy(['Y', 'true', 'yes', 1]),
|
||||
deleted: Joi.boolean().truthy(['Y', 'true', 'yes', 1]),
|
||||
flagged: Joi.boolean().truthy(['Y', 'true', 'yes', 1]),
|
||||
draft: Joi.boolean().truthy(['Y', 'true', 'yes', 1]),
|
||||
seen: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
deleted: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
flagged: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
draft: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
expires: Joi.alternatives().try(
|
||||
Joi.date(),
|
||||
Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.allow(false)
|
||||
)
|
||||
});
|
||||
|
@ -1870,13 +1883,16 @@ module.exports = (db, server, messageHandler) => {
|
|||
.required(),
|
||||
date: Joi.date(),
|
||||
unseen: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
flagged: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
draft: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
raw: Joi.binary()
|
||||
.max(consts.MAX_ALLOWE_MESSAGE_SIZE)
|
||||
|
@ -2003,9 +2019,9 @@ module.exports = (db, server, messageHandler) => {
|
|||
success: status,
|
||||
message: data
|
||||
? {
|
||||
id: data.uid,
|
||||
mailbox: data.mailbox
|
||||
}
|
||||
id: data.uid,
|
||||
mailbox: data.mailbox
|
||||
}
|
||||
: false
|
||||
});
|
||||
return next();
|
||||
|
@ -2593,7 +2609,8 @@ module.exports = (db, server, messageHandler) => {
|
|||
.length(24)
|
||||
.required(),
|
||||
replaceCidLinks: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false)
|
||||
});
|
||||
|
||||
|
|
|
@ -597,7 +597,8 @@ module.exports = (db, server, messageHandler, userHandler) => {
|
|||
|
||||
uploadOnly: Joi.boolean()
|
||||
.empty('')
|
||||
.truthy('true')
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
|
||||
sendTime: Joi.date(),
|
||||
|
|
|
@ -144,21 +144,21 @@ module.exports = (db, server, userHandler) => {
|
|||
|
||||
let filter = query
|
||||
? {
|
||||
$or: [
|
||||
{
|
||||
address: {
|
||||
$regex: query.replace(/\./g, ''),
|
||||
$options: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
unameview: {
|
||||
$regex: query.replace(/\./g, ''),
|
||||
$options: ''
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
$or: [
|
||||
{
|
||||
address: {
|
||||
$regex: query.replace(/\./g, ''),
|
||||
$options: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
unameview: {
|
||||
$regex: query.replace(/\./g, ''),
|
||||
$options: ''
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
: {};
|
||||
|
||||
let tagSeen = new Set();
|
||||
|
@ -355,7 +355,8 @@ module.exports = (db, server, userHandler) => {
|
|||
|
||||
address: Joi.string().email(),
|
||||
emptyAddress: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
|
||||
language: Joi.string()
|
||||
|
@ -395,10 +396,12 @@ module.exports = (db, server, userHandler) => {
|
|||
.trim()
|
||||
.regex(/^-----BEGIN PGP PUBLIC KEY BLOCK-----/, 'PGP key format'),
|
||||
encryptMessages: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
encryptForwarded: Joi.boolean()
|
||||
.truthy(['Y', 'true', 'yes', 1])
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, ''])
|
||||
.default(false),
|
||||
sess: Joi.string().max(255),
|
||||
ip: Joi.string().ip({
|
||||
|
@ -880,10 +883,12 @@ module.exports = (db, server, userHandler) => {
|
|||
.regex(/^-----BEGIN PGP PUBLIC KEY BLOCK-----/, 'PGP key format'),
|
||||
encryptMessages: Joi.boolean()
|
||||
.empty('')
|
||||
.truthy(['Y', 'true', 'yes', 1]),
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
encryptForwarded: Joi.boolean()
|
||||
.empty('')
|
||||
.truthy(['Y', 'true', 'yes', 1]),
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
retention: Joi.number().min(0),
|
||||
quota: Joi.number().min(0),
|
||||
recipients: Joi.number().min(0),
|
||||
|
@ -901,7 +906,8 @@ module.exports = (db, server, userHandler) => {
|
|||
|
||||
disabled: Joi.boolean()
|
||||
.empty('')
|
||||
.truthy(['Y', 'true', 'yes', 1]),
|
||||
.truthy(['Y', 'true', 'yes', 'on', 1])
|
||||
.falsy(['N', 'false', 'no', 'off', 0, '']),
|
||||
sess: Joi.string().max(255),
|
||||
ip: Joi.string().ip({
|
||||
version: ['ipv4', 'ipv6'],
|
||||
|
|
Loading…
Reference in a new issue