From 7fc19c3733fdbba59cd833a36d9f1b499874fda3 Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 12 Dec 2020 01:00:00 +0300 Subject: [PATCH] Add groupCall.loaded_all_participants flag. --- td/generate/scheme/td_api.tl | 3 ++- td/generate/scheme/td_api.tlo | Bin 190924 -> 190972 bytes td/telegram/GroupCallManager.cpp | 44 ++++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index b5172937b..b40abed15 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2067,11 +2067,12 @@ callStateError error:error = CallState; //@is_active True, if the call is active //@is_joined True, if the call is joined //@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 participant_count:int32 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 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 2f92af113ea53d09cbc9d783dfaa3fec548ee9ab..e2496dfeb574d8966a4b204a53edd0fa17b3cec0 100644 GIT binary patch delta 130 zcmX?enfuRW?hO(`ED5JtUu~8VIcontacts_manager_->on_get_users(std::move(participants->users_), "on_get_group_call_participants"); + if (!need_group_call_participants(input_group_call_id)) { + return; + } + + auto is_empty = participants->participants_.empty(); process_group_call_participants(input_group_call_id, std::move(participants->participants_), is_load); on_receive_group_call_version(input_group_call_id, participants->version_); @@ -667,6 +673,29 @@ void GroupCallManager::on_get_group_call_participants( participants_it->second->next_offset = std::move(participants->next_offset_); } } + + if (is_empty) { + bool need_update = false; + auto group_call = get_group_call(input_group_call_id); + CHECK(group_call != nullptr && group_call->is_inited); + if (!group_call->loaded_all_participants) { + group_call->loaded_all_participants = true; + need_update = true; + } + + auto real_participant_count = participants_it != group_call_participants_.end() + ? static_cast(participants_it->second->participants.size()) + : 0; + if (real_participant_count != group_call->participant_count) { + LOG(ERROR) << "Have participant count " << group_call->participant_count << " instead of " + << real_participant_count << " in " << input_group_call_id; + group_call->participant_count = real_participant_count; + need_update = true; + } + if (need_update) { + send_update_group_call(group_call); + } + } } } @@ -1228,6 +1257,13 @@ void GroupCallManager::try_clear_group_call_participants(InputGroupCallId input_ CHECK(participants != nullptr); group_call_participants_.erase(participants_it); + auto group_call = get_group_call(input_group_call_id); + CHECK(group_call != nullptr && group_call->is_inited); + if (group_call->loaded_all_participants) { + group_call->loaded_all_participants = false; + send_update_group_call(group_call); + } + for (auto &participant : participants->participants) { if (participant.order != 0) { CHECK(participant.order >= participants->min_order); @@ -1510,10 +1546,10 @@ tl_object_ptr GroupCallManager::get_group_call_object(const G CHECK(group_call != nullptr); CHECK(group_call->is_inited); - return td_api::make_object(group_call->group_call_id.get(), group_call->is_active, - group_call->is_joined, group_call->participant_count, - std::move(recent_speaker_user_ids), group_call->mute_new_participants, - group_call->allowed_change_mute_new_participants, group_call->duration); + return td_api::make_object( + group_call->group_call_id.get(), group_call->is_active, group_call->is_joined, 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); } tl_object_ptr GroupCallManager::get_update_group_call_object(