mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-09-20 23:36:15 +08:00
Updated API
This commit is contained in:
parent
54d4531cf9
commit
12a85ebdba
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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-11-29T11:59:34.485Z",
"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-11-30T10:17:30.414Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
});
|
||||
|
|
|
@ -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-11-29T11:59:34.485Z",
"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-11-30T10:17:30.414Z",
"url": "http://apidocjs.com",
"version": "0.17.6"
}
}
|
||||
|
|
|
@ -372,7 +372,7 @@ class Indexer {
|
|||
if (!isMultipart && node.body && node.body.length && (!isInlineText || node.size > 300 * 1024)) {
|
||||
let attachmentId = 'ATT' + leftPad(++idcount, '0', 5);
|
||||
|
||||
let fileName =
|
||||
let filename =
|
||||
(node.parsedHeader['content-disposition'] &&
|
||||
node.parsedHeader['content-disposition'].params &&
|
||||
node.parsedHeader['content-disposition'].params.filename) ||
|
||||
|
@ -384,19 +384,19 @@ class Indexer {
|
|||
.replace(/<|>/g, '')
|
||||
.trim();
|
||||
|
||||
if (fileName) {
|
||||
if (filename) {
|
||||
try {
|
||||
fileName = libmime.decodeWords(fileName).trim();
|
||||
filename = libmime.decodeWords(filename).trim();
|
||||
} catch (E) {
|
||||
// failed to parse filename, keep as is (most probably an unknown charset is used)
|
||||
}
|
||||
} else {
|
||||
fileName = crypto.randomBytes(4).toString('hex') + '.' + libmime.detectExtension(contentType);
|
||||
filename = crypto.randomBytes(4).toString('hex') + '.' + libmime.detectExtension(contentType);
|
||||
}
|
||||
|
||||
cidMap.set(contentId, {
|
||||
id: attachmentId,
|
||||
fileName
|
||||
filename
|
||||
});
|
||||
|
||||
// push to queue
|
||||
|
@ -414,7 +414,7 @@ class Indexer {
|
|||
// list in the attachments array
|
||||
maildata.attachments.push({
|
||||
id: attachmentId,
|
||||
fileName,
|
||||
filename,
|
||||
contentType,
|
||||
disposition,
|
||||
transferEncoding,
|
||||
|
|
1029
lib/api/messages.js
1029
lib/api/messages.js
File diff suppressed because it is too large
Load diff
|
@ -61,6 +61,7 @@ module.exports = (db, server, messageHandler) => {
|
|||
return callback(err);
|
||||
}
|
||||
|
||||
let overQuota = Number(userData.quota || config.maxStorage * 1024 * 1024) - userData.storageUsed <= 0;
|
||||
userData.recipients = userData.recipients || config.maxRecipients;
|
||||
|
||||
db.users
|
||||
|
@ -319,6 +320,16 @@ module.exports = (db, server, messageHandler) => {
|
|||
|
||||
let outbound = args[0].id;
|
||||
|
||||
if (overQuota) {
|
||||
log.info('API', 'STOREFAIL user=%s error=%s', user, 'Over quota');
|
||||
return callback(null, {
|
||||
id: false,
|
||||
mailbox: false,
|
||||
queueId: outbound,
|
||||
overQuota: true
|
||||
});
|
||||
}
|
||||
|
||||
// Checks if the message needs to be encrypted before storing it
|
||||
messageHandler.encryptMessage(
|
||||
userData.encryptMessages ? userData.pubKey : false,
|
||||
|
@ -448,7 +459,8 @@ module.exports = (db, server, messageHandler) => {
|
|||
* @apiError {String} code Reason for the error
|
||||
*
|
||||
* @apiExample {curl} Example usage:
|
||||
* curl -i -XPOST http://localhost:8080/users/59fc66a03e54454869460e45/submit \
|
||||
* # Sender info is derived from account settings
|
||||
* curl -i -XPOST "http://localhost:8080/users/59fc66a03e54454869460e45/submit" \
|
||||
* -H 'Content-type: application/json' \
|
||||
* -d '{
|
||||
* "to": [{
|
||||
|
@ -458,12 +470,25 @@ module.exports = (db, server, messageHandler) => {
|
|||
* "text": "Test message"
|
||||
* }'
|
||||
*
|
||||
* @apiExample {curl} Reply to All
|
||||
* # Recipients and subject line are derived from referenced message
|
||||
* curl -i -XPOST "http://localhost:8080/users/59fc66a03e54454869460e45/submit" \
|
||||
* -H 'Content-type: application/json' \
|
||||
* -d '{
|
||||
* "reference": {
|
||||
* "mailbox": "59fc66a03e54454869460e47",
|
||||
* "id": 15,
|
||||
* "action": "replyAll"
|
||||
* },
|
||||
* "text": "Yeah, sure"
|
||||
* }'
|
||||
*
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* HTTP/1.1 200 OK
|
||||
* {
|
||||
* "success": true,
|
||||
* "message": {
|
||||
* "id": 16,
|
||||
* "id": 16,
|
||||
* "mailbox": "59fc66a03e54454869460e47",
|
||||
* "queueId": "1600798505b000a25f"
|
||||
* }
|
||||
|
@ -472,7 +497,8 @@ module.exports = (db, server, messageHandler) => {
|
|||
* @apiErrorExample {json} Error-Response:
|
||||
* HTTP/1.1 200 OK
|
||||
* {
|
||||
* "error": "Mailbox update failed with code ALREADYEXISTS"
|
||||
* "error": "User account is disabled",
|
||||
* "code": "ERRDISABLEDUSER"
|
||||
* }
|
||||
*/
|
||||
server.post({ name: 'send', path: '/users/:user/submit' }, (req, res, next) => {
|
||||
|
|
Loading…
Reference in a new issue