resolvers-renamed
Some checks failed
deploy / deploy (push) Failing after 1m7s

This commit is contained in:
2023-11-28 11:33:50 +03:00
parent 493f6106ab
commit 15139249f1
8 changed files with 34 additions and 34 deletions

View File

@@ -3,7 +3,7 @@ import json
from typing import Any, Dict, List, Optional, Union
from services.auth import login_required
from services.core import get_my_followings, get_all_authors
from services.core import get_my_followed, get_all_authors
from services.rediscache import redis
from services.schema import query
from models.chat import Message, ChatPayload
@@ -19,7 +19,7 @@ async def get_unread_counter(chat_id: str, author_id: int) -> int:
# NOTE: not an API handler
async def load_messages(
chat_id: str, limit: int = 5, offset: int = 0, ids: Optional[List[int]] = None
) -> List[Message|None]:
) -> List[Message | None]:
"""load :limit messages for :chat_id with :offset"""
messages = []
try:
@@ -48,7 +48,7 @@ async def load_messages(
return messages
@query.field("loadChats")
@query.field("load_chats")
@login_required
async def load_chats(_, info, limit: int = 50, offset: int = 0) -> Dict[str, Union[List[Dict[str, Any]], None]]:
"""load :limit chats of current user with :offset"""
@@ -84,7 +84,7 @@ async def load_chats(_, info, limit: int = 50, offset: int = 0) -> Dict[str, Uni
return {"chats": chats, "error": None}
@query.field("loadMessagesBy")
@query.field("load_messages_by")
@login_required
async def load_messages_by(_, info, by, limit: int = 10, offset: int = 0):
"""load :limit messages of :chat_id with :offset"""
@@ -111,13 +111,13 @@ async def load_messages_by(_, info, by, limit: int = 10, offset: int = 0):
return {"error": "Cannot access messages of this chat"}
@query.field("loadRecipients")
@query.field("load_recipients")
async def load_recipients(_, _info, limit=50, offset=0):
"""load possible chat participants"""
onliners = (await redis.execute("SMEMBERS", "authors-online")) or []
r = []
all_authors: List[ChatMember] = await get_all_authors()
my_followings: List[ChatMember] = await get_my_followings()
my_followings: List[ChatMember] = await get_my_followed()
if all_authors:
if len(my_followings) < limit:
my_followings = my_followings + all_authors[0 : limit - len(my_followings)]