diff --git a/lib/api/submit.js b/lib/api/submit.js index 47af61c9..8e35dd98 100644 --- a/lib/api/submit.js +++ b/lib/api/submit.js @@ -15,7 +15,7 @@ const Transform = require('stream').Transform; const { sessSchema, sessIPSchema, booleanSchema, metaDataSchema } = require('../schemas'); const { preprocessAttachments } = require('../data-url'); const { userId, mailboxId } = require('../schemas/request/general-schemas'); -const { AddressOptionalName, AddressOptionalNameArray, Header, Attachment, ReferenceWithAttachments } = require('../schemas/request/messages-schemas'); +const { AddressOptionalName, AddressOptionalNameArray, Header, ReferenceWithoutAttachments } = require('../schemas/request/messages-schemas'); const { successRes } = require('../schemas/response/general-schemas'); class StreamCollect extends Transform { @@ -631,7 +631,7 @@ module.exports = (db, server, messageHandler, userHandler, settingsHandler) => { description: 'Use this method to send emails from a user account', validationObjs: { requestBody: { - mailbox: mailboxId, + mailbox: Joi.string().hex().lowercase().length(24).description('ID of the Mailbox'), from: AddressOptionalName.description('Addres for the From: header'), replyTo: AddressOptionalName.description('Address for the Reply-To: header'), to: Joi.array() @@ -664,12 +664,27 @@ module.exports = (db, server, messageHandler, userHandler, settingsHandler) => { .empty('') .max(1024 * 1024) .description('HTML formatted message'), - attachments: Joi.array().items(Attachment).description('Attachments for the message'), + attachments: Joi.array() + .items( + Joi.object({ + filename: Joi.string().empty('').max(255).description('Attachment filename'), + contentType: Joi.string().empty('').max(255).description('MIME type for the attachment file'), + encoding: Joi.string().empty('').default('base64').description('Encoding to use to store the attachments'), + contentTransferEncoding: Joi.string().empty('').description('Transfer encoding'), + contentDisposition: Joi.string().empty('').trim().lowercase().valid('inline', 'attachment').description('Content Disposition'), + content: Joi.string().required().description('Base64 encoded attachment content'), + cid: Joi.string() + .empty('') + .max(255) + .description('Content-ID value if you want to reference to this attachment from HTML formatted message') + }) + ) + .description('Attachments for the message'), meta: metaDataSchema.label('metaData').description('Optional metadata, must be an object or JSON formatted string'), sess: sessSchema, ip: sessIPSchema, - reference: ReferenceWithAttachments.description( + reference: ReferenceWithoutAttachments.description( 'Optional referenced email. If uploaded message is a reply draft and relevant fields are not provided then these are resolved from the message to be replied to' ), // if true then treat this message as a draft