diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 05076097b..22084f42d 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4571,12 +4571,12 @@ inviteGroupCallParticipants group_call_id:int32 user_ids:vector = Ok; setGroupCallParticipantIsSpeaking group_call_id:int32 source:int32 is_speaking:Bool = Ok; //@description Toggles whether a group call participant is muted, unmuted, or allowed to unmute themself -//@group_call_id Group call identifier @user_id User identifier @is_muted Pass true if the user must be muted and false otherwise -toggleGroupCallParticipantIsMuted group_call_id:int32 user_id:int32 is_muted:Bool = Ok; +//@group_call_id Group call identifier @participant Participant identifier @is_muted Pass true if the user must be muted and false otherwise +toggleGroupCallParticipantIsMuted group_call_id:int32 participant:MessageSender is_muted:Bool = Ok; //@description Changes a group call participant's volume level. If the current user can manage the group call, then the participant's volume level will be changed for all users with default volume level -//@group_call_id Group call identifier @user_id User identifier @volume_level New participant's volume level; 1-20000 in hundreds of percents -setGroupCallParticipantVolumeLevel group_call_id:int32 user_id:int32 volume_level:int32 = Ok; +//@group_call_id Group call identifier @participant Participant identifier @volume_level New participant's volume level; 1-20000 in hundreds of percents +setGroupCallParticipantVolumeLevel group_call_id:int32 participant:MessageSender volume_level:int32 = Ok; //@description Loads more group call participants. The loaded participants will be received through updates. Use the field groupCall.loaded_all_participants to check whether all participants has already been loaded //@group_call_id Group call identifier. The group call must be previously received through getGroupCall and must be joined or being joined diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index d1acbdb4f..b8f8a01da 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -640,6 +640,32 @@ void GroupCallManager::on_sync_participants_timeout(GroupCallId group_call_id) { sync_group_call_participants(input_group_call_id); } +DialogId GroupCallManager::get_group_call_participant_id( + const td_api::object_ptr &message_sender) { + if (message_sender == nullptr) { + return DialogId(); + } + switch (message_sender->get_id()) { + case td_api::messageSenderUser::ID: { + UserId user_id(static_cast(message_sender.get())->user_id_); + if (td_->contacts_manager_->have_user_force(user_id)) { + return DialogId(user_id); + } + break; + } + case td_api::messageSenderChat::ID: { + DialogId dialog_id(static_cast(message_sender.get())->chat_id_); + if (td_->messages_manager_->have_dialog_force(dialog_id)) { + return dialog_id; + } + break; + } + default: + UNREACHABLE(); + } + return DialogId(); +} + GroupCallId GroupCallManager::get_group_call_id(InputGroupCallId input_group_call_id, DialogId dialog_id) { if (td_->auth_manager_->is_bot() || !input_group_call_id.is_valid()) { return GroupCallId(); diff --git a/td/telegram/GroupCallManager.h b/td/telegram/GroupCallManager.h index 661fb7327..07011d559 100644 --- a/td/telegram/GroupCallManager.h +++ b/td/telegram/GroupCallManager.h @@ -37,6 +37,8 @@ class GroupCallManager : public Actor { GroupCallManager &operator=(GroupCallManager &&) = delete; ~GroupCallManager() override; + DialogId get_group_call_participant_id(const td_api::object_ptr &message_sender); + GroupCallId get_group_call_id(InputGroupCallId input_group_call_id, DialogId dialog_id); void create_voice_chat(DialogId dialog_id, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 559f1fba7..8ddbe7172 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6026,15 +6026,16 @@ void Td::on_request(uint64 id, const td_api::toggleGroupCallParticipantIsMuted & CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); group_call_manager_->toggle_group_call_participant_is_muted( - GroupCallId(request.group_call_id_), DialogId(UserId(request.user_id_)), request.is_muted_, std::move(promise)); + GroupCallId(request.group_call_id_), group_call_manager_->get_group_call_participant_id(request.participant_), + request.is_muted_, std::move(promise)); } void Td::on_request(uint64 id, const td_api::setGroupCallParticipantVolumeLevel &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); - group_call_manager_->set_group_call_participant_volume_level(GroupCallId(request.group_call_id_), - DialogId(UserId(request.user_id_)), - request.volume_level_, std::move(promise)); + group_call_manager_->set_group_call_participant_volume_level( + GroupCallId(request.group_call_id_), group_call_manager_->get_group_call_participant_id(request.participant_), + request.volume_level_, std::move(promise)); } void Td::on_request(uint64 id, const td_api::loadGroupCallParticipants &request) { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 9bf52e084..50c3b629a 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2702,18 +2702,18 @@ class CliClient final : public Actor { as_user_ids(user_ids))); } else if (op == "tgcpim") { string group_call_id; - string user_id; + string participant_id; bool is_muted; - get_args(args, group_call_id, user_id, is_muted); - send_request(td_api::make_object(as_group_call_id(group_call_id), - as_user_id(user_id), is_muted)); + get_args(args, group_call_id, participant_id, is_muted); + send_request(td_api::make_object( + as_group_call_id(group_call_id), as_message_sender(participant_id), is_muted)); } else if (op == "sgcpvl") { string group_call_id; - string user_id; + string participant_id; int32 volume_level; - get_args(args, group_call_id, user_id, volume_level); - send_request(td_api::make_object(as_group_call_id(group_call_id), - as_user_id(user_id), volume_level)); + get_args(args, group_call_id, participant_id, volume_level); + send_request(td_api::make_object( + as_group_call_id(group_call_id), as_message_sender(participant_id), volume_level)); } else if (op == "lgcp") { string group_call_id; string limit;