Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements currency localization for email notifications and improves the notification system reliability. The changes ensure that subscription costs are displayed in the user's preferred currency and prevent duplicate notifications from being sent.
- Adds currency symbol mapping and localization for subscription costs in email notifications
- Improves notification system reliability by setting flags before sending emails and handling failures
- Prevents duplicate scheduler initialization
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/email.py | Adds currency localization, improves notification timing logic, and prevents scheduler duplication |
| README.md | Minor formatting change adding blank lines |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| # Set the notification sent flag BEFORE sending email to prevent race conditions | ||
| if not user.settings: | ||
| user_settings = UserSettings(user_id=user.id) | ||
| db.session.add(user_settings) |
There was a problem hiding this comment.
When user.settings is None, a new UserSettings object is created but user_settings variable still refers to the old object from line 252. This will cause an AttributeError when trying to set last_notification_sent. The code should assign the new object to user_settings and update the user's settings relationship.
| # Set the notification sent flag BEFORE sending email to prevent race conditions | |
| if not user.settings: | |
| user_settings = UserSettings(user_id=user.id) | |
| db.session.add(user_settings) | |
| db.session.add(user_settings) | |
| user.settings = user_settings # Ensure relationship is set |
| if user.settings: | ||
| db.session.refresh(user.settings) | ||
| user_settings = user.settings |
There was a problem hiding this comment.
The user_settings variable is only assigned when user.settings exists, but it's used unconditionally later in the code (lines 253, 285, 294). When user.settings is None, user_settings will be undefined, causing a NameError.
No description provided.