mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-05-21 23:24:44 +02:00
fix: node_id int handling in connector + rule stats data path
- connector.send_message accepts int or string destination - channels.py converts node_id to str before string operations - Rule stats write to /data/ (Docker volume) not /opt/meshai/data/
This commit is contained in:
parent
2f0cf520fa
commit
32f6a238f8
3 changed files with 13 additions and 10 deletions
|
|
@ -229,10 +229,13 @@ class MeshConnector:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if destination:
|
if destination:
|
||||||
# DM to specific node
|
# DM to specific node - handle int or string
|
||||||
# Convert hex string to int if needed
|
if isinstance(destination, int):
|
||||||
if destination.startswith("!"):
|
dest_num = destination
|
||||||
|
elif destination.startswith("!"):
|
||||||
dest_num = int(destination[1:], 16)
|
dest_num = int(destination[1:], 16)
|
||||||
|
elif destination.isdigit():
|
||||||
|
dest_num = int(destination)
|
||||||
else:
|
else:
|
||||||
dest_num = int(destination, 16)
|
dest_num = int(destination, 16)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -168,8 +168,8 @@ class MeshDMChannel(NotificationChannel):
|
||||||
|
|
||||||
for node_id in self._node_ids:
|
for node_id in self._node_ids:
|
||||||
try:
|
try:
|
||||||
dest = int(node_id[1:], 16) if node_id.startswith("!") else (int(node_id) if node_id.isdigit() else int(node_id, 16))
|
node_id = str(node_id)
|
||||||
self._connector.send_message(text=message, destination=dest, channel=0)
|
self._connector.send_message(text=message, destination=node_id, channel=0)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Failed to DM %s: %s", node_id, e)
|
logger.error("Failed to DM %s: %s", node_id, e)
|
||||||
success = False
|
success = False
|
||||||
|
|
@ -199,10 +199,10 @@ class MeshDMChannel(NotificationChannel):
|
||||||
|
|
||||||
for node_id in self._node_ids:
|
for node_id in self._node_ids:
|
||||||
try:
|
try:
|
||||||
dest = int(node_id[1:], 16) if node_id.startswith("!") else (int(node_id) if node_id.isdigit() else int(node_id, 16))
|
node_id = str(node_id)
|
||||||
self._connector.send_message(
|
self._connector.send_message(
|
||||||
text="MeshAI DM test",
|
text="MeshAI DM test",
|
||||||
destination=dest,
|
destination=node_id,
|
||||||
channel=0,
|
channel=0,
|
||||||
)
|
)
|
||||||
results.append({"node": node_id, "success": True})
|
results.append({"node": node_id, "success": True})
|
||||||
|
|
@ -249,8 +249,8 @@ class MeshDMChannel(NotificationChannel):
|
||||||
|
|
||||||
for node_id in self._node_ids:
|
for node_id in self._node_ids:
|
||||||
try:
|
try:
|
||||||
dest = int(node_id[1:], 16) if node_id.startswith("!") else (int(node_id) if node_id.isdigit() else int(node_id, 16))
|
node_id = str(node_id)
|
||||||
self._connector.send_message(text=message, destination=dest, channel=0)
|
self._connector.send_message(text=message, destination=node_id, channel=0)
|
||||||
success_count += 1
|
success_count += 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.append(f"{node_id}: {e}")
|
errors.append(f"{node_id}: {e}")
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ logger = logging.getLogger(__name__)
|
||||||
SEVERITY_ORDER = ["routine", "priority", "immediate"]
|
SEVERITY_ORDER = ["routine", "priority", "immediate"]
|
||||||
|
|
||||||
# State file for rule statistics
|
# State file for rule statistics
|
||||||
RULE_STATS_FILE = "/opt/meshai/data/rule_stats.json"
|
RULE_STATS_FILE = "/data/rule_stats.json"
|
||||||
|
|
||||||
|
|
||||||
class NotificationRouter:
|
class NotificationRouter:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue