From 9e34e9f838e53af6031578e5ad8832a715ceb233 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 18 Jul 2026 02:55:10 +0300 Subject: [PATCH] fix chatgui: self in member list, online status on reconnect, lb spam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - cs_handle_welcome(): add self to local peers_ so joiner sees own account in channel member list - cs_on_conn_up(): post CHANNEL_PEERS_ONLINE after reconnect so GUI shows connected status (was only posted on conn_down) - etcp_loadbalancer: DEBUG_WARN -> DEBUG_DEBUG for no suitable link: tmr:wait — normal shaper behavior, not a warning --- src/etcp_loadbalancer.c | 2 +- tools/chatgui/transport/chat_sync.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/etcp_loadbalancer.c b/src/etcp_loadbalancer.c index d1803925..7ea8e39b 100644 --- a/src/etcp_loadbalancer.c +++ b/src/etcp_loadbalancer.c @@ -57,7 +57,7 @@ struct ETCP_LINK* etcp_loadbalancer_select_link(struct ETCP_CONN* etcp) { if (available_count == 0) { if (etcp->links) - DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[%s] no suitable link found: tmr:%s", + DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] no suitable link found: tmr:%s", etcp->log_name, etcp->links->shaper_timer?"wait":"rdy"); return NULL; } diff --git a/tools/chatgui/transport/chat_sync.c b/tools/chatgui/transport/chat_sync.c index 48c54682..1a0fed82 100644 --- a/tools/chatgui/transport/chat_sync.c +++ b/tools/chatgui/transport/chat_sync.c @@ -513,6 +513,10 @@ static void cs_on_conn_up(struct ETCP_CONN* conn, void* arg) { } member_sync_set_online(g_cs->inst, peer, 1); + for (int i = 0; i < g_cs->channel_count; i++) { + for (int j = 0; j < g_cs->channels[i].peer_count; j++) + if (g_cs->channels[i].peer_ids[j] == peer) { cs_post_channel_online(g_cs, g_cs->channels[i].channel_id); break; } + } } static void cs_on_conn_down(struct ETCP_CONN* conn, void* arg) { @@ -1204,6 +1208,18 @@ static void cs_handle_welcome(struct chat_sync* cs, uint64_t peer, cs_refresh_channels(cs); + /* add self to local peers table (server added joiner to its DB; client must do the same) */ + { + uint64_t myid = cs->inst->node_id; + const uint8_t* my_x25 = cs->inst->my_keys.public_key; + const uint8_t* my_ed = cs->inst->my_ed25519_pubkey; + const char* my_name = cs->inst->name[0] ? cs->inst->name : ""; + int src = topo_node_sqlite_member_put(db, ch_id, myid, NULL, 0, NULL, 0, my_x25, my_ed, my_name, NULL); + if (src != 0) + DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: member_put(self) FAILED in WELCOME ch=%s rc=%d", CS_ID, ch_id, src); + else + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "%s: WELCOME added self to peers ch=%s node=0x%016llx", CS_ID, ch_id, (unsigned long long)myid); + } uint8_t evt[65]; uint8_t ch_id_len = (uint8_t)strlen(ch_id); evt[0] = ch_id_len; memcpy(evt + 1, ch_id, ch_id_len);