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.publish(channel_name, json.dumps(data)) except Exception as e: print(f"Failed to publish to channel {channel_name}: {e}")