Skip to content
Merged
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
11 changes: 7 additions & 4 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,13 @@ public function createShare(

// Handle mail send
if (is_null($sendMail)) {
// Define a default behavior when sendMail is not provided
// 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 !== '');
$allowSendMail = $this->config->getSystemValueBool('sharing.enable_share_mail', true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$allowSendMail = $this->config->getSystemValueBool('sharing.enable_share_mail', true);
$allowSendMail = $this->config->getSystemValueBool('sharing.enable_share_mail', true) || ($shareType === IShare::TYPE_EMAIL && $shareWith !== null && $shareWith !== '');

The entire logic could be written a bit nicer like this, since it deduplicates checks.

if ($allowSendMail !== true || $shareType === IShare::TYPE_EMAIL) {
// Define a default behavior when sendMail is not provided
// 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
Loading