Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ShareAPI): Send mails for mail shares by default #48381

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Fenn-CS
Copy link
Contributor

@Fenn-CS Fenn-CS commented Sep 26, 2024

Summary

It looks like, the frontend it needs to provide the sendMail param for the backend to decide whether 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

Checklist

Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

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

Fix makes sense, curious how it broke though.

apps/files_sharing/lib/Controller/ShareAPIController.php Outdated Show resolved Hide resolved
@Fenn-CS Fenn-CS force-pushed the fix/48012/fix-share-email-send-mail-share branch from 6553268 to 8103393 Compare September 26, 2024 12:31
@Fenn-CS
Copy link
Contributor Author

Fenn-CS commented Sep 26, 2024

/backport to stable30

@Fenn-CS Fenn-CS force-pushed the fix/48012/fix-share-email-send-mail-share branch from 8103393 to 410854f Compare September 26, 2024 13:08
@Fenn-CS Fenn-CS force-pushed the fix/48012/fix-share-email-send-mail-share branch from 410854f to 3f7528b Compare September 26, 2024 13:52
@Fenn-CS Fenn-CS force-pushed the fix/48012/fix-share-email-send-mail-share branch 3 times, most recently from e2fa7e1 to 9f0eda3 Compare September 30, 2024 11:01
@provokateurin
Copy link
Member

Why rebase it so often?

@Fenn-CS
Copy link
Contributor Author

Fenn-CS commented Sep 30, 2024

Why rebase it so often?

Some tests that seem unrelated (cypress especially are failing consistently)...

Re-basing triggers a rerun, but also adds the latest updates on master in case something that broke the tests has been resolved. (Because a bunch of other PRs are failing tests too)...

Now taking a closer to see if something is indeed broken.

@Fenn-CS Fenn-CS force-pushed the fix/48012/fix-share-email-send-mail-share branch from 9f0eda3 to aab671f Compare October 7, 2024 06:57
Copy link
Contributor Author

@Fenn-CS Fenn-CS left a comment

Choose a reason for hiding this comment

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

This breaks "File Requests"

if (is_string($shareWith) && $shareType === IShare::TYPE_EMAIL) {
// If sending a mail have been requested, validate the mail address
if ($share->getMailSend() && !$this->mailer->validateMailAddress($shareWith)) {
throw new OCSNotFoundException($this->l->t('Please specify a valid email address'));
}
$share->setSharedWith($shareWith);
}

Why?

  • File requests are sent with an empty string for shareWith which the backend uses to check if a shareWith value is available (poorly so)
  • The file requests shareType is 4, which is mail share and I am not sure why that is.

@Fenn-CS Fenn-CS force-pushed the fix/48012/fix-share-email-send-mail-share branch from aab671f to 91a3ce1 Compare October 7, 2024 07:57
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 <[email protected]>
Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

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

Oops

"File request" is the new "File drop"... File drop was only possible on link shares.

The mails sent at the end of creating a file request is "sending the link to various emails"
it does should not turn the share type to email.

Signed-off-by: fenn-cs <[email protected]>
@Fenn-CS Fenn-CS force-pushed the fix/48012/fix-share-email-send-mail-share branch from 91a3ce1 to e089e40 Compare October 7, 2024 08:09
@Fenn-CS Fenn-CS disabled auto-merge October 7, 2024 08:11
shareType: sharingConfig.isMailShareAllowed ? ShareType.Email : ShareType.Link,
shareType: ShareType.Link,
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about this, @skjnldsv what was the idea behind this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I checked on talk and seems he is on holiday... However as far as I know "file drop" which is what was converted to "File request" was only possible on public link shares.

Leaving all this context as I won't be around as from tomorrow, however, this is an important fix. Mails not being sent out for mails shares is quite critical.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@susnux May also be able to help in the absence of Bath.

@Fenn-CS
Copy link
Contributor Author

Fenn-CS commented Oct 7, 2024

Add some more context on why the tests are failing and some related stuff with a plausible fix:

Share type setting can be changed (current solution), this seems to prevent the sendMail function for file requests as at now but since the links can be copied and shared, it's way better than breaking email shares on prod.

@@ -284,7 +284,7 @@ export default defineComponent({
const request = await axios.post<OCSResponse>(shareUrl, {
// Always create a file request, but without mail share
// permissions, only a share link will be created.
shareType: sharingConfig.isMailShareAllowed ? ShareType.Email : ShareType.Link,
shareType: ShareType.Link,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

File requests, should always be link share? The concept of mail shares is different.

shareType: sharingConfig.isMailShareAllowed ? ShareType.Email : ShareType.Link,
shareType: ShareType.Link,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I checked on talk and seems he is on holiday... However as far as I know "file drop" which is what was converted to "File request" was only possible on public link shares.

Leaving all this context as I won't be around as from tomorrow, however, this is an important fix. Mails not being sent out for mails shares is quite critical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🏗️ In progress
Development

Successfully merging this pull request may close these issues.

[Bug]: 30.0.0 share by email - no email is sent
3 participants