author-getting-fix
All checks were successful
deploy / deploy (push) Successful in 1m4s

This commit is contained in:
2023-12-19 17:24:52 +03:00
parent d75f31072c
commit 8c1f52f99b
5 changed files with 67 additions and 55 deletions

View File

@@ -4,7 +4,7 @@ from typing import Any, Dict, List, Union
from resolvers.load import load_messages
from services.auth import login_required
from services.core import authors_by_id
from services.core import authors_by_id, authors_by_user
from services.rediscache import redis
from services.schema import query
@@ -16,7 +16,10 @@ async def search_recipients(_, info, text: str, limit: int = 50, offset: int = 0
# TODO: maybe redis scan?
author_id = info.context["author_id"]
user_id = info.context["user_id"]
author = authors_by_user[user_id]
author_id = author["id"]
existed_chats = await redis.execute("SMEMBERS", f"/chats_by_author/{author_id}")
if existed_chats:
for chat_id in list(json.loads(existed_chats))[offset : (offset + limit)]:
@@ -38,7 +41,9 @@ async def search_recipients(_, info, text: str, limit: int = 50, offset: int = 0
async def search_messages(
_, info, by: Dict[str, Union[str, int]], limit: int, offset: int
) -> Dict[str, Union[List[Dict[str, Any]], None]]:
author_id = info.context["author_id"]
user_id = info.context["user_id"]
author = authors_by_user[user_id]
author_id = author["id"]
lookup_chats = set((await redis.execute("SMEMBERS", f"chats_by_author/{author_id}")) or [])
messages_set = set([])