-
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
base: enext
Are you sure you want to change the base?
fix(notifications): resolve email not sent for team invites #1201
Conversation
Reviewer's GuideThis PR extends the team invitation system to registered users by unifying and enhancing email flows across views, serializers, and models. It updates subjects and bodies with team and organizer context, introduces temporary invites for seamless email reuse, and aligns the API serializer and templates with the web UI behavior. Sequence diagram for enhanced team invitation email flowsequenceDiagram
actor Organizer
participant "TeamView (web/API)"
participant "TeamInvite Model"
participant "Mail Service"
participant "User (Registered)"
Organizer->>"TeamView (web/API)": Add member to team
"TeamView (web/API)"->>"TeamInvite Model": Create temporary invite (if registered)
"TeamInvite Model"->>"Mail Service": Send invitation email (with team & organizer info)
"Mail Service"->>"User (Registered)": Deliver invitation email
"TeamInvite Model"->>"TeamView (web/API)": Cleanup temporary invite
"TeamView (web/API)"->>"TeamView (web/API)": Add user to team
"TeamView (web/API)"->>Organizer: Success message
Class diagram for updated TeamInvite and email logicclassDiagram
class TeamInvite {
+email: str
+team: Team
+send()
+invitation_url
}
class Team {
+name: str
+organizer: Organizer
+members: User[]
+log_action()
}
class Organizer {
+name: str
+slug: str
}
class User {
+email: str
+pk: int
}
class QueuedMail {
+to: str
+subject: str
+body: str
}
TeamInvite --> Team
Team --> Organizer
Team --> User
TeamInvite --> QueuedMail : send() creates
QueuedMail --> User : to
TeamInvite --> User : email
TeamInvite : +send() now uses improved subject/body
TeamInvite : +temporary invites for registered users
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes - here's some feedback:
- Consider extracting the invitation email logic (subject formatting, template rendering, and mail dispatch) into a shared helper or service to reduce duplication and ensure consistency across views, models, and serializers.
- Standardize URL construction for invitation links (e.g. build_global_uri vs build_absolute_uri) in a central place so web UI and API flows stay in sync and future changes apply uniformly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the invitation email logic (subject formatting, template rendering, and mail dispatch) into a shared helper or service to reduce duplication and ensure consistency across views, models, and serializers.
- Standardize URL construction for invitation links (e.g. build_global_uri vs build_absolute_uri) in a central place so web UI and API flows stay in sync and future changes apply uniformly.
## Individual Comments
### Comment 1
<location> `app/eventyay/control/views/organizer_views/team_view.py:337` </location>
<code_context>
+ data={'email': user.email, 'user': user.pk},
)
- messages.success(self.request, _('The new member has been added to the team.'))
+ messages.success(self.request, _('The new member has been invited and added to the team.'))
return redirect(self.get_success_url())
</code_context>
<issue_to_address>
**suggestion:** Consider clarifying messaging for invitation and addition.
If the invitation email fails, the message may incorrectly state both actions succeeded. Please update the messaging to reflect the actual outcome.
</issue_to_address>
### Comment 2
<location> `app/eventyay/control/views/organizer_views/team_view.py:328-329` </location>
<code_context>
+ locale=self.request.LANGUAGE_CODE,
+ )
+ except SendMailException:
+ logger.warning("Failed to send invitation to existing member %s", user.email)
+
self.object.members.add(user)
</code_context>
<issue_to_address>
**suggestion:** Consider including exception details in the log for failed email sends.
Including exception details in the log will make it easier to identify why the email failed to send.
```suggestion
except SendMailException as exc:
logger.warning(
"Failed to send invitation to existing member %s: %s",
user.email,
exc,
)
```
</issue_to_address>
### Comment 3
<location> `app/eventyay/eventyay_common/views/team.py:226` </location>
<code_context>
+ locale=self.request.LANGUAGE_CODE,
+ )
+ except SendMailException:
+ logger.warning("Failed to send invitation email to existing user %s", user.email)
+
self.object.members.add(user)
</code_context>
<issue_to_address>
**suggestion:** Log message could include exception details for better traceability.
Consider passing exc_info=True to logger.warning to include the stack trace for easier debugging of email failures.
```suggestion
logger.warning("Failed to send invitation email to existing user %s", user.email, exc_info=True)
```
</issue_to_address>
### Comment 4
<location> `app/eventyay/api/serializers/organizer.py:231-233` </location>
<code_context>
+ locale=get_language_without_region(),
+ )
+ except SendMailException:
+ logger.warning("Failed to send invitation email to existing user: %s", user.email)
+
self.context['team'].members.add(user)
</code_context>
<issue_to_address>
**suggestion:** Consider logging exception details for failed invitation emails.
Logging the exception details will make it easier to diagnose why email sending failed.
```suggestion
except SendMailException as exc:
logger.warning(
"Failed to send invitation email to existing user: %s. Exception: %s",
user.email,
exc,
)
```
</issue_to_address>
### Comment 5
<location> `app/eventyay/control/templates/pretixcontrol/email/invitation.txt:14` </location>
<code_context>
-
Your event team
-{% endblocktrans %}
+{% endblocktranslate %}
\ No newline at end of file
</code_context>
<issue_to_address>
**issue (typo):** Possible typo: use of '{% endblocktranslate %}' instead of '{% endblocktrans %}'.
Please confirm if this is intentional; otherwise, change to '{% endblocktrans %}' for correct Django syntax.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
app/eventyay/control/templates/pretixcontrol/email/invitation.txt
Outdated
Show resolved
Hide resolved
Signed-off-by: Hemant M Mehta <[email protected]>
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.
Pull Request Overview
This pull request improves team invitation emails by making them more descriptive and consistent across the platform. The changes update email subjects and body text to include specific team and organizer names, and ensure that existing users receive notification emails when added to teams.
- Updated email subject lines to include team and organizer names for better clarity
- Added email notifications for existing users when they're added to teams
- Standardized invitation email template with clearer instructions
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| app/eventyay/eventyay_common/views/team.py | Updated email subject in _send_invite method and added email notification for existing users being added to teams with logger import |
| app/eventyay/control/views/organizer_views/team_view.py | Similar updates to email subjects and added email notifications for existing users with improved error handling |
| app/eventyay/control/templates/pretixcontrol/email/invitation.txt | Refined email template with clearer language and structured formatting |
| app/eventyay/base/models/organizer.py | Updated invitation email subject and body text in the send method to match new format |
| app/eventyay/api/serializers/organizer.py | Updated email subjects and added email notifications for existing users in API serializer |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mariobehling
left a comment
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.
Thanks for the PR! The title is close to our preferred format, but could be made a bit clearer and more readable.
Please use the format:
type(scope): short description
For example, instead of:
fix: email-notifications-team-invites
it would be better to write:
fix(notifications): resolve email not sent for team invites
This makes it easier to understand what’s being fixed at a glance and follows the conventional commit style we use for changelogs and automation.
💡 Why this is better
- Adds a scope (
notifications→ tells where the fix happens). - Uses normal words instead of hyphens — easier to read.
- Describes the issue or outcome clearly (“email not sent” instead of just “email-notifications”).
- Keeps consistency with other commits and changelogs.
|
Also, could you please add screenshots or a short video showing the fix in action? It helps reviewers confirm that the email notifications now work correctly for team invites. |
Will update it soon. |
Signed-off-by: Hemant M Mehta <[email protected]>
…/hemantmm/eventyay into email-notifications-team-invites
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.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/eventyay/control/templates/pretixcontrol/email/invitation.txt
Outdated
Show resolved
Hide resolved
…vitation Signed-off-by: Hemant M Mehta <[email protected]>
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.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Removed duplicate logging import and initialization.
Removed duplicate logging import and initialization.
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.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Hemant M Mehta <[email protected]>
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.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
| 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.')) |
Copilot
AI
Nov 6, 2025
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.
| messages.warning(self.request, _('The new member was added to the team, but the invitation email could not be sent.')) | |
| messages.warning(self.request, _('The new member will be added to the team, but the invitation email could not be sent.')) |
| 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.')) | ||
|
|
Copilot
AI
Nov 6, 2025
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.
There is trailing whitespace on this blank line. Remove the trailing whitespace to maintain code cleanliness.
closes: #1160
Add email notifications for registered users when they are invited to teams, ensuring all team members receive proper communication about their invitations.
✅ Changes Made:
1. Enhanced Team Invitation Email Flow
Files:
app/eventyay/control/views/organizer_views/team.pyapp/eventyay/control/models/organizer.py✅ Modified TeamInvite.send() to use a clearer, more professional email template.
✅ Updated email subject to include both team name and organizer name for clarity.
✅ Enhanced email body text to be appropriate for both registered and unregistered users.
✅ Implemented temporary invite creation for registered users to trigger email notifications.
✅ Added automatic cleanup of temporary invites after email dispatch.
2. Updated Team Member Addition Logic
Files:
app/eventyay/control/views/organizer_views/team.pyapp/eventyay/control/views/organizer_views/team_view.py✅ Modified post() method to send invitation emails to registered users before team addition.
✅ Created temporary invite objects for registered users to reuse the existing email system.
✅ Ensured cleanup of temporary invites to prevent database clutter.
✅ Maintained existing logging and audit trail functionality.
3. Improved Invitation Email Template
File:
app/eventyay/control/templates/pretixcontrol/email/invitation.txt✅ Updated template text to be clearer for all user types.
✅ Added instructions for both logged-in and new users.
✅ Improved tone and formatting for a professional appearance.
✅ Made the email template consistent across all invitation flows.
4. Updated API Serializer
File:
app/eventyay/api/serializers/organizer.py✅ Enhanced TeamInviteSerializer.create() to send emails to registered users.
✅ Improved email subject line for better readability.
✅ Ensured API endpoint feature parity with the web UI.
✅ Maintained backward compatibility with existing API consumers.
Summary:
This PR significantly improves team collaboration UX and transparency by ensuring all users — both registered and unregistered — receive email notifications when invited to teams.
Summary by Sourcery
Ensure all team invite flows send professional, branded email notifications to both registered and unregistered users, unify invitation templates across the codebase, and standardize temporary invite cleanup and logging.
New Features:
Enhancements: