Conversation
Slack URL Was hardcoded. Now you have slack url as an argument
Created reminder endpoint
There was a problem hiding this comment.
Pull Request Overview
This pull request adds reminder email functionality for event participants and improves the Slack invitation process. The changes enable event organizers to send reminder emails to accepted hackers who haven't confirmed attendance, and allow dynamic Slack workspace URLs for invitations.
- New
/send_reminder_mails/endpoint to trigger reminder emails for unconfirmed hackers - Slack invitation endpoint converted from GET to POST with dynamic URL parameter
- New
EVENT_HACKER_REMINDERemail template for reminder communications
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/impl/Mail/internall_templates.py | Added EVENT_HACKER_REMINDER enum value for the new reminder email template |
| src/impl/Event/service.py | Implemented send_reminder_mails method with token generation and days-until-event calculation; updated send_slack_mail to accept dynamic URL and send emails immediately |
| src/impl/Event/router_v1.py | Changed Slack endpoint from GET to POST with slackUrl parameter; added new POST endpoint for sending reminder emails |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| @BaseService.needs_service(MailClient) | ||
| def send_slack_mail(self, event_id: int, data: BaseToken): | ||
| def send_slack_mail(self, event_id: int, slackUrl: str, data: BaseToken): |
There was a problem hiding this comment.
Missing input validation: The slackUrl parameter is not validated before use. Consider adding validation to ensure it's a valid URL format and not empty. This is especially important since this URL will be sent to users via email and could be a security concern if arbitrary strings are accepted.
| def send_slack_mail(event_id: int, token: BaseToken = Depends(JWTBearer())): | ||
| event_service.send_slack_mail(event_id, token) | ||
| @router.post("/{event_id}/send_slack_mail/") | ||
| def send_slack_mail(event_id: int, slackUrl: str, token: BaseToken = Depends(JWTBearer())): |
There was a problem hiding this comment.
The slackUrl parameter should be part of a request body model rather than a query parameter. For POST endpoints, it's a best practice to use request body objects (Pydantic models) for data parameters. Consider creating a schema like SlackMailRequest with a slack_url field and use it as the body parameter.
src/impl/Event/service.py
Outdated
| except Exception: | ||
| days_left = 0 |
There was a problem hiding this comment.
The broad exception handler except Exception: silently swallows all errors when computing days left. This could hide important issues like attribute errors or timezone problems. Consider either handling specific exceptions (e.g., TypeError, AttributeError) or at minimum logging the exception before setting days_left = 0.
src/impl/Event/service.py
Outdated
| for hacker in hackers: | ||
| reg = ( | ||
| db.session.query(HackerRegistration) | ||
| .filter( | ||
| HackerRegistration.user_id == hacker.id, | ||
| HackerRegistration.event_id == event.id, | ||
| ) | ||
| .first() | ||
| ) |
There was a problem hiding this comment.
Potential N+1 query problem: For each accepted hacker, a separate database query is executed to fetch the HackerRegistration. This could be inefficient for events with many accepted hackers. Consider using a single query with a join or eager loading to fetch all registrations at once, e.g., using joinedload or querying all registrations upfront and creating a lookup dictionary.
| for hacker in hackers: | |
| reg = ( | |
| db.session.query(HackerRegistration) | |
| .filter( | |
| HackerRegistration.user_id == hacker.id, | |
| HackerRegistration.event_id == event.id, | |
| ) | |
| .first() | |
| ) | |
| hacker_ids = [h.id for h in hackers] | |
| registrations = ( | |
| db.session.query(HackerRegistration) | |
| .filter( | |
| HackerRegistration.user_id.in_(hacker_ids), | |
| HackerRegistration.event_id == event.id, | |
| ) | |
| .all() | |
| ) | |
| reg_by_user_id = {reg.user_id: reg for reg in registrations} | |
| for hacker in hackers: | |
| reg = reg_by_user_id.get(hacker.id) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request adds new functionality for sending reminder emails to event participants and improves the process for sending Slack invitations. The main changes include introducing a new endpoint and service method for sending reminder emails to accepted hackers, updating the Slack invitation endpoint to accept a dynamic URL, and adding a new internal mail template for reminders.
New reminder email functionality:
/{event_id}/send_reminder_mails/inrouter_v1.pyto trigger sending reminder emails to all accepted hackers of an event.send_reminder_mailsservice method inEvent/service.pyto send reminder emails only to hackers who have not yet confirmed attendance, generating a confirmation token if needed and including days left until the event.EVENT_HACKER_REMINDERinMail/internall_templates.pyfor the reminder emails.Slack invitation improvements:
slackUrlparameter, allowing dynamic Slack invite links to be sent.send_slack_mailservice method to accept theslackUrlparameter and use it in the invitation email. [1] [2]