mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-07-04 00:42:01 +02:00
Pass 1 on PATH integration
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""Shared direct-message ACK application logic."""
|
||||
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
|
||||
from app.services import dm_ack_tracker
|
||||
from app.services.messages import increment_ack_and_broadcast
|
||||
|
||||
BroadcastFn = Callable[..., Any]
|
||||
|
||||
|
||||
async def apply_dm_ack_code(ack_code: str, *, broadcast_fn: BroadcastFn) -> bool:
|
||||
"""Apply a DM ACK code using the shared pending/buffered state machine.
|
||||
|
||||
Returns True when the ACK matched a pending message, False when it was buffered.
|
||||
"""
|
||||
dm_ack_tracker.cleanup_expired_acks()
|
||||
|
||||
message_id = dm_ack_tracker.pop_pending_ack(ack_code)
|
||||
if message_id is None:
|
||||
dm_ack_tracker.buffer_unmatched_ack(ack_code)
|
||||
return False
|
||||
|
||||
dm_ack_tracker.clear_pending_acks_for_message(message_id)
|
||||
await increment_ack_and_broadcast(message_id=message_id, broadcast_fn=broadcast_fn)
|
||||
return True
|
||||
Reference in New Issue
Block a user