Outgoing echoes were recorded optimistically regardless of whether the broadcast was actually submitted. Now broadcastChatMemos / broadcastChatMemosLite return whether the send was submitted (false on immediate failures: not connected, no spendable z-address, or a lite send already in progress), and the echo records a ChatDelivery status (Sent / Failed). The Chat tab shows a "not sent" marker in the error color on failed messages. The status persists in the DB (backward- compatible: old rows deserialize as Sent). (A later async failure — an opid that fails after submission — still surfaces via the existing send-progress notification; only the submit gate is reflected here.) Also removes the now-unused chat_readonly_note string (the composer replaced the read-only footer). Test: delivery status round-trips through the DB. Verified: Linux + Windows build with chat ON, ctest 100%, hygiene clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
1.3 KiB
C++
31 lines
1.3 KiB
C++
#pragma once
|
|
|
|
// DragonX Wallet - HushChat decrypted message model. Held in memory by ChatStore and persisted at
|
|
// rest (encrypted under a seed-derived key) by ChatDatabase.
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace dragonx::chat {
|
|
|
|
enum class ChatDirection { Incoming, Outgoing };
|
|
enum class ChatMessageKind { Message, ContactRequest };
|
|
// Outgoing delivery: Sent = the broadcast was submitted; Failed = it wasn't (not connected, no
|
|
// spendable address, a send already in progress). Always Sent for incoming.
|
|
enum class ChatDelivery { Sent, Failed };
|
|
|
|
struct ChatMessage {
|
|
ChatDirection direction = ChatDirection::Incoming;
|
|
ChatMessageKind kind = ChatMessageKind::Message;
|
|
std::string txid;
|
|
std::string conversation_id; // cid — the conversation thread key
|
|
std::string peer_zaddr; // header "z": peer's reply z-address
|
|
std::string peer_public_key_hex; // header "p": peer's crypto_kx public key
|
|
std::string body; // decrypted plaintext (Message) or request text (ContactRequest)
|
|
std::int64_t timestamp = 0; // tx time in seconds; set by the ingesting caller
|
|
std::size_t payload_position = 0; // together with txid, the dedup key
|
|
ChatDelivery delivery = ChatDelivery::Sent; // outgoing only
|
|
};
|
|
|
|
} // namespace dragonx::chat
|