feat: add online presence tracking with last_seen column and configurable timeout

Add `last_seen` column to users table with index, implement `set_last_seen` and `get_online_users` database functions, expose presence config env vars (`PRESENCE_TIMEOUT_SECONDS`, `PRESENCE_ONLINE_LIMIT`, `PRESENCE_ONLINE_MARGIN_SECONDS`), include `last_seen` in follow list responses, and update profile docs to mention online indicator.
This commit is contained in:
2026-07-04 22:08:20 +00:00
parent 7002b23eeb
commit 0f872336b1
41 changed files with 935 additions and 94 deletions
+22
View File
@@ -349,6 +349,28 @@ def test_maintenance_block_recorded(seeded_db):
assert event["result"] == "denied"
def test_feed_avatar_has_presence_dot(app_server):
s, name = _member()
uid = _db_user(name)["uid"]
s.post(
f"{BASE_URL}/posts/create",
data={"title": _unique("dot"), "content": "presence dot feed post", "topic": "devlog"},
allow_redirects=True,
)
html = s.get(f"{BASE_URL}/feed").text
assert "presence-dot" in html
assert f'data-presence-uid="{uid}"' in html
def test_feed_shows_online_now_section(app_server):
s, name = _member()
html = s.get(f"{BASE_URL}/feed").text
assert "online-users" in html
assert "data-online-users-list" in html
assert "data-online-count" in html
assert f'class="online-user" title="{name}"' in html
def test_feed_shows_poll_results_without_voting(app_server):
s, _ = _session_polls()
title = f"feedpoll-{int(time.time() * 1000)}"