All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m14s
- Implemented push subscription API with tests for subscribing and unsubscribing users. - Created web push notification tests triggered by child actions. - Added digest scheduler to send email digests to users at 9 PM local time. - Developed utility functions for creating and validating digest action tokens. - Integrated web push sender to handle sending notifications to users. - Added service worker for handling push notifications in the frontend. - Created a push opt-in component for user notification preferences. - Implemented tests for the push opt-in component to ensure correct behavior. - Updated frontend services to manage push subscriptions and permissions.
30 lines
756 B
Python
30 lines
756 B
Python
from dataclasses import dataclass
|
|
from models.base import BaseModel
|
|
|
|
|
|
@dataclass
|
|
class PushSubscription(BaseModel):
|
|
user_id: str
|
|
endpoint: str
|
|
keys: dict # {'p256dh': str, 'auth': str}
|
|
|
|
@classmethod
|
|
def from_dict(cls, d: dict) -> 'PushSubscription':
|
|
return cls(
|
|
user_id=d.get('user_id'),
|
|
endpoint=d.get('endpoint'),
|
|
keys=d.get('keys', {}),
|
|
id=d.get('id'),
|
|
created_at=d.get('created_at'),
|
|
updated_at=d.get('updated_at'),
|
|
)
|
|
|
|
def to_dict(self) -> dict:
|
|
base = super().to_dict()
|
|
base.update({
|
|
'user_id': self.user_id,
|
|
'endpoint': self.endpoint,
|
|
'keys': self.keys,
|
|
})
|
|
return base
|