inbox/services/presence.py
Untone 4ecdc08dfc
Some checks failed
deploy / deploy (push) Failing after 1m7s
format+fix
2023-11-14 21:25:55 +03:00

15 lines
462 B
Python

import json
from services.rediscache import redis
from validators.chat import Message
async def notify_message(message: Message, chat_id: str, action="create"):
channel_name = f"chat:{chat_id}"
data = {"payload": message, "action": action}
try:
await redis.publish(channel_name, json.dumps(data))
print(f"[services.presence] ok {data}")
except Exception as e:
print(f"Failed to publish to channel {channel_name}: {e}")