Allow to edit chat group call participants.

This commit is contained in:
levlam 2021-03-05 16:03:49 +03:00
parent 3d08e0e18f
commit 3bac31cc16
5 changed files with 45 additions and 16 deletions

View File

@ -4571,12 +4571,12 @@ inviteGroupCallParticipants group_call_id:int32 user_ids:vector<int32> = 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

View File

@ -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<td_api::MessageSender> &message_sender) {
if (message_sender == nullptr) {
return DialogId();
}
switch (message_sender->get_id()) {
case td_api::messageSenderUser::ID: {
UserId user_id(static_cast<const td_api::messageSenderUser *>(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<const td_api::messageSenderChat *>(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();

View File

@ -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<td_api::MessageSender> &message_sender);
GroupCallId get_group_call_id(InputGroupCallId input_group_call_id, DialogId dialog_id);
void create_voice_chat(DialogId dialog_id, Promise<GroupCallId> &&promise);

View File

@ -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) {

View File

@ -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<td_api::toggleGroupCallParticipantIsMuted>(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<td_api::toggleGroupCallParticipantIsMuted>(
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<td_api::setGroupCallParticipantVolumeLevel>(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<td_api::setGroupCallParticipantVolumeLevel>(
as_group_call_id(group_call_id), as_message_sender(participant_id), volume_level));
} else if (op == "lgcp") {
string group_call_id;
string limit;