-
Notifications
You must be signed in to change notification settings - Fork 131
fix(notifications): resolve email not sent for team invites #1201
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
Open
hemantmm
wants to merge
16
commits into
fossasia:enext
Choose a base branch
from
hemantmm:email-notifications-team-invites
base: enext
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a0de4b8
fix: email-notifications-team-invites
hemantmm d6c4ec0
fix: suggestion by sourcery
hemantmm 98749dc
Merge branch 'enext' into email-notifications-team-invites
mariobehling 7079351
fix: copilot suggestion
hemantmm 73a989c
Merge branch 'email-notifications-team-invites' of https://github.com…
hemantmm e9fad2e
fix: prevents conflicting success and warning messages during team in…
hemantmm de6d22f
Merge branch 'enext' into email-notifications-team-invites
hemantmm a6c6da4
fix: remove duplicate add members
hemantmm 0aa36bc
Fix logging of email send failure exception
hemantmm 94fc21f
fix: moved logging at top
hemantmm 47ca471
fix: moved logging at top
hemantmm e923e0c
fix: naming consistence
hemantmm 0e6a13b
fix: user reference in email invitation logic
hemantmm 91fb93d
fix: user reference in invitation email context
hemantmm f81c321
fix: revert back change
hemantmm 1ba6fd4
fix: duplication block
hemantmm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
app/eventyay/control/templates/pretixcontrol/email/invitation.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,14 @@ | ||
| {% load i18n %}{% blocktrans with url=url|safe %}Hello, | ||
| {% load i18n %}{% blocktrans with url=url|safe team=team organizer=organizer %}Hello, | ||
|
|
||
| you have been invited to the following event team | ||
| You have been invited to join the team "{{ team }}" for the organizer "{{ organizer }}". | ||
|
|
||
| Organizer: {{ organizer }} | ||
| Team: {{ team }} | ||
|
|
||
| If you want to join that team, just click on the following link: | ||
| Please click the following link to accept the invitation: | ||
| {{ url }} | ||
|
|
||
| If you are already logged in, you will be automatically added to the team. Otherwise, please log in or create an account to join. | ||
|
|
||
| If you do not want to join, you can safely ignore or delete this email. | ||
|
|
||
| Best regards, | ||
|
|
||
| Your event team | ||
| {% endblocktrans %} | ||
| {% endblocktrans %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,3 +1,7 @@ | ||||
| import logging | ||||
|
|
||||
| logger = logging.getLogger(__name__) | ||||
|
|
||||
| from django.contrib import messages | ||||
| from django.db import transaction | ||||
| from django.db.models import Count, ManyToManyField | ||||
|
|
@@ -173,10 +177,13 @@ def _send_invite(self, instance): | |||
| try: | ||||
| mail( | ||||
| instance.email, | ||||
| _('eventyay account invitation'), | ||||
| _('You have been invited to join the team "{team}" for "{organizer}"').format( | ||||
| team=instance.team.name, | ||||
| organizer=self.request.organizer.name, | ||||
| ), | ||||
| 'pretixcontrol/email/invitation.txt', | ||||
| { | ||||
| 'user': self, | ||||
| 'user': instance, | ||||
| 'organizer': self.request.organizer.name, | ||||
| 'team': instance.team.name, | ||||
| 'url': build_global_uri('eventyay_common:auth.invite', kwargs={'token': instance.token}), | ||||
|
|
@@ -304,16 +311,37 @@ def post(self, request, *args, **kwargs): | |||
| ) | ||||
| return self.get(request, *args, **kwargs) | ||||
|
|
||||
| # Send email to registered user and then add them | ||||
| try: | ||||
| mail( | ||||
| user.email, | ||||
| _('You have been invited to join the team "{team}" for "{organizer}"').format( | ||||
| team=self.object.name, | ||||
| organizer=self.request.organizer.name, | ||||
| ), | ||||
| 'pretixcontrol/email/invitation.txt', | ||||
| { | ||||
| 'user': user, | ||||
| 'organizer': self.request.organizer.name, | ||||
| 'team': self.object.name, | ||||
| 'url': build_global_uri('eventyay_common:organizer.team', kwargs={'organizer': self.request.organizer.slug, 'team': self.object.pk}), | ||||
| }, | ||||
| event=None, | ||||
| locale=self.request.LANGUAGE_CODE, | ||||
| ) | ||||
| except SendMailException: | ||||
| logger.warning("Failed to send invitation to existing member %s", user.email, exc_info=True) | ||||
| messages.warning(self.request, _('The new member was added to the team, but the invitation email could not be sent.')) | ||||
|
|
||||
hemantmm marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 tense in this error message is inconsistent. At the time this message is shown, the member has not been added yet (that happens on line 339). The message should say 'will be added' to match the actual timing, or the code should be restructured to add the member before sending the email.