fix(appointments): calendar booking notifications

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
This commit is contained in:
Richard Steinmetz 2023-03-06 09:06:56 +01:00
parent 7e8f1a0d7b
commit a61f7a9155
No known key found for this signature in database
GPG Key ID: 27137D9E7D273FB2
2 changed files with 0 additions and 20 deletions

View File

@ -75,12 +75,6 @@ class Notifier implements INotifier {
'link' => $this->url->linkToRouteAbsolute('calendar.view.index') 'link' => $this->url->linkToRouteAbsolute('calendar.view.index')
] ]
]); ]);
$placeholders = $replacements = [];
foreach ($notification->getRichSubjectParameters() as $placeholder => $parameter) {
$placeholders[] = '{' . $placeholder . '}';
$replacements[] = $parameter[$placeholder];
}
$notification->setParsedSubject(str_replace($placeholders, $replacements, $notification->getRichSubject()));
$messageParameters = $notification->getMessageParameters(); $messageParameters = $notification->getMessageParameters();
$notification->setRichMessage($l->t('{display_name} ({email}) booked the appointment "{config_display_name}" on {date_time}.'), [ $notification->setRichMessage($l->t('{display_name} ({email}) booked the appointment "{config_display_name}" on {date_time}.'), [
@ -105,17 +99,11 @@ class Notifier implements INotifier {
'name' => $messageParameters['config_display_name'], 'name' => $messageParameters['config_display_name'],
] ]
]); ]);
foreach ($notification->getRichMessageParameters() as $placeholder => $parameter) {
$placeholders[] = '{' . $placeholder . '}';
$replacements[] = $parameter[$placeholder];
}
$notification->setParsedMessage(str_replace($placeholders, $replacements, $notification->getRichMessage()));
break; break;
default: default:
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }
return $notification; return $notification;
} }
} }

View File

@ -179,20 +179,12 @@ class NotifierTest extends \PHPUnit\Framework\TestCase {
$notification->expects($this->once()) $notification->expects($this->once())
->method('setRichSubject') ->method('setRichSubject')
->with('New booking {booking}', $booking); ->with('New booking {booking}', $booking);
$notification->expects($this->once())
->method('getRichSubjectParameters');
$notification->expects(self::once())
->method('setParsedSubject');
$notification->expects(self::once()) $notification->expects(self::once())
->method('getMessageParameters') ->method('getMessageParameters')
->willReturn($messageParameters); ->willReturn($messageParameters);
$notification->expects($this->once()) $notification->expects($this->once())
->method('setRichMessage') ->method('setRichMessage')
->with('{display_name} ({email}) booked the appointment "{config_display_name}" on {date_time}.', $messageRichData); ->with('{display_name} ({email}) booked the appointment "{config_display_name}" on {date_time}.', $messageRichData);
$notification->expects($this->once())
->method('getRichMessageParameters');
$notification->expects(self::once())
->method('setParsedMessage');
$return = $this->notifier->prepare($notification, 'de'); $return = $this->notifier->prepare($notification, 'de');
$this->assertEquals($notification, $return); $this->assertEquals($notification, $return);