Axe some dead code

This commit is contained in:
Jack Kingsman
2026-04-03 17:22:04 -07:00
parent d5922a214b
commit 4a93641f04
6 changed files with 11 additions and 85 deletions

View File

@@ -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),

View File

@@ -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

View File

@@ -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."""

View File

@@ -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()]

View File

@@ -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,

View File

@@ -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