-
Notifications
You must be signed in to change notification settings - Fork 360
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
Conversation
- Add thread_id, in_reply_to, and references parameters for proper reply threading - Auto-format reply subjects with 'Re:' prefix when replying - Include proper email headers for threading (In-Reply-To, References) - Add examples for both new drafts and reply drafts in docstring
- Add thread_id, in_reply_to, and references parameters for proper reply threading - Auto-format reply subjects with 'Re:' prefix when replying - Include proper email headers for threading (In-Reply-To, References) - Add examples for both new emails and reply emails in docstring - Achieve feature parity between send_gmail_message and draft_gmail_message
|
This looks very good, thank you! Will try to get it out it after work wraps up for the day today. |
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.
Pull Request Overview
This PR enhances Gmail functionality by adding comprehensive email threading support and multi-recipient capabilities. The changes enable proper email reply threading with In-Reply-To and References headers, while also supporting CC and BCC recipients for both sending and drafting operations.
Key changes:
- Added email threading parameters (thread_id, in_reply_to, references) to enable proper reply functionality
- Added CC and BCC support for multi-recipient emails
- Refactored shared email preparation logic into a reusable
_prepare_gmail_messagefunction
| thread_id: Optional[str] = None, | ||
| in_reply_to: Optional[str] = None, | ||
| references: Optional[str] = None, | ||
| ) -> tuple[str, Optional[str]]: |
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.
Use Tuple from typing instead of the built-in tuple for better compatibility with older Python versions. Import Tuple from typing and change to -> Tuple[str, Optional[str]]:
| ) -> tuple[str, Optional[str]]: | |
| ) -> Tuple[str, Optional[str]]: |
| """ | ||
| # Handle reply subject formatting | ||
| reply_subject = subject | ||
| if in_reply_to and not subject.lower().startswith('re:'): |
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 condition checks for 'Re:' prefix but should handle variations like 'RE:', 'Re:', 'rE:', etc. Consider using a case-insensitive regex or normalizing the check: if in_reply_to and not re.match(r'^re:\s*', subject, re.IGNORECASE):
| 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): |
| if thread_id_final: | ||
| send_body["threadId"] = thread_id_final |
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 |
| if thread_id_final: | ||
| draft_body["message"]["threadId"] = thread_id_final |
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 |
|
Works perfectly with no changes, the copilot suggestions are worthless. Good stuff, thanks @benjaminjackson! |
Enhanced Gmail functionality with comprehensive email threading support and multi-recipient capabilities:
• Email Threading: Added support for threaded replies with proper In-Reply-To and References headers
• Multi-recipient Support: Added CC and BCC functionality to both send and draft operations
• Code Consolidation: Refactored shared email preparation logic to eliminate duplication
Technical Changes
New Features:
Note: this duplicates WIP in PR #71 but is more atomic, with no changes to Forms Functionality.