Problem/Motivation

OrchestraNotificationEvent is the channel-neutral contract for notifications: resolved recipients plus structured params, delivered by whichever channel is enabled. There is currently no way for a dispatcher to attach a file (a generated PDF, an ICS invite, a receipt), so a channel cannot deliver one.

The concrete driver is the Yoyaku ticket submodule (yoyaku #3611638): on order confirmation it generates a PDF ticket that should ride along on the existing confirmation email rather than forcing a second, separate email. An order can hold several tickets (one per booked place), so a notification must be able to carry multiple attachments, one per ticket.

Proposed resolution

Add a neutral attachments payload to OrchestraNotificationEvent and have the shipped channels honor it.

  1. New NotificationAttachment value object (@api): filename, mimeType, and one of content (raw bytes) or uri (a stream-wrapper URI), so a producer can pass either an in-memory blob or a file.
  2. New trailing array $attachments = [] constructor argument on OrchestraNotificationEvent, a list of NotificationAttachment. Being a list, one notification can carry many files (one per ticket). It is appended last, so existing dispatchers are unaffected.
  3. orchestra_mail: pass the attachments through so hook_mail sets the message attachments (the de-facto convention honored by Symfony Mailer and Mime Mail). The default PHP mail backend does not send attachments; this is a mail-system capability, not an Orchestra one.
  4. orchestra_easy_email: map the attachments onto the Easy Email entity before send.

Remaining tasks

  • Implement the value object and the event change.
  • Honor attachments in both channels.
  • Unit and kernel coverage for both channels: attachment present, empty default, uri versus content, and multiple attachments.

API changes

  • OrchestraNotificationEvent::__construct() gains a trailing array $attachments = [] argument (backward compatible).
  • New @api NotificationAttachment value object.

Issue fork orchestra-3612558

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review

  • mably committed 6a40a972 on 1.x
    feat: #3612558 Carry file attachments on OrchestraNotificationEvent and...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.