diff --git a/src/chat/chat_event.h b/src/chat/chat_event.h index 0a29727f..ad317dc3 100644 --- a/src/chat/chat_event.h +++ b/src/chat/chat_event.h @@ -21,7 +21,7 @@ extern "C" { #endif /* Типы событий (совпадают с GUI_EVT_* в gui_bridge.h для прямой совместимости) */ -#define CHAT_EVT_MSG_RECEIVED 1 /* [ch_id_len:1][ch_id:var][author_node_id:8] */ +#define CHAT_EVT_MSG_RECEIVED 1 /* [ch_id_len:1][ch_id:var][author_node_id:8][initial_sync:1] */ #define CHAT_EVT_CONNECT_RESULT 2 /* [node_id:8][result:4][channel_id:8] */ #define CHAT_EVT_NEW_PEER 3 /* [node_id:8] */ #define CHAT_EVT_CHANNEL_UPDATED 4 /* [ch_id_len:1][ch_id:var] */ diff --git a/src/chat/chat_msg.c b/src/chat/chat_msg.c index fa099c06..68059f6b 100644 --- a/src/chat/chat_msg.c +++ b/src/chat/chat_msg.c @@ -859,7 +859,8 @@ void on_msg_inserted(struct DB_SYNC_INSTANCE* si, const uint8_t message_id[32], chat_feedback_check_message(inst, ch_id, message_id); uint8_t evt[73]; uint8_t cl = (uint8_t)strlen(ch_id); evt[0] = cl; memcpy(evt + 1, ch_id, cl); memcpy(evt + 1 + cl, &author, 8); - chat_event_post(inst, CHAT_EVT_MSG_RECEIVED, evt, 1 + cl + 8); + evt[1 + cl + 8] = initial_sync != 0; + chat_event_post(inst, CHAT_EVT_MSG_RECEIVED, evt, 1 + cl + 9); /* auto-download media if message contains media metadata (live PUSH/local only). initial-sync (SEND_DATA) media докачивается после sync через per-channel backfill. */ diff --git a/tools/chatgui/transport/gui_bridge.h b/tools/chatgui/transport/gui_bridge.h index 8ae6a5f0..a2ca2f1f 100644 --- a/tools/chatgui/transport/gui_bridge.h +++ b/tools/chatgui/transport/gui_bridge.h @@ -19,7 +19,7 @@ struct UTUN_INSTANCE; /* ── Типы уведомлений uasync→GUI (fire-and-forget) ── */ -#define GUI_EVT_MSG_RECEIVED 1 /* data: [ch_id_len:1][ch_id:var][author_node_id:8] */ +#define GUI_EVT_MSG_RECEIVED 1 /* data: [ch_id_len:1][ch_id:var][author_node_id:8][initial_sync:1] */ #define GUI_EVT_CONNECT_RESULT 2 /* data: [node_id:8][result:4][channel_id:8] */ #define GUI_EVT_NEW_PEER 3 /* data: [node_id:8] */ #define GUI_EVT_CHANNEL_UPDATED 4 /* data: [ch_id_len:1][ch_id:var] */ @@ -93,7 +93,7 @@ typedef void (*gui_connect_result_fn)(uint64_t node_id, uint64_t channel_id, int void gui_bridge_set_connect_result_cb(gui_connect_result_fn cb); /* Callback для входящих сообщений (вызывается из GUI-потока) */ -typedef void (*gui_msg_received_fn)(const char* ch_id, int ch_id_len, uint64_t author); +typedef void (*gui_msg_received_fn)(const char* ch_id, int ch_id_len, uint64_t author, int initial_sync); void gui_bridge_set_msg_received_cb(gui_msg_received_fn cb); /* Callback для обновления канала (вызывается из GUI-потока) */