mmrelay 1.2.1__py3-none-any.whl → 1.2.2__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 +452 -50
- mmrelay/cli_utils.py +59 -9
- mmrelay/config.py +198 -71
- mmrelay/constants/app.py +2 -2
- mmrelay/db_utils.py +73 -26
- mmrelay/e2ee_utils.py +6 -3
- mmrelay/log_utils.py +16 -5
- mmrelay/main.py +41 -38
- mmrelay/matrix_utils.py +1069 -293
- mmrelay/meshtastic_utils.py +350 -206
- mmrelay/message_queue.py +22 -23
- mmrelay/plugin_loader.py +634 -205
- mmrelay/plugins/mesh_relay_plugin.py +43 -38
- mmrelay/plugins/weather_plugin.py +11 -12
- mmrelay/runtime_utils.py +35 -0
- mmrelay/setup_utils.py +324 -129
- 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.2.dist-info}/METADATA +7 -7
- mmrelay-1.2.2.dist-info/RECORD +48 -0
- mmrelay-1.2.1.dist-info/RECORD +0 -45
- {mmrelay-1.2.1.dist-info → mmrelay-1.2.2.dist-info}/WHEEL +0 -0
- {mmrelay-1.2.1.dist-info → mmrelay-1.2.2.dist-info}/entry_points.txt +0 -0
- {mmrelay-1.2.1.dist-info → mmrelay-1.2.2.dist-info}/licenses/LICENSE +0 -0
- {mmrelay-1.2.1.dist-info → mmrelay-1.2.2.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 if it
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
If importing
|
|
481
|
-
background thread to stop this MessageQueue, and returns False.
|
|
476
|
+
Return True if it is currently safe to send a message via Meshtastic.
|
|
477
|
+
|
|
478
|
+
Performs runtime checks: ensures the global reconnecting flag is not set, a Meshtastic client object is available, and — if the client exposes `is_connected` (callable or boolean) — that it reports connected. Returns False if any check fails.
|
|
479
|
+
|
|
480
|
+
If importing the Meshtastic utilities raises ImportError, the method will asynchronously stop this MessageQueue and return 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 message mapping (mesh message id → Matrix event) and optionally prune old mappings.
|
|
521
|
+
|
|
522
|
+
If mapping_info contains 'matrix_event_id', 'room_id', and 'text', 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)
|
|
529
|
-
- room_id (str)
|
|
530
|
-
- text (str)
|
|
531
|
-
- meshnet (optional):
|
|
532
|
-
- msgs_to_keep (optional, int):
|
|
525
|
+
result: Send function result object with an `id` attribute (the mesh message id).
|
|
526
|
+
mapping_info (dict): Mapping details. Relevant keys:
|
|
527
|
+
- matrix_event_id (str)
|
|
528
|
+
- room_id (str)
|
|
529
|
+
- text (str)
|
|
530
|
+
- meshnet (optional): passed to the store operation
|
|
531
|
+
- msgs_to_keep (optional, int): number of mappings to retain for 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
|