Add Notification Backend Protocol #24
@@ -16,9 +16,7 @@ logger = logging.getLogger(__name__)
|
|||||||
class NotificationBackend(Protocol):
|
class NotificationBackend(Protocol):
|
||||||
"""Backend-agnostic interface for notification storage."""
|
"""Backend-agnostic interface for notification storage."""
|
||||||
|
|
||||||
async def get_recent_notifications(
|
async def get_recent_notifications(self, phone_number: str) -> list[dict[str, Any]]:
|
||||||
self, phone_number: str
|
|
||||||
) -> list[dict[str, Any]]:
|
|
||||||
"""Return recent notifications for *phone_number*."""
|
"""Return recent notifications for *phone_number*."""
|
||||||
...
|
...
|
||||||
|
|
||||||
@@ -51,9 +49,7 @@ class FirestoreNotificationBackend:
|
|||||||
self._max_to_notify = max_to_notify
|
self._max_to_notify = max_to_notify
|
||||||
self._window_hours = window_hours
|
self._window_hours = window_hours
|
||||||
|
|
||||||
async def get_recent_notifications(
|
async def get_recent_notifications(self, phone_number: str) -> list[dict[str, Any]]:
|
||||||
self, phone_number: str
|
|
||||||
) -> list[dict[str, Any]]:
|
|
||||||
"""Get recent notifications for a user.
|
"""Get recent notifications for a user.
|
||||||
|
|
||||||
Retrieves notifications created within the configured time window,
|
Retrieves notifications created within the configured time window,
|
||||||
@@ -159,9 +155,7 @@ class RedisNotificationBackend:
|
|||||||
self._max_to_notify = max_to_notify
|
self._max_to_notify = max_to_notify
|
||||||
self._window_hours = window_hours
|
self._window_hours = window_hours
|
||||||
|
|
||||||
async def get_recent_notifications(
|
async def get_recent_notifications(self, phone_number: str) -> list[dict[str, Any]]:
|
||||||
self, phone_number: str
|
|
||||||
) -> list[dict[str, Any]]:
|
|
||||||
"""Get recent notifications for a user from Redis.
|
"""Get recent notifications for a user from Redis.
|
||||||
|
|
||||||
Reads from the ``notification:{phone}`` key, parses the JSON
|
Reads from the ``notification:{phone}`` key, parses the JSON
|
||||||
|
|||||||
Reference in New Issue
Block a user