Fix inline images for eml exports (#4879)
We have to use `contentId` instead of name for inline attachments as filenames can be duplicated. --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
40d1d4fb21
commit
90bed4c14e
@ -2,8 +2,12 @@ package eml
|
|||||||
|
|
||||||
// This package helps convert from the json response
|
// This package helps convert from the json response
|
||||||
// received from Graph API to .eml format (rfc0822).
|
// received from Graph API to .eml format (rfc0822).
|
||||||
// Ref: https://www.ietf.org/rfc/rfc0822.txt
|
|
||||||
// Ref: https://datatracker.ietf.org/doc/html/rfc5322
|
// RFC
|
||||||
|
// Original: https://www.ietf.org/rfc/rfc0822.txt
|
||||||
|
// New: https://datatracker.ietf.org/doc/html/rfc5322
|
||||||
|
// Extension for MIME: https://www.ietf.org/rfc/rfc1521.txt
|
||||||
|
|
||||||
// Data missing from backup:
|
// Data missing from backup:
|
||||||
// SetReturnPath SetPriority SetListUnsubscribe SetDkim
|
// SetReturnPath SetPriority SetListUnsubscribe SetDkim
|
||||||
// AddAlternative SetDSN (and any other X-MS specific headers)
|
// AddAlternative SetDSN (and any other X-MS specific headers)
|
||||||
@ -17,6 +21,7 @@ import (
|
|||||||
mail "github.com/xhit/go-simple-mail/v2"
|
mail "github.com/xhit/go-simple-mail/v2"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
|
"github.com/alcionai/corso/src/internal/common/str"
|
||||||
"github.com/alcionai/corso/src/pkg/logger"
|
"github.com/alcionai/corso/src/pkg/logger"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
)
|
)
|
||||||
@ -152,8 +157,23 @@ func FromJSON(ctx context.Context, body []byte) (string, error) {
|
|||||||
return "", clues.WrapWC(ctx, err, "invalid content bytes")
|
return "", clues.WrapWC(ctx, err, "invalid content bytes")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name := ptr.Val(attachment.GetName())
|
||||||
|
|
||||||
|
contentID, err := attachment.GetBackingStore().Get("contentId")
|
||||||
|
if err != nil {
|
||||||
|
return "", clues.WrapWC(ctx, err, "getting content id for attachment")
|
||||||
|
}
|
||||||
|
|
||||||
|
if contentID != nil {
|
||||||
|
cids, _ := str.AnyToString(contentID)
|
||||||
|
if len(cids) > 0 {
|
||||||
|
name = cids
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
email.Attach(&mail.File{
|
email.Attach(&mail.File{
|
||||||
Name: ptr.Val(attachment.GetName()),
|
// cannot use filename as inline attachment will not get mapped properly
|
||||||
|
Name: name,
|
||||||
MimeType: kind,
|
MimeType: kind,
|
||||||
Data: bts,
|
Data: bts,
|
||||||
Inline: ptr.Val(attachment.GetIsInline()),
|
Inline: ptr.Val(attachment.GetIsInline()),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user