intermittent commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping
|
||||
|
||||
from govoplan_core.core.modules import ModuleContext
|
||||
from govoplan_core.core.notifications import NotificationDispatchProvider, NotificationDispatchRequest
|
||||
from govoplan_notifications.backend.service import deliver_notification, deliver_pending, enqueue_dispatch_request, notification_response
|
||||
|
||||
|
||||
class SqlNotificationDispatchProvider(NotificationDispatchProvider):
|
||||
def __init__(self, context: ModuleContext) -> None:
|
||||
self._settings = context.settings
|
||||
|
||||
def enqueue_notification(
|
||||
self,
|
||||
session: object,
|
||||
request: NotificationDispatchRequest,
|
||||
*,
|
||||
enqueue_delivery: bool = True,
|
||||
) -> Mapping[str, object]:
|
||||
notification = enqueue_dispatch_request(session, request, enqueue_delivery=enqueue_delivery) # type: ignore[arg-type]
|
||||
return notification_response(notification)
|
||||
|
||||
def deliver_notification(self, session: object, *, notification_id: str) -> Mapping[str, object]:
|
||||
notification = deliver_notification(session, notification_id=notification_id, settings=self._settings) # type: ignore[arg-type]
|
||||
return notification_response(notification)
|
||||
|
||||
def deliver_pending(
|
||||
self,
|
||||
session: object,
|
||||
*,
|
||||
tenant_id: str | None = None,
|
||||
limit: int = 50,
|
||||
) -> Mapping[str, object]:
|
||||
return deliver_pending(session, tenant_id=tenant_id, limit=limit, settings=self._settings) # type: ignore[arg-type]
|
||||
|
||||
|
||||
def dispatch_capability(context: ModuleContext) -> SqlNotificationDispatchProvider:
|
||||
return SqlNotificationDispatchProvider(context)
|
||||
Reference in New Issue
Block a user