fix-error-messags

This commit is contained in:
tonyrewin 2022-12-04 12:42:04 +03:00
parent b9d0e47fca
commit f2a0617871

View File

@ -6,7 +6,6 @@ from auth.credentials import AuthCredentials
from base.redis import redis from base.redis import redis
from base.orm import local_session from base.orm import local_session
from base.resolvers import query from base.resolvers import query
from base.exceptions import ObjectNotExist
from orm.user import User from orm.user import User
from resolvers.zine.profile import followed_authors from resolvers.zine.profile import followed_authors
from .unread import get_unread_counter from .unread import get_unread_counter
@ -100,7 +99,10 @@ async def load_messages_by(_, info, by, limit: int = 10, offset: int = 0):
if by_chat: if by_chat:
chat = await redis.execute("GET", f"chats/{by_chat}") chat = await redis.execute("GET", f"chats/{by_chat}")
if not chat: if not chat:
raise ObjectNotExist("Chat not exists") return {
"messages": [],
"error": "chat not exist"
}
# everyone's messages in filtered chat # everyone's messages in filtered chat
messages.union(set(await load_messages(by_chat, limit, offset))) messages.union(set(await load_messages(by_chat, limit, offset)))