From 956e70d841731d5a7bae6bba0c1aba7f6de02308 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 21 Dec 2020 13:47:19 +0300 Subject: [PATCH] Add groupCall.can_be_managed flag. --- td/generate/scheme/td_api.tl | 5 +++-- td/generate/scheme/td_api.tlo | Bin 191512 -> 191552 bytes td/telegram/GroupCallManager.cpp | 24 +++++++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 7acae297c..e8dac7221 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2071,14 +2071,15 @@ callStateError error:error = CallState; //@is_active True, if the call is active //@is_joined True, if the call is joined //@need_rejoin True, if user was kicked from the call because of network loss and the call needs to be rejoined -//@can_unmute_self True, if the user can unmute themself +//@can_unmute_self True, if the current user can unmute themself +//@can_be_managed True, if the current user can manage the group call //@participant_count Number of participants in the group call //@loaded_all_participants True, if all group call participants are loaded //@recent_speaker_user_ids Identifiers of recently speaking users in the group call //@mute_new_participants True, if only group call administrators can unmute new participants //@allowed_change_mute_new_participants True, if group call administrators can enable or disable mute_new_participants setting //@duration Call duration; for ended calls only -groupCall id:int32 is_active:Bool is_joined:Bool need_rejoin:Bool can_unmute_self:Bool participant_count:int32 loaded_all_participants:Bool recent_speaker_user_ids:vector mute_new_participants:Bool allowed_change_mute_new_participants:Bool duration:int32 = GroupCall; +groupCall id:int32 is_active:Bool is_joined:Bool need_rejoin:Bool can_unmute_self:Bool can_be_managed:Bool participant_count:int32 loaded_all_participants:Bool recent_speaker_user_ids:vector mute_new_participants:Bool allowed_change_mute_new_participants:Bool duration:int32 = GroupCall; //@description Describes a payload fingerprint for interaction with tgcalls @hash Value of the field hash @setup Value of the field setup @fingerprint Value of the field fingerprint groupCallPayloadFingerprint hash:string setup:string fingerprint:string = GroupCallPayloadFingerprint; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 217e7fe7385510f7c8b137aee8f94e178a2e0aca..c92950cd4f574c4b75076ffba2bd597db5e70f80 100644 GIT binary patch delta 123 zcmbPngZsb@?hO(`EHWGahHaJ+(pV-5VsWMy<(C#XC+6fZFo5_sj|utkOfK|Np4_lw z%Jd6@j2x`FiFt|XlM{oaH;e4FU9SAHJCTO;5wti_A_4@FO-4#lQ$Gt NfEnBGm&C6~#j9su$7C9?nk diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index 9eec77eb9..33761ef2e 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -410,6 +410,7 @@ struct GroupCallManager::GroupCall { bool is_being_left = false; bool is_speaking = false; bool can_self_unmute = false; + bool can_be_managed = false; bool syncing_participants = false; bool loaded_all_participants = false; bool mute_new_participants = false; @@ -702,8 +703,8 @@ void GroupCallManager::get_group_call(GroupCallId group_call_id, } void GroupCallManager::on_update_group_call_rights(InputGroupCallId input_group_call_id) { + auto group_call = get_group_call(input_group_call_id); if (need_group_call_participants(input_group_call_id)) { - auto group_call = get_group_call(input_group_call_id); CHECK(group_call != nullptr && group_call->is_inited); try_load_group_call_administrators(input_group_call_id, group_call->dialog_id); @@ -717,6 +718,14 @@ void GroupCallManager::on_update_group_call_rights(InputGroupCallId input_group_ } } + if (group_call != nullptr && group_call->is_inited) { + bool can_be_managed = group_call->is_active && can_manage_group_calls(group_call->dialog_id).is_ok(); + if (can_be_managed != group_call->can_be_managed) { + group_call->can_be_managed = can_be_managed; + send_update_group_call(group_call, "on_update_group_call_rights"); + } + } + reload_group_call(input_group_call_id, Auto()); } @@ -1809,6 +1818,7 @@ void GroupCallManager::on_group_call_left_impl(GroupCall *group_call, bool need_ group_call->is_being_left = false; group_call->is_speaking = false; group_call->can_self_unmute = false; + group_call->can_be_managed = false; group_call->joined_date = 0; group_call->source = 0; group_call->loaded_all_participants = false; @@ -1910,8 +1920,8 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptrgroup_call_id; call.dialog_id = dialog_id.is_valid() ? dialog_id : group_call->dialog_id; - call.can_self_unmute = - call.is_active && (!call.mute_new_participants || can_manage_group_calls(call.dialog_id).is_ok()); + call.can_be_managed = call.is_active && can_manage_group_calls(call.dialog_id).is_ok(); + call.can_self_unmute = (call.is_active && !call.mute_new_participants) || call.can_be_managed; if (!group_call->dialog_id.is_valid()) { group_call->dialog_id = dialog_id; } @@ -1955,6 +1965,10 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptrallowed_change_mute_new_participants = call.allowed_change_mute_new_participants; need_update = true; } + if (call.can_be_managed != group_call->can_be_managed) { + group_call->can_be_managed = call.can_be_managed; + need_update = true; + } if (call.version > group_call->version) { if (group_call->version != -1) { // if we know group call version, then update participants only by corresponding updates @@ -2232,8 +2246,8 @@ tl_object_ptr GroupCallManager::get_group_call_object(const G return td_api::make_object( group_call->group_call_id.get(), group_call->is_active, group_call->is_joined, group_call->need_rejoin, - group_call->can_self_unmute, group_call->participant_count, group_call->loaded_all_participants, - std::move(recent_speaker_user_ids), group_call->mute_new_participants, + group_call->can_self_unmute, group_call->can_be_managed, group_call->participant_count, + group_call->loaded_all_participants, std::move(recent_speaker_user_ids), group_call->mute_new_participants, group_call->allowed_change_mute_new_participants, group_call->duration); }