Skip to content
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

Add support for cid based attachment in email #4952

Merged

Conversation

djabarovgeorge
Copy link
Contributor

What change does this PR introduce?

CID attachment is used for inline image embedding

Example:-

To show novu logo as inline embed in html

<html>
  <body>
    <p>Before image</p>
    <img src="cid:novu-logo" alt="Novu logo">
    <p>After image</p>
  </body>
</html>

Sendgrid attachment example code:-

{
  "content": "imageFileBase64",
  "filename": "index.jpeg",
  "type": "image/jpeg",
  "disposition": "inline",
  "content_id": "novu-logo"
}

Why? (Context)

Novu has 3 fields for attachments currently:-

{
   file: "base64 of file",
   name: 'file_name.jpeg',
   mime: 'image/jpeg',
}

Definition of Done

Add new fields to support CID based attachments

Copy link

linear bot commented Dec 6, 2023

} from '@novu/stateless';

import { MailDataRequired, MailService } from '@sendgrid/mail';

type AttachmentJSON = MailDataRequired['attachments'][0];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea why but the AttachmentJSON is not exported from @sendgrid/mail, created this workaround so we won't use any in the code, and without importing other libs or creating internal types that can become stale.

Copy link
Contributor

@LetItRock LetItRock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

providers/sendgrid/src/lib/sendgrid.provider.ts Outdated Show resolved Hide resolved
@djabarovgeorge djabarovgeorge merged commit 0744144 into next Dec 17, 2023
26 checks passed
@djabarovgeorge djabarovgeorge deleted the nv-3185-add-support-for-cid-based-attachment-in-email branch December 17, 2023 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants