fix(chat): commit radio mute before applying cache and reporting success
This commit is contained in:
1 parent
32a8c1c48b
commit
1bb824fb8a
3 files changed
+49
-23
No files matched your search
@@ -274,14 +274,15 @@ int chat_core_get_single_member(struct UTUN_INSTANCE* inst, const char* ch_id, u
|
||||
|
||||
int chat_core_toggle_member_radio_mute(struct UTUN_INSTANCE* inst, const char* ch_id, uint64_t node_id) {
|
||||
uint8_t member[CHAT_MEMBER_DISPLAY_SIZE];
|
||||
if (!ch_id || !ch_id[0] || strlen(ch_id) >= 64 || chat_core_get_single_member(inst, ch_id, node_id, member) < 0) {
|
||||
if (!chat_channel_id(ch_id) || chat_core_get_single_member(inst, ch_id, node_id, member) < 0) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_RADIO, "radio: mute toggle member not found node=%016llx", (unsigned long long)node_id); return -1;
|
||||
}
|
||||
int muted = !(member[10] & CHAT_MEMBER_FLAG_RADIO_MUTED);
|
||||
if (radio_set_member_muted(inst, strtoull(ch_id, NULL, 10), node_id, muted) < 0) return -1;
|
||||
if (chat_core_get_single_member(inst, ch_id, node_id, member) < 0) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_RADIO, "radio: cannot publish local mute ch=%s node=%016llx",
|
||||
ch_id, (unsigned long long)node_id); return -1;
|
||||
/* Снимок уже готов: после committed mute нет нового чтения, способного превратить успех в ошибку. */
|
||||
member[10] = (uint8_t)((member[10] & ~CHAT_MEMBER_FLAG_RADIO_MUTED) | (muted ? CHAT_MEMBER_FLAG_RADIO_MUTED : 0));
|
||||
if (!inst->topo_groups || !topo_groups_find(inst->topo_groups, strtoull(ch_id, NULL, 10))) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_RADIO, "radio: mute committed, group removed by audio callback ch=%s", ch_id); return 0;
|
||||
}
|
||||
size_t cl = strlen(ch_id);
|
||||
uint8_t evt[1 + 64 + 1 + CHAT_MEMBER_DISPLAY_SIZE];
|
||||
|
||||
Reference in new issue
Block a user