Updated address resolving

This commit is contained in:
Andris Reinman 2017-12-01 15:21:44 +02:00
parent 55d7b87915
commit 5b89511c35
7 changed files with 23 additions and 18 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
define({ "name": "wildduck", "version": "1.0.0", "description": "WildDuck API docs. Under construction, see old docs here: https://github.com/nodemailer/wildduck/blob/master/docs/api.md", "title": "WildDuck API", "url": "http://localhost:8080", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", "time": "2017-12-01T13:04:16.194Z", "url": "http://apidocjs.com", "version": "0.17.6" } }); define({ "name": "wildduck", "version": "1.0.0", "description": "WildDuck API docs. Under construction, see old docs here: https://github.com/nodemailer/wildduck/blob/master/docs/api.md", "title": "WildDuck API", "url": "http://localhost:8080", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", "time": "2017-12-01T13:21:34.058Z", "url": "http://apidocjs.com", "version": "0.17.6" } });

View file

@ -1 +1 @@
{ "name": "wildduck", "version": "1.0.0", "description": "WildDuck API docs. Under construction, see old docs here: https://github.com/nodemailer/wildduck/blob/master/docs/api.md", "title": "WildDuck API", "url": "http://localhost:8080", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", "time": "2017-12-01T13:04:16.194Z", "url": "http://apidocjs.com", "version": "0.17.6" } } { "name": "wildduck", "version": "1.0.0", "description": "WildDuck API docs. Under construction, see old docs here: https://github.com/nodemailer/wildduck/blob/master/docs/api.md", "title": "WildDuck API", "url": "http://localhost:8080", "sampleUrl": false, "defaultVersion": "0.0.0", "apidoc": "0.3.0", "generator": { "name": "apidoc", "time": "2017-12-01T13:21:34.058Z", "url": "http://apidocjs.com", "version": "0.17.6" } }

View file

@ -223,9 +223,12 @@ module.exports = (db, server) => {
.lowercase() .lowercase()
.length(24) .length(24)
.required(), .required(),
address: Joi.string() address: [
.email() Joi.string()
.required(), .email()
.required(),
Joi.string().regex(/^\w+@\*$/, 'special address')
],
main: Joi.boolean().truthy(['Y', 'true', 'yes', 1]), main: Joi.boolean().truthy(['Y', 'true', 'yes', 1]),
allowWildcard: Joi.boolean().truthy(['Y', 'true', 'yes', 1]) allowWildcard: Joi.boolean().truthy(['Y', 'true', 'yes', 1])
}); });

View file

@ -9,7 +9,7 @@ module.exports = (db, server) => {
/** /**
* @api {get} /addresses List registered Domain Aliases * @api {get} /addresses List registered Domain Aliases
* @apiName GetAliases * @apiName GetAliases
* @apiGroup Domain Aliases * @apiGroup DomainAliases
* @apiHeader {String} X-Access-Token Optional access token if authentication is enabled * @apiHeader {String} X-Access-Token Optional access token if authentication is enabled
* @apiHeaderExample {json} Header-Example: * @apiHeaderExample {json} Header-Example:
* { * {
@ -183,8 +183,8 @@ module.exports = (db, server) => {
/** /**
* @api {post} /domainaliases/addresses Create new Domain Alias * @api {post} /domainaliases/addresses Create new Domain Alias
* @apiName PostDomainAlias * @apiName PostDomainAlias
* @apiGroup Domain Aliases * @apiGroup DomainAliases
* @apiDescription Add a new Alias for a Domain * @apiDescription Add a new Alias for a Domain. This allows to accept mail on username@domain and username@alias
* @apiHeader {String} X-Access-Token Optional access token if authentication is enabled * @apiHeader {String} X-Access-Token Optional access token if authentication is enabled
* @apiHeaderExample {json} Header-Example: * @apiHeaderExample {json} Header-Example:
* { * {
@ -225,10 +225,12 @@ module.exports = (db, server) => {
const schema = Joi.object().keys({ const schema = Joi.object().keys({
alias: Joi.string() alias: Joi.string()
.hostname() .max(255)
//.hostname()
.required(), .required(),
domain: Joi.string() domain: Joi.string()
.hostname() .max(255)
//.hostname()
.required() .required()
}); });
@ -296,7 +298,7 @@ module.exports = (db, server) => {
/** /**
* @api {get} /domainaliases/:alias Request Alias information * @api {get} /domainaliases/:alias Request Alias information
* @apiName GetDomainAlias * @apiName GetDomainAlias
* @apiGroup Domain Aliases * @apiGroup DomainAliases
* @apiHeader {String} X-Access-Token Optional access token if authentication is enabled * @apiHeader {String} X-Access-Token Optional access token if authentication is enabled
* @apiHeaderExample {json} Header-Example: * @apiHeaderExample {json} Header-Example:
* { * {
@ -392,7 +394,7 @@ module.exports = (db, server) => {
/** /**
* @api {delete} /domainaliases/:alias Delete an Alias * @api {delete} /domainaliases/:alias Delete an Alias
* @apiName DeleteDomainAlias * @apiName DeleteDomainAlias
* @apiGroup Domain Aliases * @apiGroup DomainAliases
* @apiHeader {String} X-Access-Token Optional access token if authentication is enabled * @apiHeader {String} X-Access-Token Optional access token if authentication is enabled
* @apiHeaderExample {json} Header-Example: * @apiHeaderExample {json} Header-Example:
* { * {

View file

@ -87,7 +87,7 @@ class UserHandler {
// try an alias // try an alias
let checkAliases = done => { let checkAliases = done => {
this.users.collection('domainalias').findOne({ alias: address.substr(address.indexOf('@') + 1) }, (err, aliasData) => { this.users.collection('domainaliases').findOne({ alias: address.substr(address.indexOf('@') + 1) }, (err, aliasData) => {
if (err) { if (err) {
return done(err); return done(err);
} }
@ -134,12 +134,12 @@ class UserHandler {
} }
if (addressData) { if (addressData) {
next(null, { _id: addressData.user }); return next(null, { _id: addressData.user });
} }
// try to find a catch-all user // try to find a catch-all user
this.users.collection('addresses').findOne( this.users.collection('addresses').findOne(
{ {
addrview: address.substr(0, address.indexOf('@')).replace(/\./g, '') + +'@*' addrview: address.substr(0, address.indexOf('@')).replace(/\./g, '') + '@*'
}, },
{ {
fields: { fields: {
@ -155,7 +155,7 @@ class UserHandler {
return callback(null, false); return callback(null, false);
} }
next(null, { _id: addressData.user }); return next(null, { _id: addressData.user });
} }
); );
} }