From 6ad2905e07dcf9d7f120f36839f6323b97e0b969 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Mon, 9 Dec 2024 23:38:07 +0100 Subject: [PATCH] hs2: change msgpack format and fixes --- solanaceae/ngc_hs2/ngc_hs2_rizzler.cpp | 25 ++++++++----------------- solanaceae/ngc_hs2/ngc_hs2_sigma.cpp | 10 ++++------ solanaceae/ngc_hs2/spec_ngc_hs2.md | 8 +++----- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/solanaceae/ngc_hs2/ngc_hs2_rizzler.cpp b/solanaceae/ngc_hs2/ngc_hs2_rizzler.cpp index 0a7c763..406e34b 100644 --- a/solanaceae/ngc_hs2/ngc_hs2_rizzler.cpp +++ b/solanaceae/ngc_hs2/ngc_hs2_rizzler.cpp @@ -215,8 +215,6 @@ void NGCHS2Rizzler::handleMsgPack(Contact3Handle sync_by_c, const std::vector id; @@ -255,20 +245,22 @@ void NGCHS2Rizzler::handleMsgPack(Contact3Handle sync_by_c, const std::vector(ts); // reactive? + new_real_msg.emplace(from_c); new_real_msg.emplace(sync_by_c.get().parent); new_real_msg.emplace(mid); - if (type == "text" || type == "action") { - bool is_action = type == "action"; + if (j_entry.contains("action") && static_cast(j_entry.at("action"))) { + new_real_msg.emplace(); + } + + if (j_entry.contains("text")) { const std::string& text = j_entry.at("text"); new_real_msg.emplace(text); - if (is_action) { - new_real_msg.emplace(); - } #if 0 std::cout << "msg ts:" << ts @@ -279,7 +271,7 @@ void NGCHS2Rizzler::handleMsgPack(Contact3Handle sync_by_c, const std::vector(now_ts); new_msg.emplace(ts); - new_msg.emplace(ts); // reactive? new_msg.emplace(); _rmm.throwEventConstruct(reg, new_msg); diff --git a/solanaceae/ngc_hs2/ngc_hs2_sigma.cpp b/solanaceae/ngc_hs2/ngc_hs2_sigma.cpp index fe86eff..730be95 100644 --- a/solanaceae/ngc_hs2/ngc_hs2_sigma.cpp +++ b/solanaceae/ngc_hs2/ngc_hs2_sigma.cpp @@ -319,12 +319,11 @@ std::vector NGCHS2Sigma::buildChatLogFileRange(Contact3Handle c, uint64 } j_entry["mid"] = msg_reg.get(e).id; + if (msg_reg.all_of(e)) { + j_entry["action"] = true; + } + if (msg_reg.all_of(e)) { - if (msg_reg.all_of(e)) { - j_entry["msgtype"] = "action"; // TODO: textaction? - } else { - j_entry["msgtype"] = "text"; - } j_entry["text"] = msg_reg.get(e).text; } else if (msg_reg.any_of(e)) { const auto& o = msg_reg.get(e).o; @@ -334,7 +333,6 @@ std::vector NGCHS2Sigma::buildChatLogFileRange(Contact3Handle c, uint64 // HACK: use tox fild_id and file_kind instead!! if (o.all_of()) { - j_entry["msgtype"] = "file"; j_entry["fkind"] = NGCFT1_file_kind::HASH_SHA1_INFO; j_entry["fid"] = nlohmann::json::binary_t{o.get().hash}; } else { diff --git a/solanaceae/ngc_hs2/spec_ngc_hs2.md b/solanaceae/ngc_hs2/spec_ngc_hs2.md index 79e0ed9..b086b10 100644 --- a/solanaceae/ngc_hs2/spec_ngc_hs2.md +++ b/solanaceae/ngc_hs2/spec_ngc_hs2.md @@ -91,8 +91,9 @@ Msgpack array of messages. - ts | 64bit deciseconds - ppk | 32bytes - mid | 16bit - - msgtype | enum (string or number?) - - if text/action | + - if action | + - action | bool + - if text | - text | string | maybe byte array instead? - if file | - fkind | 32bit enum | is this right? @@ -102,9 +103,6 @@ Msgpack array of messages. Name is the actual string key. Data type sizes are suggestions, if not defined by the tox protocol. -How unknown `msgtype`s are handled is client defined. -They can be fully ignored or displayed as broken. - ## TODO - [ ] figure out a pro-active approach (instead of waiting for a range request)