mmrelay 1.2.1__py3-none-any.whl → 1.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mmrelay might be problematic. Click here for more details.
- mmrelay/__init__.py +1 -1
- mmrelay/__main__.py +29 -0
- mmrelay/cli.py +451 -48
- mmrelay/cli_utils.py +59 -9
- mmrelay/config.py +193 -66
- mmrelay/constants/app.py +2 -2
- mmrelay/db_utils.py +73 -26
- mmrelay/e2ee_utils.py +11 -3
- mmrelay/log_utils.py +16 -5
- mmrelay/main.py +41 -38
- mmrelay/matrix_utils.py +1068 -292
- mmrelay/meshtastic_utils.py +352 -209
- mmrelay/message_queue.py +22 -23
- mmrelay/plugin_loader.py +634 -205
- mmrelay/plugins/mesh_relay_plugin.py +44 -38
- mmrelay/plugins/weather_plugin.py +11 -12
- mmrelay/runtime_utils.py +35 -0
- mmrelay/setup_utils.py +323 -128
- mmrelay/tools/mmrelay.service +2 -1
- mmrelay/tools/sample-docker-compose-prebuilt.yaml +11 -72
- mmrelay/tools/sample-docker-compose.yaml +12 -58
- mmrelay/tools/sample_config.yaml +1 -1
- mmrelay/windows_utils.py +349 -0
- {mmrelay-1.2.1.dist-info → mmrelay-1.2.3.dist-info}/METADATA +7 -7
- mmrelay-1.2.3.dist-info/RECORD +48 -0
- mmrelay-1.2.1.dist-info/RECORD +0 -45
- {mmrelay-1.2.1.dist-info → mmrelay-1.2.3.dist-info}/WHEEL +0 -0
- {mmrelay-1.2.1.dist-info → mmrelay-1.2.3.dist-info}/entry_points.txt +0 -0
- {mmrelay-1.2.1.dist-info → mmrelay-1.2.3.dist-info}/licenses/LICENSE +0 -0
- {mmrelay-1.2.1.dist-info → mmrelay-1.2.3.dist-info}/top_level.txt +0 -0
mmrelay/message_queue.py
CHANGED
|
@@ -355,9 +355,9 @@ class MessageQueue:
|
|
|
355
355
|
|
|
356
356
|
async def _process_queue(self):
|
|
357
357
|
"""
|
|
358
|
-
|
|
358
|
+
Process queued messages in FIFO order, sending each when the connection is ready and the configured inter-message delay has elapsed.
|
|
359
359
|
|
|
360
|
-
This
|
|
360
|
+
This background coroutine continuously pulls QueuedMessage items from the internal queue and executes their send_function in the configured executor, enforcing rate limiting (_message_delay) and checking connection/readiness via _should_send_message. After a successful send, it updates last-send timestamps and optionally persists message mapping information via _handle_message_mapping when mapping_info is present and the send result exposes an `id`. The coroutine exits when the queue is stopped or when cancelled; cancellation may drop an in-flight message, which will be logged.
|
|
361
361
|
"""
|
|
362
362
|
logger.debug("Message queue processor started")
|
|
363
363
|
current_message = None
|
|
@@ -467,18 +467,17 @@ class MessageQueue:
|
|
|
467
467
|
self._in_flight = False
|
|
468
468
|
self._has_current = False
|
|
469
469
|
break
|
|
470
|
-
except Exception
|
|
471
|
-
logger.
|
|
470
|
+
except Exception:
|
|
471
|
+
logger.exception("Error in message queue processor")
|
|
472
472
|
await asyncio.sleep(1.0) # Prevent tight error loop
|
|
473
473
|
|
|
474
474
|
def _should_send_message(self) -> bool:
|
|
475
475
|
"""
|
|
476
|
-
Return True
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
If importing
|
|
481
|
-
background thread to stop this MessageQueue, and returns False.
|
|
476
|
+
Return True when it is safe to send a Meshtastic message; otherwise False.
|
|
477
|
+
|
|
478
|
+
Performs runtime checks: verifies the module-level `reconnecting` flag is False, a Meshtastic client object exists, and — if the client exposes `is_connected` (callable or boolean) — that it reports connected. If any check fails the method returns False.
|
|
479
|
+
|
|
480
|
+
If importing the Meshtastic utilities raises ImportError, the queue will be stopped asynchronously and the method returns False.
|
|
482
481
|
"""
|
|
483
482
|
# Import here to avoid circular imports
|
|
484
483
|
try:
|
|
@@ -518,18 +517,18 @@ class MessageQueue:
|
|
|
518
517
|
|
|
519
518
|
def _handle_message_mapping(self, result, mapping_info):
|
|
520
519
|
"""
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
If
|
|
524
|
-
|
|
520
|
+
Persist a sent mesh-to-Matrix message mapping and optionally prune old mappings.
|
|
521
|
+
|
|
522
|
+
If mapping_info contains 'matrix_event_id', 'room_id', and 'text', this stores a mapping using result.id as the mesh message id. If 'msgs_to_keep' is present and > 0 it prunes older mappings to retain that many entries; otherwise DEFAULT_MSGS_TO_KEEP is used.
|
|
523
|
+
|
|
525
524
|
Parameters:
|
|
526
|
-
result:
|
|
527
|
-
mapping_info:
|
|
528
|
-
- matrix_event_id (str): Matrix event
|
|
529
|
-
- room_id (str): Matrix room
|
|
530
|
-
- text (str):
|
|
531
|
-
- meshnet (optional): Mesh network identifier passed to
|
|
532
|
-
- msgs_to_keep (optional, int): Number of mappings to retain
|
|
525
|
+
result: An object returned by the send function with an `id` attribute (the mesh message id).
|
|
526
|
+
mapping_info (dict): Mapping details. Relevant keys:
|
|
527
|
+
- matrix_event_id (str): Matrix event ID to map to.
|
|
528
|
+
- room_id (str): Matrix room ID where the event was sent.
|
|
529
|
+
- text (str): Message text to associate with the mapping.
|
|
530
|
+
- meshnet (optional): Mesh network identifier passed through to storage.
|
|
531
|
+
- msgs_to_keep (optional, int): Number of mappings to retain when pruning.
|
|
533
532
|
"""
|
|
534
533
|
try:
|
|
535
534
|
# Import here to avoid circular imports
|
|
@@ -557,8 +556,8 @@ class MessageQueue:
|
|
|
557
556
|
if msgs_to_keep > 0:
|
|
558
557
|
prune_message_map(msgs_to_keep)
|
|
559
558
|
|
|
560
|
-
except Exception
|
|
561
|
-
logger.
|
|
559
|
+
except Exception:
|
|
560
|
+
logger.exception("Error handling message mapping")
|
|
562
561
|
|
|
563
562
|
|
|
564
563
|
# Global message queue instance
|