From e8365fdec6efbb5039fe821cc3a2d63c93c0b671 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 6 Oct 2026 14:04:49 +0200 Subject: [PATCH] Upgrade group avatar columns before notifying database readiness --- src/chat/chat_core.c | 5 +++++ tests/test_group_avatar.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/chat/chat_core.c b/src/chat/chat_core.c index c42f43ad..ffd4a61c 100644 --- a/src/chat/chat_core.c +++ b/src/chat/chat_core.c @@ -11,6 +11,7 @@ */ #include "chat_core_priv.h" +#include "group_avatar.h" #include "chat_event.h" #include "chat_setting.h" #include "chat_member.h" @@ -101,6 +102,10 @@ int chat_core_init(struct UTUN_INSTANCE* inst, const char* db_path) { sqlite3_exec(cc->db, "PRAGMA foreign_keys=ON", NULL, NULL, NULL); } + if (group_avatar_schema_init(cc->db) < 0) { + if (!cc->shared_db) sqlite3_close(cc->db); + inst->chat_core = NULL; u_free(cc); return -1; + } cc->inst = inst; cc->my_node_id = inst->node_id; diff --git a/tests/test_group_avatar.c b/tests/test_group_avatar.c index 493ffd42..a45371f1 100644 --- a/tests/test_group_avatar.c +++ b/tests/test_group_avatar.c @@ -119,6 +119,10 @@ int main(void) { group_x, NULL, group_public, NULL, signature)); assert(!group_avatar_get(nodes[0], GROUP, ©) && copy.version == first.version); uint8_t private_key[32]; assert(!topo_node_sqlite_channel_get_priv(nodes[0]->topo_sqlite_db, CHANNEL, private_key)); + uint8_t wrong_pub[32] = {1}; + assert(topo_node_sqlite_channel_put(nodes[0]->topo_sqlite_db, CHANNEL, "avatar", nodes[0]->node_id, + group_x, NULL, wrong_pub, NULL, signature) < 0); + assert(!group_avatar_get(nodes[0], GROUP, ©) && copy.version == first.version); etcp_router_set_receive_ready(nodes[1], ETCP_RT_ID_GROUP_AVATAR, hold); image[0] ^= 1; assert(!group_avatar_set(nodes[0], GROUP, image, 4097));