fix(chat_sync): peer online status not updated in invite flow
- cs_on_conn_up: call cs_on_peer_status_changed(peer,1) before return in invite path (was skipped, leaving inviter at online=0 in DB) - cs_handle_welcome: remove unconditional set_online(0) — online status is managed by conn_up/conn_down, not by WELCOME - cs_handle_welcome: add cs_post_channel_online() after WELCOME to send PEERS_ONLINE to GUI when channel is fully loaded - cs_post_channel_online: add DEBUG log for PEERS_ONLINE event - db_sync peer_check: suppress spam log when no peers connected
This commit is contained in:
1 parent
82bc432a34
commit
23d6ecac43
2 files changed
+11
-5
No files matched your search
+6
-4
@@ -1267,7 +1267,7 @@ static void db_sync_peer_check_cb(void* arg)
|
||||
return;
|
||||
}
|
||||
|
||||
int total_synced = 0, total_skipped = 0;
|
||||
int total_synced = 0, total_skipped = 0, any_peers = 0;
|
||||
for (int i = 0; i < db->instance_count; i++) {
|
||||
struct DB_SYNC_INSTANCE* si = &db->instances[i];
|
||||
if (!si->enabled) continue;
|
||||
@@ -1278,7 +1278,7 @@ static void db_sync_peer_check_cb(void* arg)
|
||||
struct TOPO_GROUP_CONN_ITEM* item = (struct TOPO_GROUP_CONN_ITEM*)e->data;
|
||||
if (item->conn && item->conn->peer_node_id != 0 && item->conn->links_up && item->conn->initialized) {
|
||||
uint64_t pid = item->conn->peer_node_id;
|
||||
if (pid != db->inst->node_id) { si_peer_add(si, pid); peers_found++; }
|
||||
if (pid != db->inst->node_id) { si_peer_add(si, pid); peers_found++; any_peers = 1; }
|
||||
}
|
||||
e = e->next;
|
||||
}
|
||||
@@ -1314,8 +1314,10 @@ static void db_sync_peer_check_cb(void* arg)
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "peer_check: instances=%d synced=%d skipped=%d",
|
||||
db->instance_count, total_synced, total_skipped);
|
||||
if (any_peers) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "peer_check: instances=%d synced=%d skipped=%d",
|
||||
db->instance_count, total_synced, total_skipped);
|
||||
}
|
||||
|
||||
db->peer_check_timer = uasync_set_timeout(db->inst->ua, DB_SYNC_PEER_CHECK_INTERVAL * 10000u,
|
||||
db, db_sync_peer_check_cb, "db_sync_peer");
|
||||
|
||||
@@ -486,6 +486,7 @@ static void cs_post_channel_online(struct chat_sync* cs, const char* ch_id) {
|
||||
memcpy(evt + 1, ch_id, cl);
|
||||
uint16_t oc = (uint16_t)online; memcpy(evt + 1 + cl, &oc, 2);
|
||||
gui_bridge_post(GUI_EVT_CHANNEL_PEERS_ONLINE, evt, 1 + (int)cl + 2);
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DB_SYNC, "%s: PEERS_ONLINE ch=%.*s online=%d", CS_ID, (int)cl, ch_id, online);
|
||||
}
|
||||
|
||||
/* ── Throttled sync (не чаще CS_SYNC_INTERVAL_MS) ── */
|
||||
@@ -600,6 +601,8 @@ static void cs_on_conn_up(struct ETCP_CONN* conn, void* arg) {
|
||||
cs_send(g_cs, ch_id_str, peer, req, 1);
|
||||
g_cs->info_req_timer = uasync_set_timeout(g_cs->inst->ua,
|
||||
CS_INFO_REQ_TIMEOUT_MS * 10, g_cs, cs_info_req_timeout_cb, "cs_info_req");
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: conn_up invite path, marking peer=%016llx online", CS_ID, (unsigned long long)peer);
|
||||
cs_on_peer_status_changed(peer, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1336,7 +1339,6 @@ static void cs_handle_welcome(struct chat_sync* cs, uint64_t peer,
|
||||
CS_ID, (unsigned long long)node_id, sid, port);
|
||||
}
|
||||
member_sync_cancel(g_cs->inst, node_id, ch_id);
|
||||
member_sync_set_online(g_cs->inst, node_id, 0);
|
||||
}
|
||||
|
||||
cs_refresh_channels(cs);
|
||||
@@ -1360,6 +1362,8 @@ static void cs_handle_welcome(struct chat_sync* cs, uint64_t peer,
|
||||
|
||||
gui_bridge_post(GUI_EVT_MEMBERS_CHANGED, evt, 1 + ch_id_len);
|
||||
|
||||
cs_post_channel_online(cs, ch_id);
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: WELCOME processed ch=%s peers=%d — message sync triggered via db_sync (active conn or peer_check timer every 5s)",
|
||||
CS_ID, ch_id, pc);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user