create-msg-fix

This commit is contained in:
Untone 2023-10-13 20:55:13 +03:00
parent 3e1fd78ebe
commit 3959a36d8a

View File

@ -10,7 +10,7 @@ from services.schema import mutation
@mutation.field("createMessage") @mutation.field("createMessage")
@login_required @login_required
async def create_message(_, info, chat: str, body: str, reply_to=None): async def create_message(_, info, chat_id: str, body: str, reply_to=None):
""" """
create message with create message with
:body for :body for
@ -19,11 +19,11 @@ async def create_message(_, info, chat: str, body: str, reply_to=None):
""" """
author_id = info.context["author_id"] author_id = info.context["author_id"]
chat_dict = await redis.execute("GET", f"chats/{chat}") chat_data = await redis.execute("GET", f"chats/{chat_id}")
if not chat_dict: if not chat_data:
return {"error": "chat is not exist"} return {"error": "chat is not exist"}
else: else:
chat_dict = vars(json.loads(chat)) chat_dict = json.loads(chat_data)
message_id = (await redis.execute("GET", f"chats/{chat_dict['id']}/next_message_id")) or 0 message_id = (await redis.execute("GET", f"chats/{chat_dict['id']}/next_message_id")) or 0
message_id = int(message_id) message_id = int(message_id)
new_message = { new_message = {