This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
from typing import List
|
||||
|
||||
from services.auth import login_required
|
||||
from services.presence import notify_message
|
||||
@@ -11,12 +10,12 @@ from validators.chat import Message
|
||||
|
||||
@mutation.field("createMessage")
|
||||
@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):
|
||||
"""Создание сообщения с телом :body для чата :chat_id с возможным ответом на :reply_to"""
|
||||
author_id = info.context["author_id"]
|
||||
|
||||
# Получение данных чата из Redis
|
||||
chat_data = await redis.execute("GET", f"chats/{chat}")
|
||||
chat_data = await redis.execute("GET", f"chats/{chat_id}")
|
||||
print(f"[resolvers.messages] debug chat data: {chat_data}")
|
||||
|
||||
# Если данных чата нет, возвращаем ошибку
|
||||
@@ -139,7 +138,7 @@ async def delete_message(_, info, chat_id: str, message_id: int):
|
||||
|
||||
@mutation.field("markAsRead")
|
||||
@login_required
|
||||
async def mark_as_read(_, info, chat_id: str, messages: List[int]):
|
||||
async def mark_as_read(_, info, chat_id: str, message_id: int):
|
||||
author_id = info.context["author_id"]
|
||||
|
||||
chat_str = await redis.execute("GET", f"chats/{chat_id}")
|
||||
@@ -151,8 +150,7 @@ async def mark_as_read(_, info, chat_id: str, messages: List[int]):
|
||||
if author_id not in members:
|
||||
return {"error": "access denied"}
|
||||
|
||||
for message_id in messages:
|
||||
await redis.execute("LREM", f"chats/{chat_id}/unread/{author_id}", 0, str(message_id))
|
||||
await redis.execute("LREM", f"chats/{chat_id}/unread/{author_id}", 0, str(message_id))
|
||||
|
||||
message_data = await redis.execute("GET", f"chats/{chat_id}/messages/{str(message_id)}")
|
||||
if not message_data:
|
||||
|
Reference in New Issue
Block a user