Skip to content

Commit

Permalink
refactor(ShareApiController): Check for null and empty strings with e…
Browse files Browse the repository at this point in the history
…mpty()

Proactive measure to avoid warnings in higher php versions as well possible type errors

Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
  • Loading branch information
nfebe committed Oct 24, 2024
1 parent bc6a3e8 commit 227b846
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,10 @@ public function createShare(
// Handle mail send
if (is_null($sendMail)) {
// Define a default behavior when sendMail is not provided
if ($shareType === IShare::TYPE_EMAIL && strlen($shareWith) !== 0) {
// For email shares, the default is to send the mail
$share->setMailSend(true);
} else {
// For all other share types, the default is to not send the mail
$share->setMailSend(false);
}
// For email shares with a valid recipient, the default is to send the mail
// For all other share types, the default is to not send the mail
$allowSendMail = ($shareType === IShare::TYPE_EMAIL && $shareWith !== null && $shareWith !== '');
$share->setMailSend($allowSendMail);
} else {
$share->setMailSend($sendMail === 'true');
}
Expand Down

0 comments on commit 227b846

Please sign in to comment.