Files
core/resolvers/inbox/unread.py

11 lines
280 B
Python
Raw Normal View History

2022-11-21 11:13:57 +03:00
from base.redis import redis
2022-12-02 11:47:55 +03:00
async def get_unread_counter(chat_id: str, user_id: int):
2022-11-21 11:13:57 +03:00
try:
2022-12-02 11:47:55 +03:00
unread = await redis.execute("LLEN", f"chats/{chat_id.decode('utf-8')}/unread/{user_id}")
2022-11-21 11:13:57 +03:00
if unread:
return unread
except Exception:
return 0