actions-notify
All checks were successful
deploy / deploy (push) Successful in 1m9s

This commit is contained in:
2023-10-19 17:43:20 +03:00
parent d25b406b60
commit c6ad0414b0
2 changed files with 9 additions and 4 deletions

View File

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