Skip to content
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
23 changes: 17 additions & 6 deletions apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function schedule(Message $iTipMessage) {
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
return;
}
$recipientName = $iTipMessage->recipientName ?: null;
$recipientName = $iTipMessage->recipientName ? (string)$iTipMessage->recipientName : null;

Check notice

Code scanning / Psalm

RedundantCastGivenDocblockType

Redundant cast to string given docblock-provided type

$newEvents = $iTipMessage->message;
$oldEvents = $this->getVCalendar();
Expand Down Expand Up @@ -213,9 +213,11 @@ public function schedule(Message $iTipMessage) {
$senderName = $senderName->getValue() ?? null;
}

if ($senderName === null || empty(trim($senderName))) {
// Try to get the sender name from the current user id if available.
if ($this->userId !== null && ($senderName === null || empty(trim($senderName)))) {
$senderName = $this->userManager->getDisplayName($this->userId);
}

$sender = substr($iTipMessage->sender, 7);
if($sender === false) {
$sender = Util::getDefaultEmailAddress('invitations-noreply');
Expand All @@ -236,17 +238,26 @@ public function schedule(Message $iTipMessage) {
break;
}


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

$fromEMail = Util::getDefaultEmailAddress('invitations-noreply');
$fromName = $this->imipService->getFrom($senderName, $this->defaults->getName());

$message = $this->mailer->createMessage()
->setFrom([$fromEMail => $fromName])
->setTo([$recipient => $recipientName ?: $recipient])
->setReplyTo([$sender => $senderName]);
->setFrom([$fromEMail => $fromName]);

if ($recipientName !== null) {
$message->setTo([$recipient => $recipientName]);
} else {
$message->setTo([$recipient]);
}

if ($senderName !== null) {
$message->setReplyTo([$sender => $senderName]);
} else {
$message->setReplyTo([$sender]);
}

$template = $this->mailer->createEMailTemplate('dav.calendarInvite.' . $method, $data);
$template->addHeader();
Expand Down
10 changes: 7 additions & 3 deletions apps/dav/lib/CalDAV/Schedule/IMipService.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ public function __construct(URLGenerator $urlGenerator,
}

/**
* @param string $senderName
* @param $default
* @param string|null $senderName
* @param string $default
* @return string
*/
public function getFrom(string $senderName, $default): string {
public function getFrom(?string $senderName, string $default): string {
if ($senderName === null) {
return $default;
}

return $this->l10n->t('%1$s via %2$s', [$senderName, $default]);
}

Expand Down