Prioritize supernodes in invites and update chat background and ringtone

This commit is contained in:
evgeny committed 2026-09-30 12:56:59 +03:00
1 parent 0d44ada922
commit 7ebc282eb2
5 files changed
+51 -6

No files matched your search

+7 -4
View File
@@ -65,7 +65,7 @@ static int node_has_both_public(struct UTUN_INSTANCE* inst, uint64_t node_id) {
static uint64_t pick_best_node(struct UTUN_INSTANCE* inst, uint64_t channel_id, int* out_has_both_public, int* out_priority) {
struct chat_core_ctx* cc = CC(inst);
uint64_t best_nid = 0;
int best_priority = 4; /* 1=regular, 2=self, 3=super, 4=invalid */
int best_priority = 4; /* 1=super, 2=regular, 3=self, 4=invalid */
int best_has_both = 0;
struct TOPO_GROUP* grp = resolve_chat_group(inst, channel_id);
@@ -99,9 +99,9 @@ static uint64_t pick_best_node(struct UTUN_INSTANCE* inst, uint64_t channel_id,
int has_both = node_has_both_public(inst, nid);
int priority;
if (nid == cc->my_node_id) priority = 2; /* self */
else if (ntype == 4) priority = 3; /* supernode */
else priority = 1; /* regular */
if (ntype == 4) priority = 1; /* supernode, включая self */
else if (nid == cc->my_node_id) priority = 3;
else priority = 2;
if (priority <= best_priority) {
best_nid = nid;
@@ -122,6 +122,9 @@ static uint64_t resolve_auto_node(struct UTUN_INSTANCE* inst, uint64_t channel_i
int has_both = 0, prio = 4;
uint64_t best = pick_best_node(inst, channel_id, &has_both, &prio);
if (best == 0) best = cc->my_node_id;
DEBUG_INFO(DEBUG_CATEGORY_CHAT_SYNC, "invite_build: auto selection ch=%llu node=0x%016llx role=%s self=%d",
(unsigned long long)channel_id, (unsigned long long)best,
prio == 1 ? "supernode" : prio == 2 ? "regular" : "self", best == cc->my_node_id);
if (out_has_both) *out_has_both = has_both;
if (out_priority) *out_priority = prio;
return best;
+2 -2
View File
@@ -20,7 +20,7 @@ struct chat_invite_build;
typedef void (*chat_invite_ready_fn)(void* arg, int result, const char* link);
/* Собрать invite-ссылку для канала.
* target_node_id = 0 → auto (лучший достижимый мембер, иначе self).
* target_node_id = 0 → auto (достижимый суперузел → обычный узел → self).
* target_node_id != 0 → конкретный узел (должен быть достижимым мембером канала).
* password = NULL → без пароля.
* NULL=ошибка запуска, callback не вызывается. Иначе callback после возврата,
@@ -35,7 +35,7 @@ void chat_invite_build_cancel(struct chat_invite_build* request);
* Возвращает количество (0..max_ids), либо -1. */
int chat_invite_candidate_nodes(struct UTUN_INSTANCE* inst, uint64_t channel_id, uint64_t* out_ids, int max_ids);
/* Авто-узел: лучший достижимый мембер, иначе self. Возвращает 0 и заполняет out_node_id, либо -1. */
/* Авто-узел: достижимый суперузел → обычный узел → self. Возвращает 0 и заполняет out_node_id, либо -1. */
int chat_invite_best_node(struct UTUN_INSTANCE* inst, uint64_t channel_id, uint64_t* out_node_id);
/* Трамплин для gui_bridge (arg = u_malloc(struct chat_invite_build_req)).