Skip to content

Reminder endpoint#332

Merged
Big-Lolo merged 6 commits intointegrationfrom
reminder-endpoint
Nov 17, 2025
Merged

Reminder endpoint#332
Big-Lolo merged 6 commits intointegrationfrom
reminder-endpoint

Conversation

@Big-Lolo
Copy link
Member

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:

  • Added a new POST endpoint /{event_id}/send_reminder_mails/ in router_v1.py to trigger sending reminder emails to all accepted hackers of an event.
  • Implemented send_reminder_mails service method in Event/service.py to 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.
  • Introduced a new internal mail template EVENT_HACKER_REMINDER in Mail/internall_templates.py for the reminder emails.

Slack invitation improvements:

  • Changed the Slack invitation endpoint from GET to POST and added a slackUrl parameter, allowing dynamic Slack invite links to be sent.
  • Updated the send_slack_mail service method to accept the slackUrl parameter and use it in the invitation email. [1] [2]

Slack URL Was hardcoded. Now you have slack url as an argument
Created reminder endpoint
Copy link
Contributor

Copilot AI left a 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 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_REMINDER email 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):
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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())):
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +1040 to +1041
except Exception:
days_left = 0
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +1019 to +1027
for hacker in hackers:
reg = (
db.session.query(HackerRegistration)
.filter(
HackerRegistration.user_id == hacker.id,
HackerRegistration.event_id == event.id,
)
.first()
)
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Big-Lolo Big-Lolo merged commit b490a3c into integration Nov 17, 2025
3 of 4 checks passed
@tonlls tonlls deleted the reminder-endpoint branch February 3, 2026 21:53
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.

2 participants