Skip to content

Commit 91a3ce1

Browse files
committed
fix(ShareAPI): Send mails for mail shares by default
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>
1 parent 363ba6b commit 91a3ce1

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,16 @@ public function createShare(
658658
$this->checkInheritedAttributes($share);
659659

660660
// Handle mail send
661-
if ($sendMail === 'true' || $sendMail === 'false') {
661+
if (is_null($sendMail)) {
662+
// Define a default behavior when sendMail is not provided
663+
if ($shareType === IShare::TYPE_EMAIL) {
664+
// For email shares, the default is to send the mail
665+
$share->setMailSend(true);
666+
} else {
667+
// For all other share types, the default is to not send the mail
668+
$share->setMailSend(false);
669+
}
670+
} else {
662671
$share->setMailSend($sendMail === 'true');
663672
}
664673

@@ -718,7 +727,7 @@ public function createShare(
718727
}
719728

720729
// Only share by mail have a recipient
721-
if (is_string($shareWith) && $shareType === IShare::TYPE_EMAIL) {
730+
if (!empty($shareWith) && !is_null($shareWith) && $shareType === IShare::TYPE_EMAIL) {
722731
// If sending a mail have been requested, validate the mail address
723732
if ($share->getMailSend() && !$this->mailer->validateMailAddress($shareWith)) {
724733
throw new OCSNotFoundException($this->l->t('Please specify a valid email address'));
@@ -1218,11 +1227,6 @@ public function updateShare(
12181227
}
12191228
$this->checkInheritedAttributes($share);
12201229

1221-
// Handle mail send
1222-
if ($sendMail === 'true' || $sendMail === 'false') {
1223-
$share->setMailSend($sendMail === 'true');
1224-
}
1225-
12261230
/**
12271231
* expirationdate, password and publicUpload only make sense for link shares
12281232
*/

0 commit comments

Comments
 (0)