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

Add notification when mail send fail #1842

Merged
merged 11 commits into from Sep 22, 2021

Conversation

alexandrediasldev
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Sep 9, 2021

Codecov Report

Merging #1842 (11101a1) into master (2ba4ad0) will increase coverage by 0.18%.
The diff coverage is 76.25%.

❗ Current head 11101a1 differs from pull request most recent head a163668. Consider uploading reports for the commit a163668 to get more accurate results
Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
parsec/api/protocol/__init__.py 100.00% <ø> (ø)
parsec/core/gui/custom_dialogs.py 68.25% <33.33%> (-1.30%) ⬇️
parsec/core/cli/invitation.py 89.53% <66.66%> (+2.52%) ⬆️
parsec/core/gui/greet_device_widget.py 82.40% <66.66%> (-0.66%) ⬇️
parsec/core/gui/users_widget.py 83.65% <70.00%> (-0.66%) ⬇️
parsec/backend/invite.py 92.16% <88.00%> (-0.35%) ⬇️
parsec/core/logged_core.py 86.03% <88.88%> (-0.10%) ⬇️
parsec/api/protocol/invite.py 100.00% <100.00%> (ø)
parsec/core/gui/devices_widget.py 97.22% <100.00%> (+0.05%) ⬆️
parsec/backend/cli/run.py 69.95% <0.00%> (-2.86%) ⬇️
... and 30 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ba4ad0...a163668. Read the comment docs.

@alexandrediasldev alexandrediasldev linked an issue Sep 9, 2021 that may be closed by this pull request
@alexandrediasldev alexandrediasldev marked this pull request as ready for review September 9, 2021 14:35
@alexandrediasldev alexandrediasldev changed the title WIP: Add notification when mail send fail Add notification when mail send fail Sep 9, 2021
@@ -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 "
Copy link
Member

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"

@@ -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)
Copy link
Member

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

@@ -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")
Copy link
Member

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

raise InviteAlreadyUsedError()
elif rep["status"] != "ok":
raise InviteError(f"Backend error during step 1: {rep}")
_check_rep(rep, step_name="step 1")
Copy link
Member

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 Show resolved Hide resolved
@@ -78,6 +78,10 @@ class InvitationAlreadyMemberError(InvitationError):
pass


class InvitationEmailError(InvitationError):
Copy link
Member

Choose a reason for hiding this comment

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

should define InvitationEmailConfigError & InvitationEmailRecipientError

@@ -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)
Copy link
Member

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 ;-)

@@ -58,8 +58,19 @@ def get_obj_type(self, obj: Dict[str, object]) -> InvitationType:
return cast(InvitationType, obj["type"])


class InvitationEmailSentStatus(Enum):
SUCESS = "SUCESS"
Copy link
Contributor

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(
Copy link
Contributor

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)

if email_sent_status == InvitationEmailSentStatus.SUCESS:
show_info(self, _("TEXT_USER_INVITE_SUCCESS_email").format(email=email))
else:
show_info(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as previous

@alexandrediasldev
Copy link
Contributor Author

The window opened when an email can't be sent
Gui_parsec_email

if email_sent_status == InvitationEmailSentStatus.BAD_RECIPIENT:
show_info_copy_link(
self,
"Email bad recipient",
Copy link
Contributor

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.

@alexandrediasldev alexandrediasldev force-pushed the add-notification_when_mail_send_fail branch 3 times, most recently from b5456bb to a5b3107 Compare September 22, 2021 13:17
@alexandrediasldev alexandrediasldev force-pushed the add-notification_when_mail_send_fail branch from a5b3107 to a163668 Compare September 22, 2021 13:28
@alexandrediasldev alexandrediasldev merged commit a163668 into master Sep 22, 2021
@alexandrediasldev alexandrediasldev deleted the add-notification_when_mail_send_fail branch September 22, 2021 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return send mail status in invitation creation api
4 participants