Retro Bulletin Board Systems on atproto. Web app and TUI. lazy mirror of alyraffauf/atbbs atbbs.xyz
forums python tui atproto bbs
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

tui: clean up out-of-core db calls

+22 -15
+14
core/auth/session.py
··· 98 98 con.close() 99 99 return dict(row) if row else None 100 100 101 + def list_sessions(self) -> list[dict]: 102 + """Return all stored sessions, newest first (by insertion order).""" 103 + con = self._connect() 104 + rows = con.execute( 105 + "SELECT * FROM oauth_session ORDER BY rowid DESC" 106 + ).fetchall() 107 + con.close() 108 + return [dict(r) for r in rows] 109 + 110 + def get_active_session(self) -> dict | None: 111 + """Return the most recently stored session, if any.""" 112 + sessions = self.list_sessions() 113 + return sessions[0] if sessions else None 114 + 101 115 ALLOWED_FIELDS = { 102 116 "dpop_pds_nonce", 103 117 "dpop_authserver_nonce",
+8 -15
tui/app.py
··· 84 84 def _restore_session(self) -> None: 85 85 """Load the stored session. The TUI is single-user: if stale extra 86 86 rows exist from a previous version, keep the newest and drop the rest.""" 87 - import sqlite3 88 - 89 87 try: 90 - con = sqlite3.connect(self.session_store.db_path) 91 - con.row_factory = sqlite3.Row 92 - rows = con.execute( 93 - "SELECT * FROM oauth_session ORDER BY rowid DESC" 94 - ).fetchall() 95 - con.close() 96 - if not rows: 97 - return 98 - self.user_session = dict(rows[0]) 99 - self.sub_title = self.user_session.get("handle", "") 100 - for extra in rows[1:]: 101 - self.session_store.delete_session(extra["did"]) 88 + sessions = self.session_store.list_sessions() 102 89 except Exception: 103 - pass 90 + return 91 + if not sessions: 92 + return 93 + self.user_session = sessions[0] 94 + self.sub_title = self.user_session.get("handle", "") 95 + for extra in sessions[1:]: 96 + self.session_store.delete_session(extra["did"]) 104 97 105 98 def action_login(self) -> None: 106 99 if self.user_session: