This commit is contained in:
2023-10-04 20:14:06 +03:00
parent 34b7d0021d
commit 1360692b57
6 changed files with 42 additions and 38 deletions

11
services/presence.py Normal file
View File

@@ -0,0 +1,11 @@
import json
from redis import redis
async def notify_message(message, chat_id: str):
channel_name = f"chat:{chat_id}"
data = {**message, "kind": "new_message"}
try:
await redis.execute_pubsub("PUBLISH", channel_name, json.dumps(data))
except Exception as e:
print(f"Failed to publish to channel {channel_name}: {e}")