-
Notifications
You must be signed in to change notification settings - Fork 363
Add threaded replies, CC and BCC to Gmail send/draft functions #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c535455
bdb06a4
f8e859d
e061ed1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -83,6 +83,62 @@ def _extract_headers(payload: dict, header_names: List[str]) -> Dict[str, str]: | |||||||||
| return headers | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def _prepare_gmail_message( | ||||||||||
| subject: str, | ||||||||||
| body: str, | ||||||||||
| to: Optional[str] = None, | ||||||||||
| cc: Optional[str] = None, | ||||||||||
| bcc: Optional[str] = None, | ||||||||||
| thread_id: Optional[str] = None, | ||||||||||
| in_reply_to: Optional[str] = None, | ||||||||||
| references: Optional[str] = None, | ||||||||||
| ) -> tuple[str, Optional[str]]: | ||||||||||
| """ | ||||||||||
| Prepare a Gmail message with threading support. | ||||||||||
|
|
||||||||||
| Args: | ||||||||||
| subject: Email subject | ||||||||||
| body: Email body (plain text) | ||||||||||
| to: Optional recipient email address | ||||||||||
| cc: Optional CC email address | ||||||||||
| bcc: Optional BCC email address | ||||||||||
| thread_id: Optional Gmail thread ID to reply within | ||||||||||
| in_reply_to: Optional Message-ID of the message being replied to | ||||||||||
| references: Optional chain of Message-IDs for proper threading | ||||||||||
|
|
||||||||||
| Returns: | ||||||||||
| Tuple of (raw_message, thread_id) where raw_message is base64 encoded | ||||||||||
| """ | ||||||||||
| # Handle reply subject formatting | ||||||||||
| reply_subject = subject | ||||||||||
| if in_reply_to and not subject.lower().startswith('re:'): | ||||||||||
|
||||||||||
| if in_reply_to and not subject.lower().startswith('re:'): | |
| if in_reply_to and not re.match(r'^\s*re:\s*', subject, re.IGNORECASE): |
Copilot
AI
Aug 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable thread_id_final is always the same as the input thread_id parameter since _prepare_gmail_message returns it unchanged. This check should use thread_id directly instead of thread_id_final.
| if thread_id_final: | |
| send_body["threadId"] = thread_id_final | |
| if thread_id: | |
| send_body["threadId"] = thread_id |
Copilot
AI
Aug 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as in send_gmail_message - thread_id_final is always identical to the input thread_id. Use thread_id directly instead of thread_id_final.
| if thread_id_final: | |
| draft_body["message"]["threadId"] = thread_id_final | |
| if thread_id: | |
| draft_body["message"]["threadId"] = thread_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
Tuplefrom typing instead of the built-intuplefor better compatibility with older Python versions. ImportTuplefrom typing and change to-> Tuple[str, Optional[str]]: