mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-07-04 17:01:45 +02:00
Clean up contact creation and add missing FE fields for last_contacted
This commit is contained in:
+6
-32
@@ -45,22 +45,9 @@ async def prepare_repeater_connection(mc, contact: Contact, password: str) -> No
|
||||
Raises:
|
||||
HTTPException: If login fails
|
||||
"""
|
||||
# Add contact to radio with path from DB (or flood if no path known)
|
||||
path_len = contact.last_path_len if contact.last_path_len >= 0 else -1
|
||||
path_str = "direct" if path_len == 0 else f"{path_len} hops" if path_len > 0 else "flood"
|
||||
logger.info("Adding repeater %s to radio (%s)", contact.public_key[:12], path_str)
|
||||
contact_data = {
|
||||
"public_key": contact.public_key,
|
||||
"adv_name": contact.name or "",
|
||||
"type": contact.type,
|
||||
"flags": contact.flags,
|
||||
"out_path": contact.last_path or "",
|
||||
"out_path_len": path_len,
|
||||
"adv_lat": contact.lat or 0.0,
|
||||
"adv_lon": contact.lon or 0.0,
|
||||
"last_advert": contact.last_advert or 0,
|
||||
}
|
||||
await mc.commands.add_contact(contact_data)
|
||||
# Add contact to radio with path from DB
|
||||
logger.info("Adding repeater %s to radio", contact.public_key[:12])
|
||||
await mc.commands.add_contact(contact.to_radio_dict())
|
||||
|
||||
# Send login with password
|
||||
logger.info("Sending login to repeater %s", contact.public_key[:12])
|
||||
@@ -382,22 +369,9 @@ async def send_repeater_command(public_key: str, request: CommandRequest) -> Com
|
||||
|
||||
# Pause message polling to prevent it from stealing our response
|
||||
async with pause_polling():
|
||||
# Add contact to radio with path from DB (or flood if no path known)
|
||||
path_len = contact.last_path_len if contact.last_path_len >= 0 else -1
|
||||
path_str = "direct" if path_len == 0 else f"{path_len} hops" if path_len > 0 else "flood"
|
||||
logger.info("Adding repeater %s to radio (%s)", contact.public_key[:12], path_str)
|
||||
contact_data = {
|
||||
"public_key": contact.public_key,
|
||||
"adv_name": contact.name or "",
|
||||
"type": contact.type,
|
||||
"flags": contact.flags,
|
||||
"out_path": contact.last_path or "",
|
||||
"out_path_len": path_len,
|
||||
"adv_lat": contact.lat or 0.0,
|
||||
"adv_lon": contact.lon or 0.0,
|
||||
"last_advert": contact.last_advert or 0,
|
||||
}
|
||||
await mc.commands.add_contact(contact_data)
|
||||
# Add contact to radio with path from DB
|
||||
logger.info("Adding repeater %s to radio", contact.public_key[:12])
|
||||
await mc.commands.add_contact(contact.to_radio_dict())
|
||||
|
||||
# Send the command
|
||||
logger.info("Sending command to repeater %s: %s", contact.public_key[:12], request.command)
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
+2
-2
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -13,7 +13,7 @@
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
<script type="module" crossorigin src="/assets/index-BwUypkiE.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DPT3GFYS.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DZ67iE5i.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -443,6 +443,7 @@ export function App() {
|
||||
lon: null,
|
||||
last_seen: null,
|
||||
on_radio: false,
|
||||
last_contacted: null,
|
||||
last_read_at: null,
|
||||
};
|
||||
setContacts((prev) => [...prev, newContact]);
|
||||
|
||||
@@ -67,6 +67,7 @@ export interface Contact {
|
||||
lon: number | null;
|
||||
last_seen: number | null;
|
||||
on_radio: boolean;
|
||||
last_contacted: number | null;
|
||||
last_read_at: number | null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user