Calculate session expiry times in operations, using a common now timestamp for everything.

This commit is contained in:
2026-02-10 21:35:56 +00:00
parent 3ca784dc3c
commit 8b6bdd0f9c
6 changed files with 15 additions and 25 deletions
+1 -2
View File
@@ -309,7 +309,7 @@ class Session(msgspec.Struct, dict=True):
"expiry": self.expiry.isoformat(),
}
def store(self) -> None:
def store(self, now: datetime) -> None:
"""Store this session in the database and record a visit.
Updates user.last_seen and user.visits. Must be called inside
@@ -317,7 +317,6 @@ class Session(msgspec.Struct, dict=True):
"""
_data = db.data()
_data.sessions[self.key] = self
now = datetime.now(UTC)
_data.users[self.user_uuid].last_seen = now
_data.users[self.user_uuid].visits += 1