Add message identities and plan the remaining feedback work

This commit is contained in:
evgeny committed 2026-10-06 21:12:53 +02:00
1 parent 8676893d59
commit d40f58d79a
4 files changed
+44 -3

No files matched your search

+9 -3
View File
@@ -7,6 +7,7 @@
#include "../routing_layer/topo_group.h"
#include "../routing_layer/topo_node_sqlite.h"
#include "member_sync.h"
#include "chat_feedback.h"
#include "../transport_layer/etcp_dump.h"
#include "../transport_layer/secure_channel.h"
#include "../../lib/debug_config.h"
@@ -562,6 +563,9 @@ static int db_record_insert(struct DB_SYNC_INSTANCE* si,
sqlite3_stmt* stmt;
int rc;
uint8_t message_id[32];
if (chat_message_id(si->group_id, ts, author_sig, message_id) < 0) return -1;
// Verify author signature (mandatory)
if (db_verify_author_sig(si, ts, author_node_id, json, jlen, author_sig) != 0) {
sqlite3_stmt* del;
@@ -598,8 +602,8 @@ static int db_record_insert(struct DB_SYNC_INSTANCE* si,
if (si_prep(si, &stmt,
"INSERT INTO \"%s\""
" (timestamp,node_id,id,chain_hash,flags,data,"
" author_signature,local_attrs,delivered_peers,delivery_chain)"
" VALUES (?,?,?,?,0,?,?,?,0,'')") != SQLITE_OK)
" author_signature,local_attrs,delivered_peers,delivery_chain,message_id)"
" VALUES (?,?,?,?,0,?,?,?,0,'',?)") != SQLITE_OK)
{ DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "db_record_insert INSERT prep: %s", sqlite3_errmsg(db)); sqlite3_exec(db, "ROLLBACK", NULL, NULL, NULL); return -1; }
sqlite3_bind_int64(stmt, 1, (sqlite3_int64)ts);
sqlite3_bind_int64(stmt, 2, (sqlite3_int64)author_node_id);
@@ -610,6 +614,7 @@ static int db_record_insert(struct DB_SYNC_INSTANCE* si,
sqlite3_bind_blob(stmt, 6, author_sig, DB_SIG_SIZE, SQLITE_STATIC);
if (local_attrs && local_attrs[0]) sqlite3_bind_text(stmt, 7, local_attrs, -1, SQLITE_STATIC);
else sqlite3_bind_text(stmt, 7, "", -1, SQLITE_STATIC);
sqlite3_bind_blob(stmt, 8, message_id, sizeof(message_id), SQLITE_STATIC);
rc = sqlite3_step(stmt);
sqlite3_finalize(stmt);
if (rc != SQLITE_DONE) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "INSERT: %s", sqlite3_errmsg(db)); sqlite3_exec(db, "ROLLBACK", NULL, NULL, NULL); return -1; }
@@ -1707,7 +1712,7 @@ struct DB_SYNC_INSTANCE* db_sync_instance_add(struct UTUN_INSTANCE* inst, const
// Create table — PK is (timestamp, node_id), author_signature NOT NULL
{
char sql[512];
char sql[768];
snprintf(sql, sizeof(sql),
"CREATE TABLE IF NOT EXISTS \"%s\" ("
" timestamp INTEGER NOT NULL,"
@@ -1717,6 +1722,7 @@ struct DB_SYNC_INSTANCE* db_sync_instance_add(struct UTUN_INSTANCE* inst, const
" flags INTEGER NOT NULL DEFAULT 0,"
" data BLOB,"
" author_signature BLOB NOT NULL,"
" message_id BLOB NOT NULL UNIQUE CHECK(length(message_id)=32),"
" local_attrs TEXT DEFAULT '',"
" delivered_peers INTEGER NOT NULL DEFAULT 0,"
" delivery_chain TEXT NOT NULL DEFAULT '',"