Add push notification functionality with tests and digest scheduler
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m14s
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.
This commit is contained in:
18
backend/db/digest_action_tokens.py
Normal file
18
backend/db/digest_action_tokens.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from tinydb import Query
|
||||
from db.db import digest_action_tokens_db
|
||||
from models.digest_action_token import DigestActionToken
|
||||
|
||||
|
||||
def insert_token(token: DigestActionToken) -> None:
|
||||
digest_action_tokens_db.insert(token.to_dict())
|
||||
|
||||
|
||||
def get_token_by_id(token_id: str) -> DigestActionToken | None:
|
||||
Q = Query()
|
||||
result = digest_action_tokens_db.get(Q.id == token_id)
|
||||
return DigestActionToken.from_dict(result) if result else None
|
||||
|
||||
|
||||
def mark_token_used(token_id: str) -> None:
|
||||
Q = Query()
|
||||
digest_action_tokens_db.update({'used': True}, Q.id == token_id)
|
||||
Reference in New Issue
Block a user