core/resolvers/inbox/unread.py
Ilya Y da8ee9b9c3
signIn/getSession optimization (#95)
Co-authored-by: Igor Lobanov <igor.lobanov@onetwotrip.com>
2023-10-19 17:54:38 +03:00

11 lines
280 B
Python

from base.redis import redis
async def get_unread_counter(chat_id: str, user_id: int):
try:
unread = await redis.execute("LLEN", f"chats/{chat_id.decode('utf-8')}/unread/{user_id}")
if unread:
return unread
except Exception:
return 0