Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/email-client/gmail-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2269,7 +2269,7 @@ class GmailClient extends BaseClient {
* @param {Object} node - MIME part node
* @param {boolean} isRelated - Whether part is inside multipart/related
*/
let walk = (node, isRelated) => {
let walk = (node, isRelated, isEnclosed) => {
if (node.mimeType === 'multipart/related') {
isRelated = true;
}
Expand Down Expand Up @@ -2309,7 +2309,8 @@ class GmailClient extends BaseClient {
encodedSize: node.body.size,

embedded: isRelated,
inline: disposition?.value === 'inline' || (!disposition && isRelated)
inline: disposition?.value === 'inline' || (!disposition && isRelated),
encodedInMessage: isEnclosed || false
};

if (node.filename) {
Expand Down Expand Up @@ -2360,11 +2361,12 @@ class GmailClient extends BaseClient {

// Process child parts
if (node.parts) {
node.parts.forEach(childNode => walk(childNode, isRelated));
let enclosed = isEnclosed || node.mimeType === 'message/rfc822';
node.parts.forEach(childNode => walk(childNode, isRelated, enclosed));
}
};

walk(messageData.payload, false);
walk(messageData.payload, false, false);

// Concatenate text parts
for (let i = 0; i < textContents.length; i++) {
Expand Down
10 changes: 6 additions & 4 deletions lib/email-client/imap/mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,7 @@ class Mailbox {
let encodedTextSize = {};

// Recursively walk body structure tree
let walk = (node, isRelated) => {
let walk = (node, isRelated, isEnclosed) => {
if (node.type === 'multipart/related') {
isRelated = true;
}
Expand All @@ -1810,7 +1810,8 @@ class Mailbox {
encodedSize: node.size,

embedded: isRelated,
inline: node.disposition === 'inline' || (!node.disposition && isRelated)
inline: node.disposition === 'inline' || (!node.disposition && isRelated),
encodedInMessage: isEnclosed || false
};

// Extract filename from disposition or content-type parameters
Expand Down Expand Up @@ -1854,11 +1855,12 @@ class Mailbox {

// Recursively process multipart children
if (node.childNodes) {
node.childNodes.forEach(childNode => walk(childNode, isRelated));
let enclosed = isEnclosed || node.type === 'message/rfc822';
node.childNodes.forEach(childNode => walk(childNode, isRelated, enclosed));
}
};

walk(bodyStructure, false);
walk(bodyStructure, false, false);

return {
attachments,
Expand Down
3 changes: 3 additions & 0 deletions lib/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,9 @@ const attachmentSchema = Joi.object({
.label('AttachmentEncodedSize'),
embedded: Joi.boolean().example(true).description('Whether the attachment is embedded in the HTML content'),
inline: Joi.boolean().example(true).description('Whether the attachment should be displayed inline rather than as a download'),
encodedInMessage: Joi.boolean()
.example(false)
.description('Whether the attachment is part of an enclosed message/rfc822 attachment rather than the message itself'),
contentId: Joi.string().example('<unique-image-id@localhost>').description('Content-ID header value used for embedding images in HTML'),
filename: Joi.string().example('image.png').description('Original filename of the attachment'),
method: Joi.string().example('REQUEST').description('Calendar method (REQUEST, REPLY, CANCEL, etc.) for iCalendar attachments')
Expand Down
Loading