Skip to content

Update SimpleEmailMessage #450

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

Closed
wants to merge 1 commit into from
Closed

Conversation

charles-circulo
Copy link

Issue #, if available:
#431

Description of changes:
Add support to parse Tags

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@bmoffatt
Copy link
Collaborator

Thanks for the PR! Do you have a documentation link I can verify this against?

My quick search found these, neither of which includes "tags"

  1. https://docs.aws.amazon.com/ses/latest/dg/receiving-email-action-lambda-event.html#receiving-email-action-lambda-event-lambdaaction
  2. https://docs.aws.amazon.com/lambda/latest/dg/services-ses.html

@charles-circulo
Copy link
Author

Hello @bmoffatt and thank you for the follow-up.

I could be wrong, but should I was using SimpleEmailMessage to unmarshal a message that SES publishes to SNS and in all of those cases, there are a few ses:* tags along with any custom ones passed when calling to the Send API.

Is there an alternate struct better suited to doing so, is the expectation that users should roll their own, or something else I'm completely unaware of? Thanks in advance.

@bmoffatt
Copy link
Collaborator

ahh, inside SNS! Thanks for that link! So the way this'd be accessed then is after a second unmarshal of the SNSEvent.Record[0].SNS.Message? Sorta like the approach taken in #296

Seems there'll also need be be a wrapper struct for the SNS usecase, along with models for the event records. Something like:

type SESBounceRecord struct { /* ... */ }
type SESComplaintRecord struct { /* ... */ }
type SESSendRecord struct { /* ... */ }
// etc...

// to be unmarshaled out from an SNSEvent.Records[0].SNS.Message string
type SimpleEmailNotificationMessage struct {
	EventType       string              `json:"eventType"`
	Mail            SimpleEmailMessage  `json:"mail"`
        // only one of the following fields will be non-nil, matching the value of the EventType field 
	BounceRecord    *SESBounceRecord    `json:"bounce,omitempty"`
	ComplaintRecord *SESComplaintRecord `json:"complaint,omitempty"`
	SendRecord      *SESSendRecord      `json:"send,omitempty"`
	// etc...
}

@charles-circulo
Copy link
Author

That would be perfect! I may have some time this weekend to flesh that out if someone else doesn't get to it first, seems like it's pretty low priority if no one has asked for this already.

What would be the approach? Assuming:

  • These wrapper structs are created and live in ses.go
  • New test data exists for each type, similar to ses-sns-event.json, but in ses-sns-payload-*.json, where * is send, bounce, click, etc.
  • Tests exist for each sample payload in sns_test.go

Anything I'm missing? Really appreciate the help 🙌

@bmoffatt
Copy link
Collaborator

bmoffatt commented Jul 13, 2022

That would be perfect! I may have some time this weekend to flesh that out if someone else doesn't get to it first, seems like it's pretty low priority if no one has asked for this already.

What would be the approach? Assuming:

  • These wrapper structs are created and live in ses.go
  • New test data exists for each type, similar to ses-sns-event.json, but in ses-sns-payload-*.json, where * is send, bounce, click, etc.
  • Tests exist for each sample payload in sns_test.go

Anything I'm missing? Really appreciate the help 🙌

👍 Suggest putting the new types & tests in a new file ses_via_sns.go/ses_via_sns_test.go, to help with the self documentation that this is a different integration than the direct SES -> Lambda email receipt integration.

The closer similar test data to emulate type I think is cloudwatch-alarm-sns-payload-multiple-metrics.json, such that the send, bounce, click, etc.., are stringified JSON inside the SNS Message field

@bmoffatt bmoffatt added the type/events issue or feature request related to the events package label Dec 21, 2022
@bmoffatt
Copy link
Collaborator

bmoffatt commented Dec 1, 2023

Closing stale PR, feel free to re-open if you want to keep working on it! Will copy the re-work comment back to the original issue for future reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/events issue or feature request related to the events package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants