Skip to content

Commit

Permalink
Send adapter import string to store on notification
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobessa committed Dec 21, 2024
1 parent 86356fb commit 49f0545
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
6 changes: 5 additions & 1 deletion vintasend/services/notification_backends/asyncio_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ async def get_user_email_from_notification(

@abstractmethod
async def store_context_used(
self, notification_id: int | str | uuid.UUID, context: dict, lock: asyncio.Lock | None = None
self,
notification_id: int | str | uuid.UUID,
context: dict,
adapter_import_str: str,
lock: asyncio.Lock | None = None,
) -> None:
...

7 changes: 6 additions & 1 deletion vintasend/services/notification_backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,10 @@ def get_user_email_from_notification(self, notification_id: int | str | uuid.UUI
raise NotImplementedError

@abstractmethod
def store_context_used(self, notification_id: int | str | uuid.UUID, context: dict) -> None:
def store_context_used(
self,
notification_id: int | str | uuid.UUID,
context: dict,
adapter_import_str: str,
) -> None:
raise NotImplementedError
19 changes: 16 additions & 3 deletions vintasend/services/notification_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,11 @@ def send(self, notification: Notification) -> None:
raise e
try:
self.notification_backend.mark_pending_as_sent(notification.id)
self.notification_backend.store_context_used(notification.id, context)
self.notification_backend.store_context_used(
notification.id,
context,
adapter.adapter_import_str,
)
except NotificationUpdateError as e:
raise NotificationMarkSentError("Failed to mark notification as sent") from e

Expand Down Expand Up @@ -532,7 +536,11 @@ def delayed_send(self, notification_dict: NotificationDict, context_dict: dict)
raise e
try:
self.notification_backend.mark_pending_as_sent(notification_dict["id"])
self.notification_backend.store_context_used(notification_dict["id"], context_dict)
self.notification_backend.store_context_used(
notification_dict["id"],
context_dict,
async_adapter.adapter_import_str,
)
except NotificationUpdateError as e:
raise NotificationMarkSentError("Failed to mark notification as sent") from e

Expand Down Expand Up @@ -651,7 +659,12 @@ async def send(self, notification: Notification, lock: asyncio.Lock | None = Non
raise e
try:
await self.notification_backend.mark_pending_as_sent(notification.id, lock)
await self.notification_backend.store_context_used(notification.id, context, lock)
await self.notification_backend.store_context_used(
notification.id,
context,
adapter.adapter_import_str,
lock
)
except NotificationUpdateError as e:
raise NotificationMarkSentError("Failed to mark notification as sent") from e
return None
Expand Down

0 comments on commit 49f0545

Please sign in to comment.