diff --git a/app/events.py b/app/events.py index a4e2e21..0f9332a 100644 --- a/app/events.py +++ b/app/events.py @@ -52,19 +52,6 @@ class ToastPayload(TypedDict): details: NotRequired[str] -WsEventPayload = ( - HealthResponse - | Message - | Contact - | ContactResolvedPayload - | Channel - | ContactDeletedPayload - | ChannelDeletedPayload - | RawPacketBroadcast - | MessageAckedPayload - | ToastPayload -) - _PAYLOAD_ADAPTERS: dict[WsEventType, TypeAdapter[Any]] = { "health": TypeAdapter(HealthResponse), "message": TypeAdapter(Message), diff --git a/app/models.py b/app/models.py index 869f9fe..b711edb 100644 --- a/app/models.py +++ b/app/models.py @@ -196,15 +196,6 @@ class Contact(BaseModel): """Convert the stored contact to the repository's write contract.""" return ContactUpsert.from_contact(self, **changes) - @staticmethod - def from_radio_dict(public_key: str, radio_data: dict, on_radio: bool = False) -> dict: - """Backward-compatible dict wrapper over ContactUpsert.from_radio_dict().""" - return ContactUpsert.from_radio_dict( - public_key, - radio_data, - on_radio=on_radio, - ).model_dump() - class CreateContactRequest(BaseModel): """Request to create a new contact.""" @@ -850,19 +841,6 @@ class AppSettings(BaseModel): ) -class FanoutConfig(BaseModel): - """Configuration for a single fanout integration.""" - - id: str - type: str # 'mqtt_private' | 'mqtt_community' | 'bot' | 'webhook' | 'apprise' | 'sqs' - name: str - enabled: bool - config: dict - scope: dict - sort_order: int = 0 - created_at: int = 0 - - class BusyChannel(BaseModel): channel_key: str channel_name: str diff --git a/app/repository/channels.py b/app/repository/channels.py index e7a765a..7255422 100644 --- a/app/repository/channels.py +++ b/app/repository/channels.py @@ -68,31 +68,6 @@ class ChannelRepository: for row in rows ] - @staticmethod - async def get_on_radio() -> list[Channel]: - """Return channels currently marked as resident on the radio in the database.""" - cursor = await db.conn.execute( - """ - SELECT key, name, is_hashtag, on_radio, flood_scope_override, path_hash_mode_override, last_read_at - FROM channels - WHERE on_radio = 1 - ORDER BY name - """ - ) - rows = await cursor.fetchall() - return [ - Channel( - key=row["key"], - name=row["name"], - is_hashtag=bool(row["is_hashtag"]), - on_radio=bool(row["on_radio"]), - flood_scope_override=row["flood_scope_override"], - path_hash_mode_override=row["path_hash_mode_override"], - last_read_at=row["last_read_at"], - ) - for row in rows - ] - @staticmethod async def delete(key: str) -> None: """Delete a channel by key.""" diff --git a/app/repository/raw_packets.py b/app/repository/raw_packets.py index 17d53dd..d14911d 100644 --- a/app/repository/raw_packets.py +++ b/app/repository/raw_packets.py @@ -172,12 +172,3 @@ class RawPacketRepository: cursor = await db.conn.execute("DELETE FROM raw_packets WHERE message_id IS NOT NULL") await db.conn.commit() return cursor.rowcount - - @staticmethod - async def get_undecrypted_text_messages() -> list[tuple[int, bytes, int]]: - """Get all undecrypted TEXT_MESSAGE packets as (id, data, timestamp) tuples. - - Filters raw packets to only include those with PayloadType.TEXT_MESSAGE (0x02). - These are direct messages that can be decrypted with contact ECDH keys. - """ - return [packet async for packet in RawPacketRepository.stream_undecrypted_text_messages()] diff --git a/app/routers/repeaters.py b/app/routers/repeaters.py index d822195..72ca330 100644 --- a/app/routers/repeaters.py +++ b/app/routers/repeaters.py @@ -28,7 +28,6 @@ from app.repository import ContactRepository, RepeaterTelemetryRepository from app.routers.contacts import _ensure_on_radio, _resolve_contact_or_404 from app.routers.server_control import ( batch_cli_fetch, - extract_response_text, prepare_authenticated_contact_connection, require_server_capable_contact, send_contact_cli_command, @@ -48,10 +47,6 @@ router = APIRouter(prefix="/contacts", tags=["repeaters"]) REPEATER_LOGIN_RESPONSE_TIMEOUT_SECONDS = 5.0 -def _extract_response_text(event) -> str: - return extract_response_text(event) - - async def prepare_repeater_connection(mc, contact: Contact, password: str) -> RepeaterLoginResponse: return await prepare_authenticated_contact_connection( mc, diff --git a/tests/test_path_utils.py b/tests/test_path_utils.py index d57cd43..25ef0e6 100644 --- a/tests/test_path_utils.py +++ b/tests/test_path_utils.py @@ -295,12 +295,12 @@ class TestContactToRadioDictHashMode: class TestContactFromRadioDictHashMode: - """Test that Contact.from_radio_dict() preserves explicit path hash mode.""" + """Test that ContactUpsert.from_radio_dict() preserves explicit path hash mode.""" def test_preserves_mode_from_radio_payload(self): - from app.models import Contact + from app.models import ContactUpsert - d = Contact.from_radio_dict( + upsert = ContactUpsert.from_radio_dict( "aa" * 32, { "adv_name": "Alice", @@ -309,14 +309,14 @@ class TestContactFromRadioDictHashMode: "out_path_hash_mode": 1, }, ) - assert d["direct_path"] == "aa00bb00" - assert d["direct_path_len"] == 2 - assert d["direct_path_hash_mode"] == 1 + assert upsert.direct_path == "aa00bb00" + assert upsert.direct_path_len == 2 + assert upsert.direct_path_hash_mode == 1 def test_flood_falls_back_to_minus_one(self): - from app.models import Contact + from app.models import ContactUpsert - d = Contact.from_radio_dict( + upsert = ContactUpsert.from_radio_dict( "bb" * 32, { "adv_name": "Bob", @@ -324,6 +324,6 @@ class TestContactFromRadioDictHashMode: "out_path_len": -1, }, ) - assert d["direct_path"] == "" - assert d["direct_path_len"] == -1 - assert d["direct_path_hash_mode"] == -1 + assert upsert.direct_path == "" + assert upsert.direct_path_len == -1 + assert upsert.direct_path_hash_mode == -1