| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- # app/services/notification_service.py
- import uuid
- from typing import List, Dict, Any
- from redis.asyncio import Redis
- from app.utils.redis_utils import redis_qpush, redis_qpop
- class NotificationService:
- @staticmethod
- async def post_email(
- redis_client: Redis,
- receiver: str,
- template_id: str,
- payload: Dict[str, Any]
- ):
- notification_payload = {
- "notification_id": f"nid_{uuid.uuid4().hex}",
- "channel": "email",
- "template_id": template_id,
- "receiver": receiver,
- "payload": payload
- }
-
- await redis_qpush(
- redis_client,
- "vas_notification_queue",
- notification_payload
- )
-
- @staticmethod
- async def post_wechat(
- redis_client: Redis,
- template_id: str,
- payload: Dict[str, Any]
- ):
- notification_payload = {
- "notification_id": f"nid_{uuid.uuid4().hex}",
- "channel": "wechat",
- "template_id": template_id,
- "payload": payload
- }
-
- await redis_qpush(
- redis_client,
- "vas_notification_queue",
- notification_payload
- )
-
|