From d6db70c2396eb7ff23b37aac2f4b81700272c4b5 Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Wed, 20 Dec 2023 23:35:11 +0530 Subject: [PATCH] Update to latest go-simple-mail (#4894) This adds support for empty attachments and also cleans up how email validation skip is done. Contains PRs 97 and 98 upstream --- #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No #### Type of change - [x] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup #### Issue(s) * # #### Test Plan - [ ] :muscle: Manual - [x] :zap: Unit test - [ ] :green_heart: E2E --- src/go.mod | 2 +- src/go.sum | 4 ++-- src/internal/converters/eml/eml.go | 12 ++---------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/go.mod b/src/go.mod index 11aebeead..c3d78b5be 100644 --- a/src/go.mod +++ b/src/go.mod @@ -9,7 +9,7 @@ replace ( github.com/minio/minio-go/v7 => github.com/alcionai/minio-go/v7 v7.0.0-20231130221740-c745a3d084aa // Alcion fork removes the validation of email addresses as we might get incomplete email addresses - github.com/xhit/go-simple-mail/v2 v2.16.0 => github.com/alcionai/go-simple-mail/v2 v2.0.0-20231216082222-e8c58c45d8a5 + github.com/xhit/go-simple-mail/v2 v2.16.0 => github.com/alcionai/go-simple-mail/v2 v2.0.0-20231220071811-c70ebcd9a41a ) require ( diff --git a/src/go.sum b/src/go.sum index 066a358b1..33d194127 100644 --- a/src/go.sum +++ b/src/go.sum @@ -17,8 +17,8 @@ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpH github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/alcionai/clues v0.0.0-20231115004051-523cbddac8e8 h1:kdpkhcKWWxnZFteGjglHvFTTPCPsvjhKDDY9J1Od6Sg= github.com/alcionai/clues v0.0.0-20231115004051-523cbddac8e8/go.mod h1:hGnRqQtV7YoojQSNMtqFK0TvfcwAljGZhUEQwx1lw34= -github.com/alcionai/go-simple-mail/v2 v2.0.0-20231216082222-e8c58c45d8a5 h1:4Vgk6zqk9lh5E1E/okrCjB+3ueyGO8BC2uC0tWtDORQ= -github.com/alcionai/go-simple-mail/v2 v2.0.0-20231216082222-e8c58c45d8a5/go.mod h1:b7P5ygho6SYE+VIqpxA6QkYfv4teeyG4MKqB3utRu98= +github.com/alcionai/go-simple-mail/v2 v2.0.0-20231220071811-c70ebcd9a41a h1:4nhM0NM1qtUT1s55rQ+D0Xw1Re5mIU9/crjEl6KdE+k= +github.com/alcionai/go-simple-mail/v2 v2.0.0-20231220071811-c70ebcd9a41a/go.mod h1:b7P5ygho6SYE+VIqpxA6QkYfv4teeyG4MKqB3utRu98= github.com/alcionai/kopia v0.12.2-0.20231205231702-863c24d6f8b1 h1:UM4YDqNmwRsajtoQT4BkMCRrjIeMDwTuTbJs5fPQTTA= github.com/alcionai/kopia v0.12.2-0.20231205231702-863c24d6f8b1/go.mod h1:f4PligAuyEicX+lfTlZltc69nM0eMoXX2nE5sCBdo6Y= github.com/alcionai/minio-go/v7 v7.0.0-20231130221740-c745a3d084aa h1:PHzp5TkXgsardwMG6O2nnyk3zBsGW8CqgsOWQCYkykQ= diff --git a/src/internal/converters/eml/eml.go b/src/internal/converters/eml/eml.go index b26a2a1bb..7d0663898 100644 --- a/src/internal/converters/eml/eml.go +++ b/src/internal/converters/eml/eml.go @@ -62,6 +62,8 @@ func FromJSON(ctx context.Context, body []byte) (string, error) { email := mail.NewMSG() email.AllowDuplicateAddress = true // More "correct" conversion email.AddBccToHeader = true // Don't ignore Bcc + email.AllowEmptyAttachments = true // Don't error on empty attachments + email.UseProvidedAddress = true // Don't try to parse the email address if data.GetFrom() != nil { email.SetFrom(formatAddress(data.GetFrom().GetEmailAddress())) @@ -157,16 +159,6 @@ func FromJSON(ctx context.Context, body []byte) (string, error) { return "", clues.WrapWC(ctx, err, "invalid content bytes") } - if len(bts) == 0 { - // TODO(meain): pass the data through after - // https://github.com/xhit/go-simple-mail/issues/96 - logger.Ctx(ctx). - With("attachment_id", ptr.Val(attachment.GetId())). - Info("empty attachment") - - continue - } - name := ptr.Val(attachment.GetName()) contentID, err := attachment.GetBackingStore().Get("contentId")