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(outbox): catch failed SENT copy operation #9364

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

miaulalala
Copy link
Contributor

@miaulalala miaulalala commented Feb 21, 2024

Fixes #8435

Sending a mail could fail at any point in the send operation.

This PR aims to introduce clear status codes that allow for the send code to redo the operations that fail.

Everything except the actual IMAP send and copying the sent message to the SENT mailbox are idempotent.

@ChristophWurst ChristophWurst removed this from the v3.6.0 milestone Feb 28, 2024
@ChristophWurst
Copy link
Member

Unassigning from the milestone because this is not a must have. We can merge at any time and backport.

@miaulalala miaulalala marked this pull request as ready for review March 13, 2024 18:09
lib/Db/LocalMessage.php Outdated Show resolved Hide resolved
lib/Db/LocalMessage.php Outdated Show resolved Hide resolved
lib/Service/AntiAbuseService.php Outdated Show resolved Hide resolved
ChristophWurst

This comment was marked as outdated.

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Testing the case where CopySentMessageHandler fails: An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'raw' in 'field list' resulting in a HTTP500.

\OCP\AppFramework\Db\QBMapper::update is called with a LocalMessage

lib/Send/CopySentMessageHandler.php Outdated Show resolved Hide resolved
lib/Send/AHandler.php Outdated Show resolved Hide resolved
lib/Send/AntiAbuseHandler.php Outdated Show resolved Hide resolved
@ChristophWurst
Copy link
Member

\OCA\Mail\Controller\OutboxController::send must not return a HTTP200 when the chain fails. Right now the outbox message disappears from the outbox until a page reload, then the message is back.

@miaulalala
Copy link
Contributor Author

Testing the case where CopySentMessageHandler fails: An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'raw' in 'field list' resulting in a HTTP500.

\OCP\AppFramework\Db\QBMapper::update is called with a LocalMessage

Did you run the migration again? The "raw" field was introduced later.

@ChristophWurst
Copy link
Member

Raw is a column for local messages, not messages

@miaulalala miaulalala changed the title fix: catch failed SENT copy operation fix(outbox): catch failed SENT copy operation Mar 19, 2024
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Successful case works ✔️
An error in \OCA\Mail\Send\CopySentMessageHandler::process shows an error toast in the front-end ✔️
After the error the message vanishes from the outbox. From a user perspective it's simply gone

This is bad because the user will not find the message anywhere, making it look like it was never sent. Messages that failed to copy on IMAP but were sent should show in a transparent matter. As in, they stay in the outbox, visible, but read-only.

@ChristophWurst
Copy link
Member

ChristophWurst commented Mar 25, 2024

  • BUG: Message that failed to copy to IMAP shows in inbox with no further information. The message is clickable, but clicking results in a silent error. Console:

image

  • BUG: Send now does not work. I would expect to be able to manually retry/resume the sending process if it failed.

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Failed messages appear in the outbox ✔️
Retried messages are processed by the worker job and finally disappear from the outbox ✔️

Frontend handling can be improved ^

@miaulalala
Copy link
Contributor Author

Added a bit of shiny for the frontend

@ChristophWurst
Copy link
Member

Clicking messages stuck in the outbox no longer causes an error ✔️

But the UX is strange. The message appears clickable but nothing happens on click. The cursor should be the default one, not pointer.

With the latest UI changes the ability to force resend/retry was lost. It's only possible to delete stuck outbox messages or wait for the cron job to retry/resend.

@miaulalala
Copy link
Contributor Author

miaulalala commented Mar 27, 2024

Clicking messages stuck in the outbox no longer causes an error ✔️

But the UX is strange. The message appears clickable but nothing happens on click. The cursor should be the default one, not pointer.

With the latest UI changes the ability to force resend/retry was lost. It's only possible to delete stuck outbox messages or wait for the cron job to retry/resend.

We can use an NcListItemIcon instead of the NcListItem that does the rendering for the pointer,. Since NcListItem it also does the rendering for the status message, it's kinda weird though.

There's no prop that I can see that will allow the pointer to be set for the NcListItem component. The styles don't really work well together for the NcListItem and NcListItemIcon (first one is NcListItemIcon, second and third are NcListItem):

image

I changed the actions button to include the "send" action again for messages not copied to the sent mailbox but labeled it 'Copy to "Sent" mailbox'

@miaulalala
Copy link
Contributor Author

On further thinking I'd actually like to see the right panel being used. We could treat outbox messages like "Sent" messages and display them like a regular email, with an "Edit" button for anything that's not been sent yet. Would get rid of the awkward unused message content space and allow for a preview of any sent messages. cc @nimishavijay

For now, I'd leave the NcListItem even though it's a tiny bit awkward with the non- action on click unless a frontender wants to take a real shot at refactoring the whole thing to render better than my awkward try with the NcListItemIcon.

@ChristophWurst
Copy link
Member

Then we leave the cursor pointer or use :v-deep to overwrite it

Once force send is back, conflicts are resolved and CI is green we can merge this :shipit:

@miaulalala
Copy link
Contributor Author

Then we leave the cursor pointer or use :v-deep to overwrite it

Once force send is back, conflicts are resolved and CI is green we can merge this :shipit:

force send is a different PR, no?

@ChristophWurst
Copy link
Member

With the latest UI changes the ability to force resend/retry was lost. It's only possible to delete stuck outbox messages or wait for the cron job to retry/resend.

This is what I mean by "force" resend. When storing on IMAP fails temporarily I want to be able to retry.

@ChristophWurst
Copy link
Member

image

@ChristophWurst
Copy link
Member

When I retry and it still fails

image

@miaulalala miaulalala force-pushed the fix/8435/add-flag-for-moved-to-sent branch from d00de44 to c152d0b Compare April 3, 2024 15:43
@ChristophWurst
Copy link
Member

Related tests fail

@miaulalala miaulalala force-pushed the fix/8435/add-flag-for-moved-to-sent branch from fb74554 to 3e84000 Compare April 4, 2024 10:41
@ChristophWurst ChristophWurst self-requested a review April 4, 2024 10:56
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Tested & works

lib/Migration/Version3600Date20240220134813.php Outdated Show resolved Hide resolved
lib/Service/AntiSpamService.php Outdated Show resolved Hide resolved
lib/Service/AntiSpamService.php Outdated Show resolved Hide resolved
lib/Service/TransmissionService.php Outdated Show resolved Hide resolved
src/components/NewMessageModal.vue Show resolved Hide resolved
src/components/OutboxMessageListItem.vue Show resolved Hide resolved
src/components/OutboxMessageListItem.vue Outdated Show resolved Hide resolved
tests/Unit/Send/AntiAbuseHandlerTest.php Outdated Show resolved Hide resolved
tests/Unit/Send/SentMailboxHandlerTest.php Outdated Show resolved Hide resolved
and try resending failed messages at POF

Signed-off-by: Anna Larch <anna@nextcloud.com>
@miaulalala miaulalala force-pushed the fix/8435/add-flag-for-moved-to-sent branch from 554d613 to 7c59040 Compare April 9, 2024 11:42
@miaulalala
Copy link
Contributor Author

/backport to stable3.6

@miaulalala miaulalala merged commit 3fcf1db into main Apr 9, 2024
35 checks passed
@miaulalala miaulalala deleted the fix/8435/add-flag-for-moved-to-sent branch April 9, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mail both "Sent" and stuck in Outbox
2 participants