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

Check mail for missing attachment #6172

Merged
merged 1 commit into from
Oct 2, 2023
Merged

Conversation

max65482
Copy link
Contributor

This PR sketches a solution to awkward problems that I sometimes encounter before my first coffee: I misspell the name of the email recipient in the salutation (Dear XXX) or I mention an attachment, but forget to attach something.

Before sending an email, the app now searches for these accidents and warns the user.

If there is interest, I can refactor and give the code presentable quality. Otherwise, feel free to close this.

grafik

grafik

@welcome
Copy link

welcome bot commented Mar 31, 2022

Thanks for opening your first pull request in this repository! ✌️

@max65482 max65482 marked this pull request as draft March 31, 2022 19:12
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.

I like the feature, e.g. to warn for the possibly missing attachments.

Translation will be tricky, because there are one or multiple words in each language (and variants of them, think: singular vs plural). For HTML messages we need to saveguard that a translation doesn't match a HTML tag or attribute, because that would show false warnings.

The editor is based on CKEditor. We could check if there is anything existing, like a module built in or a third party module that we could add.

if (warnings !== "") {
warnings += ", "
}
warnings += "missing attachments"
Copy link
Member

Choose a reason for hiding this comment

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

this needs translation

Copy link
Member

Choose a reason for hiding this comment

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

@max65482 could you address this please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will be looking at this PR again soon (with warnings only about missing attachments, not salutations for now).
(If you are referring to the translation: At this time I feel unable to address this.)

@max65482
Copy link
Contributor Author

Translation will be tricky, because there are one or multiple words in each language (and variants of them, think: singular vs plural).

For simplicity, we should assume that the singular word is always part of the plural word.

For HTML messages we need to saveguard that a translation doesn't match a HTML tag or attribute, because that would show false warnings.

toPlain(data.body) should be enough to get rid of HTML tags etc., right?

@max65482
Copy link
Contributor Author

@ChristophWurst Can you give it another look?

@max65482 max65482 marked this pull request as ready for review January 19, 2023 21:26
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.

Looks good otherwise codewise

Are users able to send despite the error?

break
}
if (line.includes(wordAttachment) || line.includes(wordAttached)) {
attachmentMissing = true
Copy link
Member

Choose a reason for hiding this comment

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

remove the variable and just throw here

Comment on lines 138 to 140
var lines = toPlain(data.body).value.toLowerCase().split('\n')
var wordAttachment = t('mail', 'attachment').toLowerCase()
var wordAttached = t('mail', 'attached').toLowerCase()
Copy link
Member

Choose a reason for hiding this comment

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

replace var with const

@max65482
Copy link
Contributor Author

@ChristophWurst I rebased and stumbled across changes that came with this commit.

<EmptyContent v-if="error"
:title="t('mail', 'Error sending your message')"
class="centered-content"
role="alert">
<p>{{ error }}</p>
<template #action>
<ButtonVue type="tertiary" @click="state = STATES.EDITING">
{{ t('mail', 'Go back') }}
</ButtonVue>
<ButtonVue type="tertiary" @click="onSend">
{{ t('mail', 'Retry') }}
</ButtonVue>
</template>
</EmptyContent>
<Loading v-else-if="uploadingAttachments" :hint="t('mail', 'Uploading attachments …')" role="alert" />
<Loading v-else-if="sending"
:hint="t('mail', 'Sending …')"
role="alert" />
<EmptyContent v-else-if="warning" :title="t('mail', 'Warning sending your message')" role="alert">
<p>{{ warning }}</p>
<ButtonVue type="tertiary" @click="state = STATES.EDITING">
{{ t('mail', 'Go back') }}
</ButtonVue>
<ButtonVue type="tertiary" @click="onForceSend">
{{ t('mail', 'Send anyway') }}
</ButtonVue>
</EmptyContent>

In particular, onForceSend does not exist in this context. Could you help out?

@ChristophWurst
Copy link
Member

We had to move some code around for a new feature. Sorry for the confusion.

@max65482
Copy link
Contributor Author

I still cannot find onForceSend in this modal although it is referenced. This method would be required for the extension. In my understanding this is technical debt.
As I don't feel proficient enough to fix this on my own, I opened #8617. I will continue once this is fixed.

@max65482 max65482 changed the title Check mail for common mistakes before sending Check mail for missing attachment Jul 17, 2023
@max65482
Copy link
Contributor Author

Thanks to #8625 onForceSend exists now.

Now I stumbled across another issue. NewMessageModal seems to use states that aren't defined in the modal:

@click="state = STATES.EDITING">

Can someone help out? @GretaD?

@GretaD
Copy link
Contributor

GretaD commented Jul 19, 2023

Thanks to #8625 onForceSend exists now.

Now I stumbled across another issue. NewMessageModal seems to use states that aren't defined in the modal:

@click="state = STATES.EDITING">

Can someone help out? @GretaD?

i am having a look if its a leftover or needs to be declared

@GretaD
Copy link
Contributor

GretaD commented Jul 27, 2023

Thanks to #8625 onForceSend exists now.

Now I stumbled across another issue. NewMessageModal seems to use states that aren't defined in the modal:

@click="state = STATES.EDITING">

Can someone help out? @GretaD?

the pr to remove the leftovers is merged. You can continue now :)

