Skip to content

Commit

Permalink
fix(ms-graph-api): Fixed plaintext content handling when retrieving e…
Browse files Browse the repository at this point in the history
…mails from MS Graph API
  • Loading branch information
andris9 committed Jan 9, 2025
1 parent 5d88539 commit 0166a0a
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions lib/email-client/outlook-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,19 @@ class OutlookClient extends BaseClient {

if (messageData?.body?.contentType) {
let textContent = messageData.body.content || '';
if ([messageData?.body?.contentType, '*'].includes(options.textType)) {
response[messageData.body.contentType] = textContent;
let textContentType;
switch (messageData.body.contentType) {
case 'text':
textContentType = 'plain';
break;

case 'html':
default:
textContentType = messageData.body.contentType;
break;
}
if ([textContentType, '*'].includes(options.textType)) {
response[textContentType] = textContent;
}
}

Expand Down Expand Up @@ -2265,9 +2276,20 @@ class OutlookClient extends BaseClient {

if (messageData?.body?.contentType) {
let textContent = messageData.body.content || '';
encodedTextSize[messageData.body.contentType] = Buffer.byteLength(textContent);
if ([messageData?.body?.contentType, '*'].includes(textType)) {
textContents[messageData.body.contentType] = textContent;
let textContentType;
switch (messageData.body.contentType) {
case 'text':
textContentType = 'plain';
break;

case 'html':
default:
textContentType = messageData.body.contentType;
break;
}
encodedTextSize[textContentType] = Buffer.byteLength(textContent);
if ([textContentType, '*'].includes(textType)) {
textContents[textContentType] = textContent;
}
}

Expand Down

0 comments on commit 0166a0a

Please sign in to comment.