Skip to content

Commit

Permalink
fix(ShareAPI): Send mails for mail shares by default
Browse files Browse the repository at this point in the history
It looks like, the frontend it needs to provide the `sendMail` param
for the backend to decide wether mails would be sent.

Our UI does not have that at the moment so it should default to sending
emails always for mail shares.

Not exactly sure how this was handled earlier but this is a good starting point.

Resolves : #48012

Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
  • Loading branch information
Fenn-CS committed Sep 26, 2024
1 parent 0a568e5 commit 33e46ad
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,24 @@ public function createShare(
$this->checkInheritedAttributes($share);

// Handle mail send
if ($sendMail === 'true' || $sendMail === 'false') {
$share->setMailSend($sendMail === 'true');
if (is_null($sendMail)) {
// Define a default behavior when sendMail is not provided
if($shareType === IShare::TYPE_EMAIL) {
// 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);
}
} else {
// Convert common "truthy" and "falsy" values to proper booleans
$sendMailBool = filter_var($sendMail, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);

if ($sendMailBool !== null) {
$share->setMailSend($sendMailBool);
} else {
throw new OCSNotFoundException($this->l->t('Invalid value for sendMail'));
}
}

if ($shareType === IShare::TYPE_USER) {
Expand Down

0 comments on commit 33e46ad

Please sign in to comment.