Skip to content

Feature/ics rework/mime - #1657

Open
lucs7 wants to merge 1 commit into
LibreBooking:developfrom
lucs7:feature/ics-rework/mime
Open

Feature/ics rework/mime#1657
lucs7 wants to merge 1 commit into
LibreBooking:developfrom
lucs7:feature/ics-rework/mime

Conversation

@lucs7

@lucs7 lucs7 commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

This pull request enhances the email attachment handling system by allowing MIME types to be specified for string attachments, ensuring correct content types are used when sending emails.

Depends on #1656

@lucs7
lucs7 force-pushed the feature/ics-rework/mime branch 2 times, most recently from dba2310 to 8d04d13 Compare August 22, 2026 11:40
@lucs7
lucs7 marked this pull request as ready for review August 26, 2026 08:15
Copilot AI lite review requested due to automatic review settings August 26, 2026 08:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends LibreBooking’s email attachment pipeline so IEmailMessage string attachments can optionally provide an explicit MIME Content-Type, allowing reservation .ics attachments to be sent with text/calendar; ...; method=REQUEST instead of relying on filename-based detection. It also incorporates the attachment-leak fix from the dependent PR (#1656) by clearing PHPMailer attachments before each send.

Changes:

  • Add optional $mimeType support to IEmailMessage::AddStringAttachment(...) and propagate it through EmailMessage + EmailService into PHPMailer’s addStringAttachment(...).
  • Update reservation ICS generation to set an explicit calendar MIME type.
  • Add PHPUnit coverage for EmailService attachment clearing and MIME passthrough.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/lib/Email/EmailServiceTest.php Adds unit tests for clearing attachments per send and passing MIME type into PHPMailer.
tests/fakes/FakeEmailMessage.php Introduces a minimal IEmailMessage fake that supports string attachments + optional MIME type.
tests/fakes/TestReservationEmailMessage.php Adds a reservation-email fake intended to expose ICS attachment generation for testing.
tests/fakes/namespace.php Registers new fakes in the global test bootstrap.
lib/Email/IEmailMessage.php Extends the interface to accept/return attachment MIME type.
lib/Email/EmailMessage.php Stores and exposes the optional attachment MIME type.
lib/Email/EmailService.php Clears attachments before each send and forwards MIME type to PHPMailer.
lib/Email/Messages/ReservationEmailMessage.php Sets the ICS attachment MIME type to text/calendar; charset=UTF-8; method=REQUEST.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/fakes/namespace.php Outdated
Comment thread lib/Email/Messages/ReservationEmailMessage.php
@lucs7
lucs7 force-pushed the feature/ics-rework/mime branch 2 times, most recently from e3ac689 to 1e62cc7 Compare August 28, 2026 18:54
@lucs7

lucs7 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

Code review

Found 1 issue:

  1. ReservationEmailMessage::PopulateIcsAttachment() hardcodes the ICS attachment's Content-Type as method=REQUEST for every reservation email, including cancellations and shares. ReservationDeletedEmail (a cancellation notice) and ReservationShareEmail (a plain share/export) don't override this method, so they'll also ship method=REQUEST in the attachment header. Per RFC 5546/iTip, a cancellation should use method=CANCEL and a share/export should use method=PUBLISH — with the wrong value, RFC 5546-aware clients (e.g. Gmail, Outlook) may render incorrect or missing Accept/Decline/Cancel scheduling UI for these emails.

$display = new CalendarExportDisplay();
$icsContents = $display->Render([$icsView]);
$this->AddStringAttachment(
$icsContents,
'reservation.ics',
'text/calendar; charset=UTF-8; method=REQUEST'
);
}

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

Added mime-type to ics attachment to improve RFC 5546 compliance
and client event recognition. Added mime-type specific tests.
@lucs7
lucs7 force-pushed the feature/ics-rework/mime branch from 1e62cc7 to 3603f86 Compare September 4, 2026 09:31
@lucs7

lucs7 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

Code review is true but mimics the current behaviour of the ics implementation. actual correct method follows in the next PR

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.

3 participants