fix(backend): clean up parsing a bit for gmail read (#10555)

<!-- Clearly explain the need for these changes: -->
Toran hit an error on reading a snippet incorrectly

### Changes 🏗️
Does fallback getting from dictionary when building email objects
<!-- Concisely describe all of the changes made in this pull request:
-->

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [ ] I have tested my changes according to the test plan:
  <!-- Put your test plan here: -->
  - [ ] Deploy to dev and have Toran test against his inbox

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Nicholas Tindle
2025-08-05 13:30:34 -05:00
committed by GitHub
parent 5a5f7f0f9e
commit cc6697e46d

View File

@@ -310,18 +310,18 @@ class GmailReadBlock(Block):
]
email = Email(
threadId=msg["threadId"],
threadId=msg.get("threadId", None),
labelIds=msg.get("labelIds", []),
id=msg["id"],
subject=headers.get("subject", "No Subject"),
snippet=msg["snippet"],
snippet=msg.get("snippet", ""),
from_=parseaddr(headers.get("from", ""))[1],
to=to_recipients if to_recipients else [],
cc=cc_recipients,
bcc=bcc_recipients,
date=headers.get("date", ""),
body=await self._get_email_body(msg, service),
sizeEstimate=msg["sizeEstimate"],
sizeEstimate=msg.get("sizeEstimate", 0),
attachments=attachments,
)
email_data.append(email)
@@ -985,7 +985,7 @@ class GmailGetThreadBlock(Block):
email = Email(
threadId=msg.get("threadId", thread_id),
labelIds=msg.get("labelIds", []),
id=msg["id"],
id=msg.get("id"),
subject=headers.get("subject", "No Subject"),
snippet=msg.get("snippet", ""),
from_=parseaddr(headers.get("from", ""))[1],