Skip to content

Commit

Permalink
Update user_notifications.py
Browse files Browse the repository at this point in the history
- Add failsafe if the user has no session
  • Loading branch information
tfnribeiro committed Dec 4, 2024
1 parent e93b463 commit a60aedc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions zeeguu/api/endpoints/user_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def get_notification_for_user():
# Is there new articles for the user?
articles = article_recommendations_for_user(user, 3)
last_activity_date_for_user = Session.get_last_use_for_user(user.id)
if last_activity_date_for_user is None:
# If the user has no sessions, assume they have not logged in.
last_activity_date_for_user = datetime.min

if any([a.published_time > last_activity_date_for_user for a in articles]):
user_notification = UserNotification.create_user_notification(
user.id, Notification.NEW_ARTICLE_AVAILABLE, db_session
Expand Down

0 comments on commit a60aedc

Please sign in to comment.