created_at -> created_at_sec

This commit is contained in:
Andrew Morgan
2026-01-23 14:41:06 +00:00
parent 2e71abdfda
commit e0304c627b
4 changed files with 14 additions and 7 deletions
@@ -219,15 +219,15 @@ class GuestModule:
CREATE TABLE IF NOT EXISTS guest_module_mas_users (
mas_user_id TEXT PRIMARY KEY,
user_id TEXT,
created_at BIGINT NOT NULL
created_at_sec BIGINT NOT NULL
)
""",
(),
)
txn.execute(
"""
CREATE INDEX IF NOT EXISTS guest_module_mas_users_created_at
ON guest_module_mas_users (created_at)
CREATE INDEX IF NOT EXISTS guest_module_mas_users_created_at_sec
ON guest_module_mas_users (created_at_sec)
""",
(),
)
@@ -135,7 +135,14 @@ class GuestRegistrationServlet(DirectServeJsonResource):
return 500, {"msg": "Internal error: Could not find a free username"}
async def _store_mas_user(self, mas_user_id: str, user_id: str, created_at: int) -> None:
async def _store_mas_user(self, mas_user_id: str, user_id: str, created_at_sec: int) -> None:
"""Store details about the MAS user in the DB
Args:
mas_user_id: The MAS user ID
user_id: The Matrix user ID
created_at_sec: The creation timestamp in seconds since the unix epoch
"""
if self._mas_tables_ready is not None:
await self._mas_tables_ready.wait()
@@ -146,7 +153,7 @@ class GuestRegistrationServlet(DirectServeJsonResource):
values={
"mas_user_id": mas_user_id,
"user_id": user_id,
"created_at": created_at,
"created_at_sec": created_at_sec,
},
)
@@ -121,7 +121,7 @@ class GuestUserReaper:
"""
SELECT mas_user_id
FROM guest_module_mas_users
WHERE created_at < ?
WHERE created_at_sec < ?
""",
(expire_ts_seconds,),
)
@@ -160,5 +160,5 @@ def _setup_db(conn: sqlite3.Connection) -> None:
"CREATE TABLE users(name text, deactivated smallint, creation_ts bigint)"
)
conn.execute(
"CREATE TABLE guest_module_mas_users(mas_user_id text, user_id text, created_at bigint)"
"CREATE TABLE guest_module_mas_users(mas_user_id text, user_id text, created_at_sec bigint)"
)