mirror of
https://github.com/vicliu624/trail-mate.git
synced 2026-08-06 18:59:43 +00:00
Refactor Reticulum runtime and delivery state
Split LXMF runtime ownership into focused peer, path, link, propagation, and delivery helpers while keeping the adapter as the coordination layer. Make chat delivery refs and send-result events protocol-aware across Reticulum, Meshtastic, and MeshCore, including Sent/Delivered/Failed semantics, UI badges, retry lookup, and store persistence. Fix Meshtastic MQTT private replies to publish encrypted direct packets and cover the new delivery behavior with smoke tests.
This commit is contained in:
@@ -356,6 +356,21 @@ class PagingStore final : public ::chat::IChatStore
|
||||
return false;
|
||||
}
|
||||
|
||||
bool updateMessageStatusForProtocol(::chat::MessageId msg_id,
|
||||
::chat::MeshProtocol protocol,
|
||||
::chat::MessageStatus status) override
|
||||
{
|
||||
for (auto& msg : messages_)
|
||||
{
|
||||
if (msg.msg_id == msg_id && msg.protocol == protocol)
|
||||
{
|
||||
msg.status = status;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool getMessage(::chat::MessageId msg_id,
|
||||
::chat::ChatMessage* out) const override
|
||||
{
|
||||
@@ -373,6 +388,24 @@ class PagingStore final : public ::chat::IChatStore
|
||||
return false;
|
||||
}
|
||||
|
||||
bool getMessageForProtocol(::chat::MessageId msg_id,
|
||||
::chat::MeshProtocol protocol,
|
||||
::chat::ChatMessage* out) const override
|
||||
{
|
||||
for (const auto& msg : messages_)
|
||||
{
|
||||
if (msg.msg_id == msg_id && msg.protocol == protocol)
|
||||
{
|
||||
if (out)
|
||||
{
|
||||
*out = msg;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<::chat::ChatMessage> messages_;
|
||||
int unread_ = 0;
|
||||
@@ -516,6 +549,8 @@ int main()
|
||||
|
||||
::chat::delivery::ChatDeliveryRecord delivered{};
|
||||
delivered.ref.protocol_id = 100;
|
||||
delivered.ref.protocol =
|
||||
static_cast<uint8_t>(::chat::MeshProtocol::Meshtastic);
|
||||
delivered.state = ::chat::delivery::DeliveryState::Delivered;
|
||||
delivered.failure = ::chat::delivery::DeliveryFailureKind::None;
|
||||
assert(delivery_read_model.upsert(delivered));
|
||||
@@ -574,7 +609,11 @@ int main()
|
||||
assert(radio_offline_send.failure == ui::UiActionFailure::RadioOffline);
|
||||
mesh.fail_returns_msg_id = true;
|
||||
assert(delivery_read_model.upsert(::chat::delivery::toFailedDeliveryRecord(
|
||||
::chat::delivery::ChatDeliveryRef{0, 101, 0},
|
||||
::chat::delivery::ChatDeliveryRef{
|
||||
0,
|
||||
101,
|
||||
0,
|
||||
static_cast<uint8_t>(::chat::MeshProtocol::Meshtastic)},
|
||||
::chat::delivery::SendFailureKind::PeerKeyMissing)));
|
||||
assert(source.buildChatWorkspaceSnapshot(request, snapshot));
|
||||
assert(snapshot.message_count == 2);
|
||||
@@ -583,7 +622,11 @@ int main()
|
||||
ui::chat::MessageFailureKind::PeerKeyMissing);
|
||||
|
||||
assert(delivery_read_model.upsert(::chat::delivery::toFailedDeliveryRecord(
|
||||
::chat::delivery::ChatDeliveryRef{0, 101, 0},
|
||||
::chat::delivery::ChatDeliveryRef{
|
||||
0,
|
||||
101,
|
||||
0,
|
||||
static_cast<uint8_t>(::chat::MeshProtocol::Meshtastic)},
|
||||
::chat::delivery::SendFailureKind::ChannelKeyMissing)));
|
||||
assert(source.buildChatWorkspaceSnapshot(request, snapshot));
|
||||
assert(snapshot.message_count == 2);
|
||||
|
||||
Reference in New Issue
Block a user