Skip to content

Commit

Permalink
Adds get_user_email_from_notification to the base backend
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobessa committed Nov 9, 2024
1 parent 31a6651 commit 0f22dfd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vintasend/services/notification_backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,7 @@ def filter_in_app_unread_notifications(
self, user_id: int | str | uuid.UUID, page: int, page_size: int
) -> Iterable["Notification"]:
raise NotImplementedError

@abstractmethod
def get_user_email_from_notification(self, notification_id: int | str | uuid.UUID) -> str:
raise NotImplementedError
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ def __paginate_notifications(self, notifications: list[Notification], page: int,
# page is 1-indexed
return notifications[((page - 1) * page_size) : ((page - 1) * page_size) + page_size]

def get_user_email_from_notification(self, notification_id: int | str | uuid.UUID) -> str:
notification = self.get_notification(notification_id)
return notification.context_kwargs.get("email", "testemail@example.com")


class InvalidBackend():
def __init__(self, *_args, **_kwargs):
Expand Down

0 comments on commit 0f22dfd

Please sign in to comment.