feat: Refactor Inbound package to provide access to SendGrid's pre-processing#443
Merged
shwetha-manvinkurke merged 16 commits intosendgrid:mainfrom Feb 9, 2022
Merged
feat: Refactor Inbound package to provide access to SendGrid's pre-processing#443shwetha-manvinkurke merged 16 commits intosendgrid:mainfrom
shwetha-manvinkurke merged 16 commits intosendgrid:mainfrom
Conversation
<!-- We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below.
Contributor
Author
|
I have updated the code and documentation to patch #444, and to warn people away from the email.Headers field |
Contributor
Author
|
sorry for the delay, I have not had a change to return to this and respond or look into the review issues. I hope to have some time to get to it in the next week or so |
|
Hi @qhenkart. Thank you |
Contributor
Author
|
@mewis thank you for the reminder. I've put aside some time to fix up the minor updates, and I will handle any continued code review updates faster. Keep an eye out for the approval |
|
Any updates on this @shwetha-manvinkurke @qhenkart ? |
shwetha-manvinkurke
approved these changes
Feb 9, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #439
Resolves #444
The inbound package as it is currently written cannot work in a reasonable fashion for several reasons
Primarily the package currently relies on the email field to extract attachments and email body https://github.com/sendgrid/sendgrid-go/blob/main/helpers/inbound/inbound.go#L35. However the email field is empty unless you select the RAW setting in SendGrid. This means that without the RAW setting, you will only have headers and no access to other fields
SendGrid provides a large set of fields that should be utilized, verified and checked that this library does not give access to. and the RAW setting should not be required to use this library
I have maintained the previous field names and functionality so there should be no breaking change. I have added a number of features that SendGrid already provides https://docs.sendgrid.com/for-developers/parsing-email/setting-up-the-inbound-parse-webhook
email := inbound.Parse skips the attachments but still provides the informative fields provided by SendGrid
email := inbound.ParseWithAttachments includes the attachment files
email.TextBody now reflects the parsed text/plain field
email.ParsedValues now provide access to all fields preprocessed by SendGrid
email.ParsedAttachments now provide access to the actual files, that is matched and attached to the information processed by SendGrid
email.Envelope is unmarshalled and provides email.Envelope.From which is the actual sender's email address without additional characters
email.Validate() will ensure that all of the DKIM and SPF values are passing to avoid spoofing and phishing attacks.
This PR provides functionality that matches the Sendgrid inbound capabilities listed in the official documentation. We are using it in production and it works great.
Check out the examples here
Checklist
If you have questions, please file a support ticket, or create a GitHub Issue in this repository.