|
|
|
|
@ -369,15 +369,20 @@ struct invite_sync_arg {
|
|
|
|
|
|
|
|
|
|
static void _on_invite_sync_done(uint64_t peer, const char* ns, int result, void* arg) { |
|
|
|
|
struct invite_sync_arg* sa = (struct invite_sync_arg*)arg; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: invite_sync %s ns=%s peer=%016llx node=0x%016llx", |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: invite_sync %s ns=%s peer=%016llx sa=%p node=0x%016llx ch=%s", |
|
|
|
|
CS_ID, result == MT_OK ? "OK" : "FAIL", ns, |
|
|
|
|
(unsigned long long)peer, sa ? (unsigned long long)sa->node_id : 0); |
|
|
|
|
(unsigned long long)peer, (void*)sa, sa ? (unsigned long long)sa->node_id : 0, sa ? sa->ch_id : "(null)"); |
|
|
|
|
if (result == MT_OK && sa && g_cs) { |
|
|
|
|
cs_post_channel_online(g_cs, sa->ch_id); |
|
|
|
|
uint8_t one = 1; |
|
|
|
|
merkle_sync_push_update(g_cs->inst, sa->ch_id, sa->node_id, 0x01, &one, 1); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: invite_sync push_update node=0x%016llx online=1 ch=%s", |
|
|
|
|
CS_ID, (unsigned long long)sa->node_id, sa->ch_id); |
|
|
|
|
if (sa->node_id == 0 || sa->ch_id[0] == '\0') { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_DB_SYNC, "%s: invite_sync CORRUPTED sa=%p node_id=0x%016llx ch_id='%s' — skip, will free", |
|
|
|
|
CS_ID, (void*)sa, (unsigned long long)sa->node_id, sa->ch_id); |
|
|
|
|
} else { |
|
|
|
|
cs_post_channel_online(g_cs, sa->ch_id); |
|
|
|
|
uint8_t one = 1; |
|
|
|
|
merkle_sync_push_update(g_cs->inst, sa->ch_id, sa->node_id, 0x01, &one, 1); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: invite_sync push_update node=0x%016llx online=1 ch=%s", |
|
|
|
|
CS_ID, (unsigned long long)sa->node_id, sa->ch_id); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
u_free(sa); |
|
|
|
|
} |
|
|
|
|
@ -1126,6 +1131,7 @@ static void cs_handle_channel_join(struct chat_sync* cs, uint64_t peer,
|
|
|
|
|
struct invite_sync_arg* sa = u_malloc(sizeof(struct invite_sync_arg)); |
|
|
|
|
if (sa) { sa->node_id = node_id; |
|
|
|
|
strncpy(sa->ch_id, ch_id, sizeof(sa->ch_id) - 1); sa->ch_id[sizeof(sa->ch_id) - 1] = '\0'; |
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_DB_SYNC, "%s: JOIN alloc sa=%p node=0x%016llx ch=%s", CS_ID, (void*)sa, (unsigned long long)sa->node_id, sa->ch_id); |
|
|
|
|
member_sync_start(cs->inst, node_id, ch_id, _on_invite_sync_done, sa); } |
|
|
|
|
else member_sync_start(cs->inst, node_id, ch_id, NULL, NULL); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: JOIN starting member_sync with joiner node=0x%016llx ch=%s done_cb=%s", |
|
|
|
|
|