Return queue rejection for invite and private conversation requests
This commit is contained in:
1 parent
dcf330ddc8
commit
b15591fe93
3 files changed
+35
-30
No files matched your search
@@ -99,8 +99,9 @@ object NativeLib {
|
||||
|
||||
fun getMyNodeId(): Long = nativeGetMyNodeId()
|
||||
|
||||
fun requestInviteCandidates(channelId: String) { nativeRequestInviteCandidates(channelId) }
|
||||
fun requestInviteLink(channelId: String, targetNodeId: Long, requestId: Long) { nativeRequestInviteLink(channelId, targetNodeId, requestId) }
|
||||
fun requestInviteCandidates(channelId: String): Boolean = nativeRequestInviteCandidates(channelId)
|
||||
fun requestInviteLink(channelId: String, targetNodeId: Long, requestId: Long): Boolean =
|
||||
nativeRequestInviteLink(channelId, targetNodeId, requestId)
|
||||
fun requestLocalDevices(): Boolean = nativeRequestLocalDevices()
|
||||
fun sendLocalInvite(peer: Long, request: Long, link: String): Boolean =
|
||||
nativeSendLocalInvite(peer, request, link.toByteArray(Charsets.UTF_8))
|
||||
@@ -378,7 +379,7 @@ object NativeLib {
|
||||
fun radioTalkEnd(groupId: Long) { nativeRadioTalkEnd(groupId) }
|
||||
|
||||
/* ── DM (личные сообщения) ── */
|
||||
fun dmStart(nodeId: Long, sourceChId: String, peerName: String) { nativeDmStart(nodeId, sourceChId, peerName) }
|
||||
fun dmStart(nodeId: Long, sourceChId: String, peerName: String): Boolean = nativeDmStart(nodeId, sourceChId, peerName)
|
||||
/** UTF-8 без Modified UTF-8: true подтверждает очередь, CHAT_EVT_MSG_SUBMITTED — запись истории/outbox. */
|
||||
fun dmSend(convId: String, text: String, generation: Long, requestId: Long): Boolean =
|
||||
nativeDmSend(convId, text.toByteArray(Charsets.UTF_8), generation, requestId)
|
||||
@@ -422,8 +423,8 @@ object NativeLib {
|
||||
private external fun nativeRegenerateKeys(configText: String): Boolean
|
||||
private external fun nativeClearDatabase(): Boolean
|
||||
private external fun nativeGetMyNodeId(): Long
|
||||
private external fun nativeRequestInviteCandidates(channelId: String)
|
||||
private external fun nativeRequestInviteLink(channelId: String, targetNodeId: Long, requestId: Long)
|
||||
private external fun nativeRequestInviteCandidates(channelId: String): Boolean
|
||||
private external fun nativeRequestInviteLink(channelId: String, targetNodeId: Long, requestId: Long): Boolean
|
||||
private external fun nativeRequestLocalDevices(): Boolean
|
||||
private external fun nativeSendLocalInvite(peer: Long, request: Long, link: ByteArray): Boolean
|
||||
private external fun nativeRestart(configText: String): Boolean
|
||||
@@ -521,7 +522,7 @@ object NativeLib {
|
||||
|
||||
/* ── DM JNI ── */
|
||||
private external fun nativeDmDelete(convId: String, generation: Long, request: Long): Boolean
|
||||
private external fun nativeDmStart(nodeId: Long, sourceChId: String, peerName: String)
|
||||
private external fun nativeDmStart(nodeId: Long, sourceChId: String, peerName: String): Boolean
|
||||
private external fun nativeDmSend(convId: String, text: ByteArray, generation: Long, requestId: Long): Boolean
|
||||
private external fun nativeDmInvite(requestId: Long, peer: Long, source: String, channelId: Long, name: String, cancel: Boolean): Boolean
|
||||
private external fun nativeIsChannelMember(channelId: String, nodeId: Long): Boolean
|
||||
|
||||
@@ -280,33 +280,33 @@ void utun_bridge_connect_node(const char* address, int port, const char* pubkey_
|
||||
#include "chat/chat_core.h"
|
||||
#include "chat/chat_core_priv.h"
|
||||
|
||||
void utun_bridge_request_invite_candidates(const char* channel_id) {
|
||||
int utun_bridge_request_invite_candidates(const char* channel_id) {
|
||||
if (!channel_id || !channel_id[0]) {
|
||||
bridge_log(BLEV_ERROR, "request_invite_candidates: null ch_id");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
if (!instance_lite_is_running()) { bridge_log(BLEV_ERROR, "request_invite_candidates: uasync not running"); return; }
|
||||
if (!instance_lite_is_running()) { bridge_log(BLEV_ERROR, "request_invite_candidates: uasync not running"); return -1; }
|
||||
struct chat_invite_cand_req* req = u_calloc(1, sizeof(*req));
|
||||
if (!req) { bridge_log(BLEV_ERROR, "request_invite_candidates: OOM"); return; }
|
||||
if (!req) { bridge_log(BLEV_ERROR, "request_invite_candidates: OOM"); return -1; }
|
||||
snprintf(req->ch_id, sizeof(req->ch_id), "%s", channel_id);
|
||||
bridge_log(BLEV_INFO, "request_invite_candidates ch=%s", channel_id);
|
||||
bridge_post_request(chat_invite_candidates_trampoline, req, &req->inst);
|
||||
return bridge_post_request(chat_invite_candidates_trampoline, req, &req->inst);
|
||||
}
|
||||
|
||||
void utun_bridge_request_invite_link(const char* channel_id, uint64_t target_node_id, uint64_t request_id) {
|
||||
int utun_bridge_request_invite_link(const char* channel_id, uint64_t target_node_id, uint64_t request_id) {
|
||||
if (!channel_id || !channel_id[0]) {
|
||||
bridge_log(BLEV_ERROR, "request_invite_link: null ch_id");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
if (!instance_lite_is_running()) { bridge_log(BLEV_ERROR, "request_invite_link: uasync not running"); return; }
|
||||
if (!instance_lite_is_running()) { bridge_log(BLEV_ERROR, "request_invite_link: uasync not running"); return -1; }
|
||||
struct chat_invite_build_req* req = u_calloc(1, sizeof(*req));
|
||||
if (!req) { bridge_log(BLEV_ERROR, "request_invite_link: OOM"); return; }
|
||||
if (!req) { bridge_log(BLEV_ERROR, "request_invite_link: OOM"); return -1; }
|
||||
strncpy(req->ch_id, channel_id, sizeof(req->ch_id) - 1);
|
||||
req->request_id = request_id;
|
||||
req->target_node_id = target_node_id;
|
||||
bridge_log(BLEV_INFO, "request_invite_link ch=%s target=0x%016llx",
|
||||
channel_id, (unsigned long long)target_node_id);
|
||||
bridge_post_request(chat_invite_build_link_trampoline, req, &req->inst);
|
||||
return bridge_post_request(chat_invite_build_link_trampoline, req, &req->inst);
|
||||
}
|
||||
|
||||
void utun_bridge_connect_channel(const char* channel_id) {
|
||||
@@ -635,18 +635,18 @@ uint64_t utun_bridge_get_my_node_id(void) {
|
||||
|
||||
/* ── DM (личные сообщения) ── */
|
||||
|
||||
void utun_bridge_dm_start(uint64_t node_id, const char* source_ch_id, const char* peer_name) {
|
||||
if (!node_id) { bridge_log(BLEV_ERROR, "dm_start: invalid node_id=0"); return; }
|
||||
if (!instance_lite_is_running()) { bridge_log(BLEV_ERROR, "dm_start: core not running"); return; }
|
||||
int utun_bridge_dm_start(uint64_t node_id, const char* source_ch_id, const char* peer_name) {
|
||||
if (!node_id) { bridge_log(BLEV_ERROR, "dm_start: invalid node_id=0"); return -1; }
|
||||
if (!instance_lite_is_running()) { bridge_log(BLEV_ERROR, "dm_start: core not running"); return -1; }
|
||||
struct dm_start_req* req = u_calloc(1, sizeof(*req));
|
||||
if (!req) { bridge_log(BLEV_ERROR, "dm_start: OOM"); return; }
|
||||
if (!req) { bridge_log(BLEV_ERROR, "dm_start: OOM"); return -1; }
|
||||
req->inst = instance_lite_get_instance();
|
||||
req->peer_node_id = node_id;
|
||||
if (source_ch_id) strncpy(req->source_ch_id, source_ch_id, sizeof(req->source_ch_id) - 1);
|
||||
if (peer_name) strncpy(req->peer_name, peer_name, sizeof(req->peer_name) - 1);
|
||||
bridge_log(BLEV_INFO, "dm_start queued peer=0x%016llx ch=%s",
|
||||
(unsigned long long)node_id, source_ch_id ? source_ch_id : "");
|
||||
bridge_post_request(dm_start_trampoline, req, &req->inst);
|
||||
return bridge_post_request(dm_start_trampoline, req, &req->inst);
|
||||
}
|
||||
|
||||
int utun_bridge_dm_send(const char* conv_id, const uint8_t* text, size_t length, uint64_t generation, uint64_t request_id) {
|
||||
@@ -2059,20 +2059,22 @@ JNIEXPORT jlong JNICALL Java_com_utun_chat_data_NativeLib_nativeDeriveNodeId(
|
||||
|
||||
/* ── nativeRequestInviteCandidates / nativeRequestInviteLink ── */
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeRequestInviteCandidates(
|
||||
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeRequestInviteCandidates(
|
||||
JNIEnv* env, jobject thiz, jstring channelId) {
|
||||
(void)thiz;
|
||||
const char* ch = jni_utf8(env, channelId);
|
||||
utun_bridge_request_invite_candidates(ch);
|
||||
int result = utun_bridge_request_invite_candidates(ch);
|
||||
if (ch) u_free((void*)ch);
|
||||
return result == 0 ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeRequestInviteLink(
|
||||
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeRequestInviteLink(
|
||||
JNIEnv* env, jobject thiz, jstring channelId, jlong targetNodeId, jlong requestId) {
|
||||
(void)thiz;
|
||||
const char* ch = jni_utf8(env, channelId);
|
||||
utun_bridge_request_invite_link(ch, (uint64_t)targetNodeId, (uint64_t)requestId);
|
||||
int result = utun_bridge_request_invite_link(ch, (uint64_t)targetNodeId, (uint64_t)requestId);
|
||||
if (ch) u_free((void*)ch);
|
||||
return result == 0 ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
/* ── nativeSetEventCallback(eventCb) ── */
|
||||
@@ -2264,14 +2266,15 @@ JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeFeedbackComma
|
||||
((char*)(req + 1))[len] = 0; int posted = bridge_post_request(chat_feedback_command_trampoline, req, &req->inst); return posted == 0 ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeDmStart(
|
||||
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeDmStart(
|
||||
JNIEnv* env, jobject thiz, jlong nodeId, jstring sourceChId, jstring peerName) {
|
||||
(void)thiz;
|
||||
const char* ch = sourceChId ? jni_utf8(env, sourceChId) : NULL;
|
||||
const char* nm = peerName ? jni_utf8(env, peerName) : NULL;
|
||||
utun_bridge_dm_start((uint64_t)nodeId, ch, nm);
|
||||
int result = utun_bridge_dm_start((uint64_t)nodeId, ch, nm);
|
||||
if (nm) u_free((void*)nm);
|
||||
if (ch) u_free((void*)ch);
|
||||
return result == 0 ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeDmSend(
|
||||
|
||||
@@ -205,8 +205,9 @@ void utun_bridge_radio_talk_end(uint64_t group_id);
|
||||
|
||||
/* ── Invite link (for sharing) — асинхронно через uasync-поток.
|
||||
Результат приходит событиями CHAT_EVT_INVITE_CANDIDATES / CHAT_EVT_INVITE_LINK_READY. ── */
|
||||
void utun_bridge_request_invite_candidates(const char* channel_id);
|
||||
void utun_bridge_request_invite_link(const char* channel_id, uint64_t target_node_id, uint64_t request_id);
|
||||
/* 0 — принято worker, -1 — ошибка аргументов/памяти/готовности, события не будет. */
|
||||
int utun_bridge_request_invite_candidates(const char* channel_id);
|
||||
int utun_bridge_request_invite_link(const char* channel_id, uint64_t target_node_id, uint64_t request_id);
|
||||
|
||||
/* Применить уровень синхронно: пустая/NULL category → общий уровень, иначе имя из debug_config. */
|
||||
|
||||
@@ -283,7 +284,7 @@ void utun_bridge_collect_conn_metrics(uint64_t peer_node_id);
|
||||
* dm_start/dm_send выполняются асинхронно через uasync (трамплины dm_core).
|
||||
* Результат dm_start — CHAT_EVT_DM_CONV_UPDATED; source_ch_id/peer_name могут быть NULL.
|
||||
* generation в send/history/file относится к поколению беседы, не к instance. */
|
||||
void utun_bridge_dm_start(uint64_t node_id, const char* source_ch_id, const char* peer_name);
|
||||
int utun_bridge_dm_start(uint64_t node_id, const char* source_ch_id, const char* peer_name); /* 0 — принято, -1 — отказ без события. */
|
||||
/* Копирует 1..DM_DATA_MAX UTF-8 байт без NUL в очередь; generation/request_id ненулевые.
|
||||
* 0 — запрос принят, результат локальной записи придёт CHAT_EVT_MSG_SUBMITTED; -1 — отказ без события. */
|
||||
int utun_bridge_dm_send(const char* conv_id, const uint8_t* text, size_t length, uint64_t generation, uint64_t request_id);
|
||||
|
||||
Reference in new issue
Block a user