mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-03-28 17:43:05 +01:00
Linting goodness
This commit is contained in:
@@ -214,13 +214,17 @@ async def on_path_update(event: "Event") -> None:
|
||||
path = payload.get("path")
|
||||
path_len = payload.get("path_len")
|
||||
if path is None or path_len is None:
|
||||
logger.debug("PATH_UPDATE for %s has no path payload, skipping DB update", contact.public_key[:12])
|
||||
logger.debug(
|
||||
"PATH_UPDATE for %s has no path payload, skipping DB update", contact.public_key[:12]
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
normalized_path_len = int(path_len)
|
||||
except (TypeError, ValueError):
|
||||
logger.warning("Invalid path_len in PATH_UPDATE for %s: %r", contact.public_key[:12], path_len)
|
||||
logger.warning(
|
||||
"Invalid path_len in PATH_UPDATE for %s: %r", contact.public_key[:12], path_len
|
||||
)
|
||||
return
|
||||
|
||||
await ContactRepository.update_path(contact.public_key, str(path), normalized_path_len)
|
||||
|
||||
@@ -194,7 +194,9 @@ async def sync_contacts_from_radio() -> dict:
|
||||
|
||||
for public_key, contact_data in contacts.items():
|
||||
lower_key = public_key.lower()
|
||||
await ContactRepository.upsert(Contact.from_radio_dict(lower_key, contact_data, on_radio=True))
|
||||
await ContactRepository.upsert(
|
||||
Contact.from_radio_dict(lower_key, contact_data, on_radio=True)
|
||||
)
|
||||
claimed = await MessageRepository.claim_prefix_messages(lower_key)
|
||||
if claimed > 0:
|
||||
logger.info("Claimed %d prefix DM message(s) for contact %s", claimed, public_key[:12])
|
||||
@@ -224,7 +226,9 @@ async def remove_contact_from_radio(public_key: str) -> dict:
|
||||
result = await mc.commands.remove_contact(radio_contact)
|
||||
|
||||
if result.type == EventType.ERROR:
|
||||
raise HTTPException(status_code=500, detail=f"Failed to remove contact: {result.payload}")
|
||||
raise HTTPException(
|
||||
status_code=500, detail=f"Failed to remove contact: {result.payload}"
|
||||
)
|
||||
|
||||
await ContactRepository.set_on_radio(contact.public_key, False)
|
||||
return {"status": "ok"}
|
||||
@@ -277,7 +281,9 @@ async def delete_contact(public_key: str) -> dict:
|
||||
async with radio_manager.radio_operation("delete_contact_from_radio", meshcore=mc):
|
||||
radio_contact = mc.get_contact_by_key_prefix(contact.public_key[:12])
|
||||
if radio_contact:
|
||||
logger.info("Removing contact %s from radio before deletion", contact.public_key[:12])
|
||||
logger.info(
|
||||
"Removing contact %s from radio before deletion", contact.public_key[:12]
|
||||
)
|
||||
await mc.commands.remove_contact(radio_contact)
|
||||
|
||||
# Delete from database
|
||||
|
||||
@@ -75,8 +75,7 @@ export function updateAck(messageId: number, ackCount: number, paths?: MessagePa
|
||||
updated[idx] = {
|
||||
...current,
|
||||
acked: Math.max(current.acked, ackCount),
|
||||
...(paths !== undefined &&
|
||||
paths.length >= (current.paths?.length ?? 0) && { paths }),
|
||||
...(paths !== undefined && paths.length >= (current.paths?.length ?? 0) && { paths }),
|
||||
};
|
||||
entry.messages = updated;
|
||||
return; // Message IDs are unique, stop after first match
|
||||
|
||||
@@ -8,6 +8,7 @@ import pytest
|
||||
from fastapi import HTTPException
|
||||
from meshcore import EventType
|
||||
|
||||
from app.radio import RadioManager
|
||||
from app.routers.radio import (
|
||||
PrivateKeyUpdate,
|
||||
RadioConfigResponse,
|
||||
@@ -20,7 +21,6 @@ from app.routers.radio import (
|
||||
set_private_key,
|
||||
update_radio_config,
|
||||
)
|
||||
from app.radio import RadioManager
|
||||
|
||||
|
||||
def _radio_result(event_type=EventType.OK, payload=None):
|
||||
|
||||
Reference in New Issue
Block a user