chat_core: connect_channel API — запуск topo_group_connect_init при выборе канала из GUI, убрано дублирование создания групп в utun_node

This commit is contained in:
Evgeny committed 2026-07-23 12:51:45 +03:00
1 parent be258eea4d
commit 0e324cf36d
4 files changed
+43 -19

No files matched your search

-19
View File
@@ -316,25 +316,6 @@ void UtunNode::runLoop() {
chat_core_init(m_instance, QString(m_dbPath + "/chats.db").toUtf8().constData());
chat_sync_init(m_instance, nullptr);
/* create TOPO_GROUP_TYPE_CHAT for all existing channels */
if (m_instance->topo_groups) {
uint8_t buf[4096]; size_t ch_len = 0;
chat_core_list_channels(buf, sizeof(buf), &ch_len);
if (ch_len >= 2) {
uint16_t cnt; memcpy(&cnt, buf, 2);
const uint8_t* p = buf + 2; size_t rem = ch_len - 2;
for (uint16_t i = 0; i < cnt && rem >= 1; i++) {
uint8_t id_len = *p++; rem--;
if (rem < id_len) break;
char ch_id[64]; memcpy(ch_id, p, id_len < 63 ? id_len : 63); ch_id[id_len < 63 ? id_len : 63] = 0;
p += id_len; rem -= id_len;
uint64_t gid = strtoull(ch_id, NULL, 10);
if (gid != 0 && !topo_groups_find(m_instance->topo_groups, gid))
topo_groups_create_group(m_instance->topo_groups, gid, TOPO_GROUP_TYPE_CHAT, ch_id);
}
}
}
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "chat_core + chat_sync initialized");
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "utun_node: entering poll loop");