diff --git a/src/chat/chat_sync.c b/src/chat/chat_sync.c index 4eb88885..4cfa279a 100644 --- a/src/chat/chat_sync.c +++ b/src/chat/chat_sync.c @@ -1057,8 +1057,10 @@ static void cs_handle_channel_info_resp(struct chat_sync* cs, uint64_t peer, } /* save channel to local DB */ - topo_node_sqlite_channel_put(cs->inst->topo_sqlite_db, + int cprc = topo_node_sqlite_channel_put(cs->inst->topo_sqlite_db, ch_id, name, owner, x25519, NULL, ed_pub, NULL, ch_sig); + DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: INFO_RESP channel_put rc=%d ch=%s owner=%016llx ch_x25519=%016llx", + CS_ID, cprc, ch_id, (unsigned long long)owner, *(const uint64_t*)x25519); chat_core_ensure_channel_ready(ch_id); DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: channel ready for sync ch=%s, db_sync will pick up via periodic check or active conn", CS_ID, ch_id); @@ -1113,7 +1115,9 @@ static void cs_handle_channel_info_resp(struct chat_sync* cs, uint64_t peer, cs->inst->name[0] ? cs->inst->name : ""); uint8_t nml = (uint8_t)strlen(juser2); jbuf[joff++] = nml; memcpy(jbuf + joff, juser2, nml); joff += nml; - cs_send(cs, ch_id, peer, jbuf, joff); + int jrc = cs_send(cs, ch_id, peer, jbuf, joff); + DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: JOIN sent myid=%016llx x25519=%016llx join_ts=%llu ch=%s to=0x%016llx rc=%d", + CS_ID, (unsigned long long)myid, *(const uint64_t*)my_x25519, (unsigned long long)join_ts, ch_id, (unsigned long long)peer, jrc); cs->join_timer = uasync_set_timeout(cs->inst->ua, CS_JOIN_TIMEOUT_MS * 10, cs, cs_join_timeout_cb, "cs_join"); } @@ -1295,7 +1299,8 @@ static void cs_handle_welcome(struct chat_sync* cs, uint64_t peer, if (src != 0) DEBUG_ERROR(DEBUG_CATEGORY_MEMBER_SYNC, "%s: member_put(self) FAILED in WELCOME ch=%s rc=%d", CS_ID, ch_id, src); else - DEBUG_DEBUG(DEBUG_CATEGORY_MEMBER_SYNC, "%s: WELCOME added self to peers ch=%s node=0x%016llx", CS_ID, ch_id, (unsigned long long)myid); + DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: WELCOME added self to peers ch=%s node=0x%016llx x25519=%016llx name=%s", + CS_ID, ch_id, (unsigned long long)myid, *(const uint64_t*)my_x25, my_name); } uint8_t evt[65]; uint8_t ch_id_len = (uint8_t)strlen(ch_id); @@ -1305,6 +1310,7 @@ static void cs_handle_welcome(struct chat_sync* cs, uint64_t peer, /* full member list for the newly joined channel */ { uint8_t* members = NULL; int mc = 0; if (chat_core_get_member_list(ch_id, &members, &mc) == 0 && members) { + DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: WELCOME member_list count=%d ch=%s", CS_ID, mc, ch_id); size_t esz = 1 + ch_id_len + 2 + (size_t)mc * CHAT_MEMBER_DISPLAY_SIZE; uint8_t* mevt = u_malloc(esz); if (mevt) { @@ -1443,11 +1449,13 @@ static void cs_handle_channel_invite(struct chat_sync* cs, uint64_t peer, } if (policy == 0) { /* autojoin */ - DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: CHANNEL_INVITE autojoin ch=%s from=%016llx", - CS_ID, ch_id, (unsigned long long)peer); + DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: CHANNEL_INVITE autojoin ch=%s from=%016llx owner=%016llx name=%s", + CS_ID, ch_id, (unsigned long long)peer, (unsigned long long)owner, name); /* Save channel and start join handshake */ - topo_node_sqlite_channel_put(cs->inst->topo_sqlite_db, + int cprc = topo_node_sqlite_channel_put(cs->inst->topo_sqlite_db, ch_id, name, owner, x25519, NULL, ed_pub, NULL, ch_sig); + DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: CHANNEL_INVITE channel_put rc=%d ch=%s ch_x25519=%016llx", + CS_ID, cprc, ch_id, *(const uint64_t*)x25519); chat_core_ensure_channel_ready(ch_id); /* Initiate join: connect back and send CHANNEL_INFO_REQ */ chat_sync_join_channel(cs->inst, ch_id, peer);