def get_reactions( post: str | None, id_: int | None = None, oconn: sqlite3.Connection | None = None ) -> list[Reaction]: if not oconn: check_db() conn, c = row_conn() else: conn = oconn c = conn.cursor() if id_: c.execute("select * from reactions where id = ?", (id_,)) rows = [c.fetchone()] else: c.execute("select * from reactions where post = ?", (post,)) rows = c.fetchall() reactions = [] rows = [row for row in rows if row] for row in rows: reaction = make_reaction(dict(row)) c.execute("select * from users where username = ?", (row["user"],)) user = c.fetchone() if user: reaction.uname = user["name"] reactions.append(reaction) if not oconn: conn.close() return reactions