Sync configured chat names and embed the Windows application icon
This commit is contained in:
1 parent
7140775d8d
commit
50017b7f74
8 files changed
+91
-5
No files matched your search
@@ -145,7 +145,7 @@ struct update_my_name_arg { struct UTUN_INSTANCE* inst; char name[128]; };
|
||||
void chat_core_update_my_name_trampoline(void* arg);
|
||||
/* Обновить адреса topo_node и собственные member-записи каналов. */
|
||||
void chat_core_sync_my_addresses(struct UTUN_INSTANCE* inst);
|
||||
/* Обновить своё userinfo во всех каналах: увеличить update_ts, подписать и запустить sync.
|
||||
/* При изменении своего userinfo в каналах увеличить update_ts, подписать и запустить sync.
|
||||
* Адреса обновляются отдельно через topo_node; подпись member-блока их не содержит. */
|
||||
void chat_core_update_my_member(struct UTUN_INSTANCE* inst);
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ static int profile_update_channel(struct UTUN_INSTANCE* inst, const char* ch, in
|
||||
if (profile_pair(&profile, "name", inst->name) < 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT, "profile: display name exceeds profile limit channel=%s", ch); return -1;
|
||||
}
|
||||
char query[256]; snprintf(query, sizeof(query), "SELECT update_ts,userinfo FROM \"%s\" WHERE node_id=?", tbl);
|
||||
char query[256]; snprintf(query, sizeof(query), "SELECT update_ts,userinfo,update_sig FROM \"%s\" WHERE node_id=?", tbl);
|
||||
sqlite3_stmt* st = NULL;
|
||||
if (sqlite3_prepare_v2(cc->db, query, -1, &st, NULL) != SQLITE_OK) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT, "profile: query failed channel=%s: %s", ch, sqlite3_errmsg(cc->db)); return -1;
|
||||
@@ -154,6 +154,8 @@ static int profile_update_channel(struct UTUN_INSTANCE* inst, const char* ch, in
|
||||
sqlite3_finalize(st); return -1;
|
||||
}
|
||||
uint64_t local_uts = (uint64_t)sqlite3_column_int64(st, 0);
|
||||
int signed_profile = local_uts && sqlite3_column_bytes(st, 2) == 64
|
||||
&& memcmp(sqlite3_column_blob(st, 2), (uint8_t[64]){0}, 64);
|
||||
const char* old = (const char*)sqlite3_column_text(st, 1);
|
||||
char before[MS_USERINFO_MAX + 1] = "";
|
||||
if (old && strlen(old) > MS_USERINFO_MAX) {
|
||||
@@ -182,8 +184,9 @@ static int profile_update_channel(struct UTUN_INSTANCE* inst, const char* ch, in
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT, "profile: attributes exceed profile limit channel=%s", ch); return -1;
|
||||
}
|
||||
profile.text[profile.used++] = '}'; profile.text[profile.used] = 0;
|
||||
if (option_count && !strcmp(before, profile.text)) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_CHAT, "profile: options unchanged channel=%s", ch); return 0;
|
||||
if (signed_profile && !strcmp(before, profile.text)) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_CHAT, "profile: unchanged channel=%s name=%s ts=%llu", ch, inst->name,
|
||||
(unsigned long long)local_uts); return 0;
|
||||
}
|
||||
if (local_uts >= INT64_MAX) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT, "profile: version exhausted channel=%s", ch); return -1; }
|
||||
time_t seconds = ntp_time_get_seconds(inst);
|
||||
@@ -198,7 +201,8 @@ static int profile_update_channel(struct UTUN_INSTANCE* inst, const char* ch, in
|
||||
int rc = member_sync_put(inst, ch, myid, inst->my_keys.public_key, inst->my_ed25519_pubkey, join_sig, join_ts,
|
||||
update_sig, update_ts, profile.text, NULL, NULL, 0, 0, NULL);
|
||||
if (rc < 0) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT, "profile: update failed channel=%s result=%d", ch, rc); return -1; }
|
||||
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: update my member ch=%s ts=%llu", CC_ID, ch, (unsigned long long)update_ts);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: update my member ch=%s name=%s ts=%llu", CC_ID, ch, inst->name,
|
||||
(unsigned long long)update_ts);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -791,6 +791,8 @@ int chat_service_start(struct UTUN_INSTANCE* instance) {
|
||||
if (db_sync_enable(instance) < 0) return -1;
|
||||
topo_group_invite_init(instance);
|
||||
if (chat_core_init(instance, db_file) < 0 || chat_sync_init(instance) < 0 || stream_service_init(instance) < 0) goto fail;
|
||||
/* Имя из конфига публикуем подписанным member-блоком после восстановления Merkle. */
|
||||
if (instance->config->global.chatserver_enabled) chat_core_update_my_member(instance);
|
||||
instance->media_async = media_async_create();
|
||||
if (!instance->media_async || media_delivery_init(instance) < 0) goto fail;
|
||||
if (chat_attachment_init(instance) < 0) goto fail;
|
||||
|
||||
Reference in new issue
Block a user