|
|
|
@ -283,10 +283,12 @@ void chat_core_update_my_name(const char* name) { |
|
|
|
} |
|
|
|
} |
|
|
|
EVP_PKEY_free(pkey); |
|
|
|
EVP_PKEY_free(pkey); |
|
|
|
} |
|
|
|
} |
|
|
|
topo_node_sqlite_member_put(g_cc.db, ch, myid, new_sig, join_ts, NULL, 0, |
|
|
|
int r1 = topo_node_sqlite_member_put(g_cc.db, ch, myid, new_sig, join_ts, NULL, 0, |
|
|
|
g_cc.inst->my_keys.public_key, g_cc.inst->my_ed25519_pubkey, name, NULL); |
|
|
|
g_cc.inst->my_keys.public_key, g_cc.inst->my_ed25519_pubkey, name, NULL); |
|
|
|
member_sync_put(g_cc.inst, ch, myid, g_cc.inst->my_keys.public_key, |
|
|
|
if (r1 != 0) DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: member_put(my_name) FAILED ch=%s rc=%d", CC_ID, ch, r1); |
|
|
|
g_cc.inst->my_ed25519_pubkey, new_sig, join_ts, NULL, 0, name, NULL, 0); |
|
|
|
int r2 = member_sync_put(g_cc.inst, ch, myid, g_cc.inst->my_keys.public_key, |
|
|
|
|
|
|
|
g_cc.inst->my_ed25519_pubkey, new_sig, join_ts, NULL, 0, name, NULL, 0); |
|
|
|
|
|
|
|
if (r2 != 0) DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: member_sync_put(my_name) FAILED ch=%s rc=%d", CC_ID, ch, r2); |
|
|
|
uint8_t evt[65]; uint8_t cl = (uint8_t)strlen(ch); |
|
|
|
uint8_t evt[65]; uint8_t cl = (uint8_t)strlen(ch); |
|
|
|
evt[0] = cl; memcpy(evt + 1, ch, cl); |
|
|
|
evt[0] = cl; memcpy(evt + 1, ch, cl); |
|
|
|
gui_bridge_post(GUI_EVT_MEMBERS_CHANGED, evt, 1 + cl); |
|
|
|
gui_bridge_post(GUI_EVT_MEMBERS_CHANGED, evt, 1 + cl); |
|
|
|
@ -1034,7 +1036,11 @@ void chat_core_ensure_channel_ready(const char* ch_id) { |
|
|
|
" join_sig BLOB," |
|
|
|
" join_sig BLOB," |
|
|
|
" join_ts INTEGER DEFAULT 0," |
|
|
|
" join_ts INTEGER DEFAULT 0," |
|
|
|
" update_sig BLOB," |
|
|
|
" update_sig BLOB," |
|
|
|
" update_ts INTEGER DEFAULT 0" |
|
|
|
" update_ts INTEGER DEFAULT 0," |
|
|
|
|
|
|
|
" name TEXT NOT NULL DEFAULT ''," |
|
|
|
|
|
|
|
" creator_sig BLOB," |
|
|
|
|
|
|
|
" comment TEXT," |
|
|
|
|
|
|
|
" joined_at INTEGER DEFAULT (unixepoch())" |
|
|
|
")", tbl_peers); |
|
|
|
")", tbl_peers); |
|
|
|
db_exec(sql); |
|
|
|
db_exec(sql); |
|
|
|
|
|
|
|
|
|
|
|
@ -1065,9 +1071,7 @@ void chat_core_create_channel(struct chat_channel_create* req) { |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: create_channel BEGIN ch=%s name=%s", |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: create_channel BEGIN ch=%s name=%s", |
|
|
|
CC_ID, req->channel_id, req->name); |
|
|
|
CC_ID, req->channel_id, req->name); |
|
|
|
|
|
|
|
|
|
|
|
chat_core_ensure_channel_ready(req->channel_id); |
|
|
|
/* записываем канал в БД ПЕРВЫМ — создаст полную схему peers_<ch_id> (11 колонок) */ |
|
|
|
|
|
|
|
|
|
|
|
/* записываем канал в БД */ |
|
|
|
|
|
|
|
int rc = topo_node_sqlite_channel_put(g_cc.db, |
|
|
|
int rc = topo_node_sqlite_channel_put(g_cc.db, |
|
|
|
req->channel_id, req->name, req->is_dm, req->owner_node_id, |
|
|
|
req->channel_id, req->name, req->is_dm, req->owner_node_id, |
|
|
|
req->x25519_pubkey, req->x25519_privkey, |
|
|
|
req->x25519_pubkey, req->x25519_privkey, |
|
|
|
@ -1081,6 +1085,9 @@ void chat_core_create_channel(struct chat_channel_create* req) { |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: channel_put OK ch=%s name=%s owner=0x%016llx", |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CONNECTIVITY, "%s: channel_put OK ch=%s name=%s owner=0x%016llx", |
|
|
|
CC_ID, req->channel_id, req->name, (unsigned long long)req->owner_node_id); |
|
|
|
CC_ID, req->channel_id, req->name, (unsigned long long)req->owner_node_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* после полной схемы — готовим таблицы и db_sync */ |
|
|
|
|
|
|
|
chat_core_ensure_channel_ready(req->channel_id); |
|
|
|
|
|
|
|
|
|
|
|
uint8_t ch_id_len = (uint8_t)strlen(req->channel_id); |
|
|
|
uint8_t ch_id_len = (uint8_t)strlen(req->channel_id); |
|
|
|
uint8_t data[65]; |
|
|
|
uint8_t data[65]; |
|
|
|
data[0] = ch_id_len; |
|
|
|
data[0] = ch_id_len; |
|
|
|
@ -1113,9 +1120,13 @@ void chat_core_create_channel(struct chat_channel_create* req) { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
memset(join_sig, 0, 64); |
|
|
|
memset(join_sig, 0, 64); |
|
|
|
} |
|
|
|
} |
|
|
|
member_sync_put(g_cc.inst, req->channel_id, myid, |
|
|
|
int mrc = member_sync_put(g_cc.inst, req->channel_id, myid, |
|
|
|
g_cc.inst->my_keys.public_key, g_cc.inst->my_ed25519_pubkey, |
|
|
|
g_cc.inst->my_keys.public_key, g_cc.inst->my_ed25519_pubkey, |
|
|
|
join_sig, join_ts, NULL, 0, g_cc.inst->name, NULL, 0); |
|
|
|
join_sig, join_ts, NULL, 0, g_cc.inst->name, NULL, 0); |
|
|
|
|
|
|
|
if (mrc != 0) { |
|
|
|
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTIVITY, "%s: member_sync_put(self) FAILED ch=%s rc=%d", |
|
|
|
|
|
|
|
CC_ID, req->channel_id, mrc); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* notify GUI — members already in DB, channel will show with self as participant */ |
|
|
|
/* notify GUI — members already in DB, channel will show with self as participant */ |
|
|
|
|