-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Gmail - parse name & email in parsedHeaders #14111
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
WalkthroughThis pull request primarily updates the version numbers for several components within the Gmail package, including Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
components/gmail/sources/common/base.mjs (2)
47-65
: LGTM! Consider adding input type validation.The
parseEmail
method effectively parses email strings in the "FULLNAME " format, aligning with the PR objectives. It handles various input scenarios well, including cases where the input doesn't match the expected format.Consider adding a type check for the input to ensure it's a string:
parseEmail(emailStr) { + if (typeof emailStr !== 'string') { + return undefined; + } if (!emailStr) { return undefined; } // ... rest of the method }This addition would make the method more robust against potential misuse.
75-79
: LGTM! Consider consistent handling of multiple recipients.The refactoring of the
processEmail
method effectively implements the parsing of name and email for the "from", "to", and "reply-to" headers. The use ofgetHeaderValue
andparseEmail
methods improves code readability and maintainability.For consistency and to handle multiple recipients in the "to" field, consider modifying the "to" field parsing:
- "to": this.parseEmail(this.getHeaderValue(headers, "to")), + "to": this.getHeaderValue(headers, "to")?.split(',').map(this.parseEmail).filter(Boolean) || [],This change would return an array of parsed email objects for the "to" field, which is more appropriate for handling multiple recipients.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (7)
- components/gmail/package.json (1 hunks)
- components/gmail/sources/common/base.mjs (1 hunks)
- components/gmail/sources/new-attachment-received/new-attachment-received.mjs (1 hunks)
- components/gmail/sources/new-email-matching-search/new-email-matching-search.mjs (1 hunks)
- components/gmail/sources/new-email-received/new-email-received.mjs (1 hunks)
- components/gmail/sources/new-labeled-email/new-labeled-email.mjs (1 hunks)
- components/gmail/sources/new-sent-email/new-sent-email.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (6)
- components/gmail/package.json
- components/gmail/sources/new-attachment-received/new-attachment-received.mjs
- components/gmail/sources/new-email-matching-search/new-email-matching-search.mjs
- components/gmail/sources/new-email-received/new-email-received.mjs
- components/gmail/sources/new-labeled-email/new-labeled-email.mjs
- components/gmail/sources/new-sent-email/new-sent-email.mjs
🔇 Additional comments (2)
components/gmail/sources/common/base.mjs (2)
66-68
: LGTM! Efficient header retrieval implementation.The
getHeaderValue
method provides a concise and effective way to retrieve header values. The case-insensitive comparison ensures robustness, and the use of optional chaining (?.
) gracefully handles cases where the header is not found.
47-79
: Summary: Effective implementation of email header parsingThe changes in this PR successfully address the objectives outlined in issue #14100. The new methods
parseEmail
andgetHeaderValue
, along with the refactoring of theprocessEmail
method, provide a more structured approach to handling email headers. This implementation separates the name and email components, improving the usability of the parsed data.Key improvements:
- Robust email parsing with
parseEmail
method.- Efficient header retrieval with
getHeaderValue
method.- Refactored
processEmail
method applying the new parsing logic.The suggested minor improvements (input validation in
parseEmail
and handling multiple recipients in "to" field) would further enhance the robustness and consistency of the implementation.Overall, this PR successfully meets the customer's requirements and improves the code quality.
Resolves #14100
Summary by CodeRabbit
New Features
parseEmail
for extracting names and email addresses, andgetHeaderValue
for retrieving header values.Version Updates
@pipedream/gmail
: 0.1.6 → 0.1.7gmail-new-attachment-received
: 0.0.4 → 0.0.5gmail-new-email-matching-search
: 0.0.3 → 0.0.4new-email-received
: 0.1.3 → 0.1.4new-labeled-email
: 0.0.4 → 0.0.5gmail-new-sent-email
: 0.0.4 → 0.0.5