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

Invitation mail: Change subject if event got updated #36661

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function schedule(Message $iTipMessage) {
$vEvent = array_pop($modified['new']);
/** @var VEvent $oldVevent */
$oldVevent = !empty($modified['old']) && is_array($modified['old']) ? array_pop($modified['old']) : null;
$isModified = isset($oldVevent);

// No changed events after all - this shouldn't happen if there is significant change yet here we are
// The scheduling status is debatable
Expand Down Expand Up @@ -229,7 +230,6 @@ public function schedule(Message $iTipMessage) {
break;
}


$data['attendee_name'] = ($recipientName ?: $recipient);
$data['invitee_name'] = ($senderName ?: $sender);

Expand All @@ -244,7 +244,7 @@ public function schedule(Message $iTipMessage) {
$template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data);
$template->addHeader();

$this->imipService->addSubjectAndHeading($template, $method, $data['invitee_name'], $data['meeting_title']);
$this->imipService->addSubjectAndHeading($template, $method, $data['invitee_name'], $data['meeting_title'], $isModified);
$this->imipService->addBulletList($template, $vEvent, $data);

// Only add response buttons to invitation requests: Fix Issue #11230
Expand Down
7 changes: 6 additions & 1 deletion apps/dav/lib/CalDAV/Schedule/IMipService.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,10 @@ public function getAttendeeRsvpOrReqForParticipant(?Property $attendee = null) {
* @param string $sender
* @param string $summary
* @param string|null $partstat
* @param bool $isModified
*/
public function addSubjectAndHeading(IEMailTemplate $template,
string $method, string $sender, string $summary): void {
string $method, string $sender, string $summary, bool $isModified): void {
if ($method === IMipPlugin::METHOD_CANCEL) {
// TRANSLATORS Subject for email, when an invitation is cancelled. Ex: "Cancelled: {{Event Name}}"
$template->setSubject($this->l10n->t('Cancelled: %1$s', [$summary]));
Expand All @@ -370,6 +371,10 @@ public function addSubjectAndHeading(IEMailTemplate $template,
// TRANSLATORS Subject for email, when an invitation is replied to. Ex: "Re: {{Event Name}}"
$template->setSubject($this->l10n->t('Re: %1$s', [$summary]));
$template->addHeading($this->l10n->t('%1$s has responded to your invitation', [$sender]));
} elseif ($method === IMipPlugin::METHOD_REQUEST && $isModified) {
// TRANSLATORS Subject for email, when an invitation is updated. Ex: "Invitation updated: {{Event Name}}"
$template->setSubject($this->l10n->t('Invitation updated: %1$s', [$summary]));
$template->addHeading($this->l10n->t('%1$s updated the event "%2$s"', [$sender, $summary]));
} else {
// TRANSLATORS Subject for email, when an invitation is sent. Ex: "Invitation: {{Event Name}}"
$template->setSubject($this->l10n->t('Invitation: %1$s', [$summary]));
Expand Down
10 changes: 5 additions & 5 deletions apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function testParsingSingle(): void {
->method('getFrom');
$this->service->expects(self::once())
->method('addSubjectAndHeading')
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir');
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir', true);
$this->service->expects(self::once())
->method('addBulletList')
->with($this->emailTemplate, $newVevent, $data);
Expand Down Expand Up @@ -296,7 +296,7 @@ public function testParsingRecurrence(): void {
->method('getFrom');
$this->service->expects(self::once())
->method('addSubjectAndHeading')
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Elevenses');
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Elevenses', false);
$this->service->expects(self::once())
->method('addBulletList')
->with($this->emailTemplate, $newVevent, $data);
Expand Down Expand Up @@ -405,7 +405,7 @@ public function testFailedDelivery(): void {
->method('getFrom');
$this->service->expects(self::once())
->method('addSubjectAndHeading')
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir');
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir', false);
$this->service->expects(self::once())
->method('addBulletList')
->with($this->emailTemplate, $newVevent, $data);
Expand Down Expand Up @@ -480,7 +480,7 @@ public function testNoOldEvent(): void {
->method('getFrom');
$this->service->expects(self::once())
->method('addSubjectAndHeading')
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting');
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting', false);
$this->service->expects(self::once())
->method('addBulletList')
->with($this->emailTemplate, $newVevent, $data);
Expand Down Expand Up @@ -553,7 +553,7 @@ public function testNoButtons(): void {
->method('getFrom');
$this->service->expects(self::once())
->method('addSubjectAndHeading')
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting');
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting', false);
$this->service->expects(self::once())
->method('addBulletList')
->with($this->emailTemplate, $newVevent, $data);
Expand Down