feat(chat): add presence metadata and improve web chat core
Some checks failed
CI / test (push) Failing after 22s
Some checks failed
CI / test (push) Failing after 22s
- add user last_seen_at with alembic migration and persist on realtime disconnect - extend chat serialization with private online/last_seen, group members/online, channel subscribers - add Redis batch presence lookup helper - update web chat list/header to display status counters and last-seen labels - improve delivery receipt handling using last_delivered/last_read boundaries - include chat info panel and related API/type updates
This commit is contained in:
@@ -32,3 +32,18 @@ async def is_user_online(user_id: int) -> bool:
|
||||
return bool(value and str(value).isdigit() and int(value) > 0)
|
||||
except RedisError:
|
||||
return False
|
||||
|
||||
|
||||
async def get_users_online_map(user_ids: list[int]) -> dict[int, bool]:
|
||||
if not user_ids:
|
||||
return {}
|
||||
try:
|
||||
redis = get_redis_client()
|
||||
keys = [f"presence:user:{user_id}" for user_id in user_ids]
|
||||
values = await redis.mget(keys)
|
||||
return {
|
||||
user_id: bool(value and str(value).isdigit() and int(value) > 0)
|
||||
for user_id, value in zip(user_ids, values, strict=False)
|
||||
}
|
||||
except RedisError:
|
||||
return {user_id: False for user_id in user_ids}
|
||||
|
||||
Reference in New Issue
Block a user