|
|
|
|
@ -14,6 +14,7 @@
|
|
|
|
|
#include "../../lib/json_flat.h" |
|
|
|
|
#include "member_sync.h" |
|
|
|
|
#include "merkle_sync.h" |
|
|
|
|
#include "chat_feedback.h" |
|
|
|
|
|
|
|
|
|
#include "../utun_instance.h" |
|
|
|
|
#include "../transport_layer/etcp_api.h" |
|
|
|
|
@ -537,12 +538,21 @@ static void cs_resume_db_sync(struct chat_sync* cs, const char* ch_id) {
|
|
|
|
|
if (si) db_sync_instance_set_gated(si, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Подтверждение feedback не управляет готовностью участников или истории сообщений. */ |
|
|
|
|
static void cs_feedback_done(uint64_t peer, const char* channel, int result, void* arg) { |
|
|
|
|
(void)arg; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CHAT_SYNC, "%s: feedback sync ch=%s peer=%016llx result=%d", |
|
|
|
|
CS_ID, channel, (unsigned long long)peer, result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void _on_member_sync_done(uint64_t peer, const char* ns, int result, void* arg) { |
|
|
|
|
struct chat_sync* cs = (struct chat_sync*)arg; |
|
|
|
|
if (result == MT_OK) { |
|
|
|
|
struct channel_cache* ch = cs ? cs_find(cs, ns) : NULL; |
|
|
|
|
if (ch) ch->synced = CS_SYNC_DONE; |
|
|
|
|
cs_resume_db_sync(cs, ns); |
|
|
|
|
if (cs && merkle_sync_start(cs->inst, MT_DATA_FEEDBACK, peer, ns, cs_feedback_done, cs) < 0) |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_CHAT_SYNC, "%s: feedback sync unavailable ch=%s peer=%016llx", CS_ID, ns, (unsigned long long)peer); |
|
|
|
|
} |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: member_sync %s ns=%s peer=%016llx", |
|
|
|
|
CS_ID, result == MT_OK ? "OK" : "FAIL", ns, (unsigned long long)peer); |
|
|
|
|
@ -753,6 +763,10 @@ int chat_sync_init(struct UTUN_INSTANCE* inst) {
|
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_MEMBER_SYNC, "%s: member synchronization initialization failed", CS_ID); |
|
|
|
|
inst->chat_sync = NULL; u_free(cs); return -1; |
|
|
|
|
} |
|
|
|
|
if (chat_feedback_init(inst) < 0) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "%s: feedback initialization failed", CS_ID); |
|
|
|
|
member_sync_destroy(inst); inst->chat_sync = NULL; u_free(cs); return -1; |
|
|
|
|
} |
|
|
|
|
if (group_avatar_init(inst) < 0) { |
|
|
|
|
member_sync_destroy(inst); inst->chat_sync = NULL; u_free(cs); return -1; |
|
|
|
|
} |
|
|
|
|
|