Skip to content

Commit d66cdab

Browse files
authored
Merge pull request #39 from anicholson/andy/fix-multipart-messages
fix: 🐛 multipart/mixed edge case with HTML & Attachment only
2 parents 0ad653f + dca3b70 commit d66cdab

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/GmailAPI.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,17 @@ async function saveMail(settings: ObsGMailSettings, id: string) {
254254
const parts: MessagePart[] = payload.parts ? payload.parts : [payload];
255255
flatten_parts(mailboxObject, parts);
256256
if (!mailboxObject.raw_mhtml && !mailboxObject.raw_mtxt) {
257-
let bodyText = "";
258257
const htmlAsset = mailboxObject.assets.find(
259258
(asset) =>
260259
asset.mimeType == "text/html" || asset.mimeType == "text/plain",
261260
);
262-
if (htmlAsset && htmlAsset.body?.data) {
263-
bodyText = htmlAsset.body.data;
261+
if (htmlAsset && htmlAsset.body) {
262+
mailboxObject.raw_mhtml = htmlAsset.body;
263+
mailboxObject.raw_mtxt = htmlAsset.body;
264264
} else {
265265
console.warn("no body found");
266266
}
267-
mailboxObject.mhtml = bodyText;
268-
mailboxObject.mtxt = bodyText;
267+
269268
}
270269
console.log("mailboxObject:");
271270
console.log(payload);

0 commit comments

Comments
 (0)