Skip to content

Commit

Permalink
Merge pull request #10334 from nextcloud/bug/noid/handle-null-value-f…
Browse files Browse the repository at this point in the history
…or-sender

fix: add null check for sender in imipservice
  • Loading branch information
kesselb authored Nov 11, 2024
2 parents 94a3254 + 2885f62 commit 689cebe
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/Service/IMipService.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ public function process(): void {
continue;
}

$principalUri = 'principals/users/' . $account->getUserId();
$recipient = $account->getEmail();

foreach ($filteredMessages as $message) {
/** @var IMAPMessage $imapMessage */
$imapMessage = current(array_filter($imapMessages, static function (IMAPMessage $imapMessage) use ($message) {
Expand All @@ -131,9 +134,12 @@ public function process(): void {
continue;
}

$principalUri = 'principals/users/' . $account->getUserId();
$sender = $imapMessage->getFrom()->first()->getEmail();
$recipient = $account->getEmail();
$sender = $imapMessage->getFrom()->first()?->getEmail();
if ($sender === null) {
$message->setImipError(true);
continue;
}

foreach ($imapMessage->scheduling as $schedulingInfo) { // an IMAP message could contain more than one iMIP object
if ($schedulingInfo['method'] === 'REQUEST' && method_exists($this->calendarManager, 'handleIMipRequest')) {
$processed = $this->calendarManager->handleIMipRequest($principalUri, $sender, $recipient, $schedulingInfo['contents']);
Expand All @@ -144,8 +150,7 @@ public function process(): void {
$message->setImipProcessed($processed);
$message->setImipError(!$processed);
} elseif ($schedulingInfo['method'] === 'CANCEL') {
$replyTo = $imapMessage->getReplyTo()->first();
$replyTo = !empty($replyTo) ? $replyTo->getEmail() : null;
$replyTo = $imapMessage->getReplyTo()->first()?->getEmail();
$processed = $this->calendarManager->handleIMipCancel($principalUri, $sender, $replyTo, $recipient, $schedulingInfo['contents']);
$message->setImipProcessed($processed);
$message->setImipError(!$processed);
Expand Down

0 comments on commit 689cebe

Please sign in to comment.