mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-18 02:54:47 +08:00
v1.16.2
This commit is contained in:
parent
3d95b1355b
commit
e5919187a4
8 changed files with 44 additions and 15 deletions
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",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-03-26T12:34:49.315Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
});
|
||||
define({
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-03-26T14:41:36.494Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
{
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-03-26T12:34:49.315Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
}
|
||||
{
"name": "wildduck",
"version": "1.0.0",
"description": "WildDuck API docs",
"title": "WildDuck API",
"url": "https://api.wildduck.email",
"sampleUrl": false,
"defaultVersion": "0.0.0",
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2019-03-26T14:41:36.494Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
}
|
||||
|
|
|
@ -5,6 +5,7 @@ const MongoPaging = require('mongo-cursor-pagination');
|
|||
const ObjectID = require('mongodb').ObjectID;
|
||||
const tools = require('../tools');
|
||||
const roles = require('../roles');
|
||||
const consts = require('../consts');
|
||||
|
||||
module.exports = (db, server, storageHandler) => {
|
||||
/**
|
||||
|
@ -19,7 +20,7 @@ module.exports = (db, server, storageHandler) => {
|
|||
* }
|
||||
*
|
||||
* @apiParam {String} user ID of the User
|
||||
* @apiParam {String} content Base64 encoded file content
|
||||
* @apiParam {Binary} content Request body is the file itself. Make sure to use 'application/binary' as content-type for the request, otherwise the server might try to process the input
|
||||
* @apiParam {String} [filename] Filename
|
||||
* @apiParam {String} [contentType] MIME type for the file
|
||||
* @apiParam {String} [sess] Session identifier for the logs
|
||||
|
@ -30,13 +31,15 @@ module.exports = (db, server, storageHandler) => {
|
|||
*
|
||||
* @apiError error Description of the error
|
||||
*
|
||||
* @apiExample {curl} Upload a file:
|
||||
* curl -i -XPOST "http://localhost:8080/users/5a2f9ca57308fc3a6f5f811d/storage" \
|
||||
* -H 'Content-type: application/json' \
|
||||
* -d '{
|
||||
* "content": "aGVsbG93IGZyb20=",
|
||||
* "filename": "test.txt"
|
||||
* }'
|
||||
* @apiExample {curl} Upload a file from disk:
|
||||
* curl -i -XPOST "http://localhost:8080/users/5c404c9ec1933085b59e7574/storage?filename=00-example.duck.png" \
|
||||
* -H 'Content-type: application/binary' \
|
||||
* --data-binary "@emails/00-example.duck.png"
|
||||
*
|
||||
* @apiExample {curl} Upload a string:
|
||||
* curl -i -XPOST "http://localhost:8080/users/5c404c9ec1933085b59e7574/storage?filename=hello.txt" \
|
||||
* -H 'Content-type: application/binary' \
|
||||
* -d "Hello world!"
|
||||
*
|
||||
* @apiSuccessExample {json} Forward Response:
|
||||
* HTTP/1.1 200 OK
|
||||
|
@ -71,8 +74,11 @@ module.exports = (db, server, storageHandler) => {
|
|||
.max(255),
|
||||
encoding: Joi.string()
|
||||
.empty('')
|
||||
.default('base64'),
|
||||
content: Joi.string().required(),
|
||||
.valid('base64'),
|
||||
content: Joi.binary()
|
||||
.max(consts.MAX_ALLOWED_MESSAGE_SIZE)
|
||||
.empty('')
|
||||
.required(),
|
||||
|
||||
sess: Joi.string().max(255),
|
||||
ip: Joi.string().ip({
|
||||
|
@ -81,6 +87,16 @@ module.exports = (db, server, storageHandler) => {
|
|||
})
|
||||
});
|
||||
|
||||
Object.keys(req.query || {}).forEach(key => {
|
||||
if (!(key in req.params)) {
|
||||
req.params[key] = req.query[key];
|
||||
}
|
||||
});
|
||||
|
||||
if (!req.params.content && req.body && (Buffer.isBuffer(req.body) || typeof req.body === 'string')) {
|
||||
req.params.content = req.body;
|
||||
}
|
||||
|
||||
const result = Joi.validate(req.params, schema, {
|
||||
abortEarly: false,
|
||||
convert: true
|
||||
|
|
|
@ -66,6 +66,9 @@ module.exports = {
|
|||
// Refuse to process messages larger than 64 MB. Allowing larger messages might cause jumbo chunks in MongoDB
|
||||
MAX_ALLOWED_MESSAGE_SIZE: 64 * 1024 * 1024,
|
||||
|
||||
// Refuse to process attachments larger than 64 MB
|
||||
MAX_ALLOWED_ATACHMENT_SIZE: 25 * 1024 * 1024,
|
||||
|
||||
// how long to keep deleted messages around before purgeing
|
||||
ARCHIVE_TIME: 25 * 24 * 3600 * 1000,
|
||||
|
||||
|
|
|
@ -47,6 +47,16 @@ class StorageHandler {
|
|||
resolve(store.id);
|
||||
});
|
||||
|
||||
if (!options.encoding) {
|
||||
// content is not encoded, pass on as is
|
||||
try {
|
||||
store.end(options.content);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let decoder = new libbase64.Decoder();
|
||||
decoder.pipe(store);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "wildduck",
|
||||
"version": "1.16.1",
|
||||
"version": "1.16.2",
|
||||
"description": "IMAP/POP3 server built with Node.js and MongoDB",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Add table
Reference in a new issue