@max65482 max65482 force-pushed the feat_mail_checker branch from ed74ceb to ca3b68c Compare July 31, 2023 11:20
@max65482 max65482 marked this pull request as ready for review July 31, 2023 11:22
@max65482 max65482 requested a review from ChristophWurst July 31, 2023 11:22
@max65482
Copy link
Contributor Author

Thanks @GretaD!
PR is ready for review now.

@GretaD
Copy link
Contributor

GretaD commented Aug 7, 2023

it works as described, but instead of warning it shows an error. I remember seeing a ticket related to implementing warning, but couldnt find it
Screenshot from 2023-08-07 16-33-07

@max65482
Copy link
Contributor Author

max65482 commented Aug 8, 2023

Yes, as of now there is no distinction between error and warning. E.g. ManyRecipientsError would also show up as an error although it is more of hint. I agree that (ideally) there would be a separate mechanism for warnings.

Speaking about ManyRecipientsError, this might be an opportunity for fixing #6461 as well.

@GretaD
Copy link
Contributor

GretaD commented Aug 9, 2023

Yes, as of now there is no distinction between error and warning. E.g. ManyRecipientsError would also show up as an error although it is more of hint. I agree that (ideally) there would be a separate mechanism for warnings.

Speaking about ManyRecipientsError, this might be an opportunity for fixing #6461 as well.

this is the ticket that i was looking for. When Anna is back from vacation, im gonna bring this up

Copy link
Contributor

@GretaD GretaD left a comment

Choose a reason for hiding this comment

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

we can get this in, when we have the warning part done, we can change this into a warning instead of an error.

@@ -362,7 +390,7 @@ export default {
}
},
async onForceSend() {
await this.onSend(null, true)
await this.onSend(this.cookedComposerData, true)

This comment was marked as resolved.

This comment was marked as resolved.

@GretaD GretaD force-pushed the feat_mail_checker branch 2 times, most recently from fd9e7a7 to e2f9310 Compare September 29, 2023 13:54
@GretaD
Copy link
Contributor

GretaD commented Sep 29, 2023

after rebasing, this pr has issues, having a look why

Signed-off-by: Maximilian Martin <maximilian_martin@gmx.de>
@GretaD
Copy link
Contributor

GretaD commented Sep 29, 2023

running npm run lint:fix changed a lot of things. I hope i didnt broke something..now looks good

@GretaD GretaD merged commit 4298efc into nextcloud:main Oct 2, 2023
28 checks passed
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.

4 participants