Skip to content

Implement Attachments#2

Merged
hugobessa merged 4 commits intomainfrom
feat/attachments
Jan 14, 2026
Merged

Implement Attachments#2
hugobessa merged 4 commits intomainfrom
feat/attachments

Conversation

@hugobessa
Copy link
Collaborator

@hugobessa hugobessa commented Jan 14, 2026

Summary by Sourcery

Add attachment support to the Nodemailer notification adapter and align package and dependency versions with the corresponding Vintasend release.

New Features:

  • Enable sending email notifications with file attachments via the Nodemailer adapter.

Enhancements:

  • Expose an attachments capability flag on the Nodemailer notification adapter.

Build:

  • Bump library version and update the Vintasend dependency to the matching 0.4.x release.

Tests:

  • Add tests covering attachment handling in the Nodemailer adapter.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 14, 2026

Reviewer's Guide

Adds attachment support to the Nodemailer notification adapter and aligns the package with vintasend v0.4.0, including tests for attachment handling.

Sequence diagram for sending an email with attachments via NodemailerNotificationAdapter

sequenceDiagram
  actor System
  participant Adapter as NodemailerNotificationAdapter
  participant Renderer as BaseEmailTemplateRenderer
  participant Notification as AnyDatabaseNotification
  participant FileStore as StoredAttachment_file
  participant Transporter as Nodemailer_Transporter

  System->>Adapter: send(notification, context)
  Adapter->>Adapter: check backend injected
  Adapter->>Renderer: render(notification, context)
  Renderer-->>Adapter: template
  Adapter->>Adapter: build mailOptions (from, to, subject, text, html)
  Adapter->>Notification: read attachments
  alt attachments present
    loop for each StoredAttachment
      Adapter->>FileStore: att.file.read()
      FileStore-->>Adapter: content (Buffer)
    end
    Adapter->>Adapter: prepareAttachments(attachments)
    Adapter-->>Adapter: Mail_Attachment[]
    Adapter->>Adapter: attach to mailOptions.attachments
  else no attachments
    Adapter->>Adapter: send without mailOptions.attachments
  end
  Adapter->>Transporter: sendMail(mailOptions)
  Transporter-->>Adapter: result
  Adapter-->>System: void
Loading

Updated class diagram for NodemailerNotificationAdapter with attachment support

classDiagram
  class BaseNotificationAdapter {
  }

  class BaseEmailTemplateRenderer {
  }

  class AnyDatabaseNotification {
    +attachments StoredAttachment[]
  }

  class StoredAttachment {
    +filename string
    +contentType string
    +file StoredAttachment_file
  }

  class StoredAttachment_file {
    +read() Promise_Buffer
  }

  class Mail_Attachment {
    +filename string
    +content any
    +contentType string
  }

  class NodemailerNotificationAdapter {
    -transporter Nodemailer_Transporter
    +constructor(transportOptions any)
    +get supportsAttachments() boolean
    +send(notification AnyDatabaseNotification, context JsonObject) Promise_void
    +prepareAttachments(attachments StoredAttachment[]) Promise_Mail_Attachment_array
  }

  class Nodemailer_Transporter {
    +sendMail(mailOptions any) Promise_any
  }

  BaseNotificationAdapter <|-- NodemailerNotificationAdapter
  NodemailerNotificationAdapter o--> BaseEmailTemplateRenderer : uses
  NodemailerNotificationAdapter o--> Nodemailer_Transporter : has
  AnyDatabaseNotification o--> StoredAttachment : has
  StoredAttachment o--> StoredAttachment_file : has
  NodemailerNotificationAdapter ..> AnyDatabaseNotification : send parameter
  NodemailerNotificationAdapter ..> StoredAttachment : prepareAttachments parameter
  NodemailerNotificationAdapter ..> Mail_Attachment : returns array
Loading

File-Level Changes

Change Details Files
Enable attachments in the Nodemailer notification adapter.
  • Import Nodemailer Mail type and StoredAttachment type for strong typing of attachments.
  • Expose a supportsAttachments getter that returns true to signal capability to the caller/backend.
  • Extend send() to detect notification.attachments and, when present, attach them to the Nodemailer mail options.
  • Introduce a protected prepareAttachments() helper that maps StoredAttachment objects to Nodemailer Mail.Attachment objects, including reading file content asynchronously.
src/nodemailer-notification-adapter.ts
Align package and tests with vintasend v0.4.0 and cover attachment behavior.
  • Bump library version from 0.3.0 to 0.4.0 and update vintasend peer dependency to ^0.4.0.
  • Add a dedicated test suite for attachment handling in the Nodemailer adapter and adjust existing tests as needed for the new behavior.
package.json
src/__tests__/nodemailer-adapter-one-off.test.ts
src/__tests__/nodemailer-notification-adapter.test.ts
src/__tests__/nodemailer-adapter-attachments.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@hugobessa hugobessa merged commit ee984ce into main Jan 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant