precommit-setup

This commit is contained in:
2024-01-25 12:25:52 +03:00
parent 8435c8e6b5
commit 152d5a4e99
14 changed files with 320 additions and 309 deletions

View File

@@ -4,21 +4,21 @@ from models.chat import ChatUpdate, Message
from services.rediscache import redis
async def notify_message(message: Message, action="create"):
async def notify_message(message: Message, action='create'):
channel_name = f"message:{message['chat_id']}"
data = {"payload": message, "action": action}
data = {'payload': message, 'action': action}
try:
await redis.publish(channel_name, json.dumps(data))
print(f"[services.presence] ok {data}")
print(f'[services.presence] ok {data}')
except Exception as e:
print(f"Failed to publish to channel {channel_name}: {e}")
print(f'Failed to publish to channel {channel_name}: {e}')
async def notify_chat(chat: ChatUpdate, member_id: int, action="create"):
channel_name = f"chat:{member_id}"
data = {"payload": chat, "action": action}
async def notify_chat(chat: ChatUpdate, member_id: int, action='create'):
channel_name = f'chat:{member_id}'
data = {'payload': chat, 'action': action}
try:
await redis.publish(channel_name, json.dumps(data))
print(f"[services.presence] ok {data}")
print(f'[services.presence] ok {data}')
except Exception as e:
print(f"Failed to publish to channel {channel_name}: {e}")
print(f'Failed to publish to channel {channel_name}: {e}')