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
Add notification when mail send fail #1842
Add notification when mail send fail #1842
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1842 +/- ##
==========================================
+ Coverage 87.38% 87.57% +0.18%
==========================================
Files 244 244
Lines 23636 24233 +597
==========================================
+ Hits 20654 21221 +567
- Misses 2982 3012 +30
Continue to review full report at Codecov.
|
parsec/core/gui/tr/parsec_en.po
Outdated
@@ -1851,6 +1858,10 @@ msgstr "This user is already a member of this organization." | |||
msgid "TEXT_INVITE_USER_INVITE_ERROR" | |||
msgstr "Could not invite the user." | |||
|
|||
msgid "TEXT_INVITE_USER_EMAIL_NOT_SENT_directlink" | |||
msgstr "Could not send the invite by mail to the user, here is the link the " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the invitation"
"the user needs"
parsec/core/logged_core.py
Outdated
@@ -281,11 +283,13 @@ async def new_device_invitation(self, send_email: bool) -> BackendInvitationAddr | |||
) | |||
if rep["status"] != "ok": | |||
raise BackendConnectionError(f"Backend error: {rep}") | |||
email_sent = not ("email_sent" in rep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should return a tuple containing the addr AND the email send result
parsec/core/types/backend_address.py
Outdated
@@ -438,19 +438,21 @@ class BackendInvitationAddr(BackendActionAddr): | |||
(e.g. ``parsec://parsec.example.com/my_org?action=claim_user&token=3a50b191122b480ebb113b10216ef343``) | |||
""" | |||
|
|||
__slots__ = ("_organization_id", "_invitation_type", "_token") | |||
__slots__ = ("_organization_id", "_invitation_type", "_token", "_email_sent") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to modify addr given it is not related to the success of email sending operation
parsec/core/invite/greeter.py
Outdated
raise InviteAlreadyUsedError() | ||
elif rep["status"] != "ok": | ||
raise InviteError(f"Backend error during step 1: {rep}") | ||
_check_rep(rep, step_name="step 1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep this refacto for another PR, as the current one should not have to deal with greeter/claimer (but only with invitation creation)
parsec/backend/invite.py
Outdated
@@ -78,6 +78,10 @@ class InvitationAlreadyMemberError(InvitationError): | |||
pass | |||
|
|||
|
|||
class InvitationEmailError(InvitationError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should define InvitationEmailConfigError
& InvitationEmailRecipientError
parsec/api/protocol/invite.py
Outdated
@@ -60,6 +60,7 @@ def get_obj_type(self, obj: Dict[str, object]) -> InvitationType: | |||
|
|||
class InviteNewRepSchema(BaseRepSchema): | |||
token = fields.UUID(required=True) | |||
email_sent = fields.Boolean(required=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be an enum with different possible outcomes:
- success
- not_available
- bad_recipient
with required=False
& allow_none=False
and a nice comment about the introduction of this new field ;-)
parsec/api/protocol/invite.py
Outdated
@@ -58,8 +58,19 @@ def get_obj_type(self, obj: Dict[str, object]) -> InvitationType: | |||
return cast(InvitationType, obj["type"]) | |||
|
|||
|
|||
class InvitationEmailSentStatus(Enum): | |||
SUCESS = "SUCESS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here : SUCCESS
self.button_send_email.setText(_("TEXT_GREET_DEVICE_EMAIL_SENT")) | ||
self.button_send_email.setDisabled(True) | ||
else: | ||
show_info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to tell in show_info
the error type (recipient or sender's fault)
parsec/core/gui/users_widget.py
Outdated
if email_sent_status == InvitationEmailSentStatus.SUCESS: | ||
show_info(self, _("TEXT_USER_INVITE_SUCCESS_email").format(email=email)) | ||
else: | ||
show_info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as previous
if email_sent_status == InvitationEmailSentStatus.BAD_RECIPIENT: | ||
show_info_copy_link( | ||
self, | ||
"Email bad recipient", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No hard-coded strings, it should be translated (same thing for all the other ones).
In case you didn't know, you can use
python setup.py extract_translations
to add the all the translations to the .po file (instead of doing it manually), makes it easier to find the missing ones.
b5456bb
to
a5b3107
Compare
…corresponding test
…vitationEmailRecipientError
a5b3107
to
a163668
Compare
No description provided.