social media crossposting tool. 3rd time's the charm
mastodon misskey crossposting bluesky
1from pathlib import Path 2import sqlite3 3from typing import cast 4 5from database.connection import get_conn 6 7 8class Service: 9 def __init__(self, url: str, db: Path) -> None: 10 self.url: str = url 11 self.conn: sqlite3.Connection = get_conn(db) 12 13 def get_post(self, url: str, user: str, identifier: str) -> sqlite3.Row | None: 14 cursor = self.conn.cursor() 15 _ = cursor.execute( 16 """ 17 SELECT * FROM posts 18 WHERE service = ? 19 AND user_id = ? 20 AND identifier = ? 21 """, 22 (url, user, identifier), 23 ) 24 return cast(sqlite3.Row, cursor.fetchone()) 25 26 def get_post_by_id(self, id: int) -> sqlite3.Row | None: 27 cursor = self.conn.cursor() 28 _ = cursor.execute("SELECT * FROM posts WHERE id = ?", (id,)) 29 return cast(sqlite3.Row, cursor.fetchone())