some-fixes
Some checks failed
deploy / deploy (push) Failing after 1m12s

This commit is contained in:
2023-11-22 15:09:24 +03:00
parent 4530b2a1e9
commit 856a331836
15 changed files with 63 additions and 90 deletions

View File

@@ -1,11 +1,11 @@
import json
from datetime import datetime, timezone
import time
from services.auth import login_required
from services.presence import notify_message
from services.rediscache import redis
from services.schema import mutation
from validators.chat import Message
from models.chat import Message
@mutation.field("createMessage")
@@ -29,14 +29,14 @@ async def create_message(_, info, chat_id: str, body: str, reply_to=None):
# Получение ID следующего сообщения
message_id = await redis.execute("GET", f"chats/{chat_dict['id']}/next_message_id")
message_id = int(message_id) if message_id else 0
chat_id = chat_dict['id']
chat_id = chat_dict["id"]
# Создание нового сообщения
new_message: Message = {
"chat_id": chat_id,
"id": message_id,
"created_by": author_id,
"body": body,
"created_at": int(datetime.now(tz=timezone.utc).timestamp()),
"created_at": int(time.time()),
"updated_at": None,
}
@@ -109,9 +109,9 @@ async def update_message(_, info, message):
message["chat_id"] = chat_id
await notify_message(message, "update")
return { "message": message, "error": None }
return {"message": message, "error": None}
else:
return { "message": message, "error": "cannot update, no message_id" }
return {"message": message, "error": "cannot update, no message_id"}
@mutation.field("deleteMessage")
@@ -164,7 +164,7 @@ async def mark_as_read(_, info, chat_id: str, message_id: int):
if not message_data:
return {"error": "message not exist"}
message: Message = json.loads(message_data)
await notify_message(message, "seen")
return {"error": None}