Add groupCall.can_unmute_self.

This commit is contained in:
levlam 2020-12-16 14:04:07 +03:00
parent 03c22f2866
commit 7fc2e783ed
3 changed files with 31 additions and 7 deletions

View File

@ -2070,13 +2070,14 @@ callStateError error:error = CallState;
//@id Group call identifier
//@is_active True, if the call is active
//@is_joined True, if the call is joined
//@can_unmute_self True, if the user can unmute themself
//@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 loaded_all_participants:Bool recent_speaker_user_ids:vector<int32> mute_new_participants:Bool allowed_change_mute_new_participants:Bool duration:int32 = GroupCall;
groupCall id:int32 is_active:Bool is_joined:Bool can_unmute_self:Bool participant_count:int32 loaded_all_participants:Bool recent_speaker_user_ids:vector<int32> 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;
@ -2093,9 +2094,9 @@ groupCallJoinResponseCandidate port:string protocol:string network:string genera
groupCallJoinResponse payload:groupCallPayload candidates:vector<groupCallJoinResponseCandidate> = GroupCallJoinResponse;
//@description Represents a group call participant @user_id Identifier of the user @source User's synchronization source
//@is_speaking True, if the user is speaking as set by setGroupCallParticipantIsSpeaking @is_muted True, if the user is muted @can_self_unmute True, if the user can unmute themself
//@is_speaking True, if the user is speaking as set by setGroupCallParticipantIsSpeaking @is_muted True, if the user is muted @can_unmute_self True, if the user can unmute themself
//@order User's order in the group call participant list. The bigger is order, the higher is user in the list. If order is 0, the user must be removed from the participant list
groupCallParticipant user_id:int32 source:int32 is_speaking:Bool is_muted:Bool can_self_unmute:Bool order:int64 = GroupCallParticipant;
groupCallParticipant user_id:int32 source:int32 is_speaking:Bool is_muted:Bool can_unmute_self:Bool order:int64 = GroupCallParticipant;
//@class CallProblem @description Describes the exact type of a problem with a call

Binary file not shown.

View File

@ -405,6 +405,7 @@ struct GroupCallManager::GroupCall {
bool is_active = false;
bool is_joined = false;
bool is_speaking = false;
bool can_self_unmute = false;
bool syncing_participants = false;
bool loaded_all_participants = false;
bool mute_new_participants = false;
@ -777,7 +778,8 @@ void GroupCallManager::on_get_group_call_participants(
<< group_call->version;
return;
}
LOG(INFO) << "Finish syncing participants in " << input_group_call_id << " from " << group_call->dialog_id;
LOG(INFO) << "Finish syncing participants in " << input_group_call_id << " from " << group_call->dialog_id
<< " with version " << participants->version_;
group_call->version = participants->version_;
}
}
@ -1140,6 +1142,16 @@ int GroupCallManager::process_group_call_participant(InputGroupCallId input_grou
}
LOG(INFO) << "Process " << participant << " in " << input_group_call_id;
if (participant.user_id == td_->contacts_manager_->get_my_id()) {
auto *group_call = get_group_call(input_group_call_id);
CHECK(group_call != nullptr && group_call->is_inited);
if (group_call->is_joined && group_call->is_active && group_call->can_self_unmute != participant.can_self_unmute) {
group_call->can_self_unmute = participant.can_self_unmute;
send_update_group_call(group_call, "process_group_call_participant");
}
}
auto &participants = group_call_participants_[input_group_call_id];
if (participants == nullptr) {
participants = make_unique<GroupCallParticipants>();
@ -1518,6 +1530,10 @@ void GroupCallManager::toggle_group_call_participant_is_muted(GroupCallId group_
if (user_id != td_->contacts_manager_->get_my_id()) {
TRY_STATUS_PROMISE(promise, can_manage_group_calls(group_call->dialog_id));
} else {
if (!is_muted && !group_call->can_self_unmute) {
return promise.set_error(Status::Error(400, "Can't unmute self"));
}
}
td_->create_handler<EditGroupCallMemberQuery>(std::move(promise))->send(input_group_call_id, user_id, is_muted);
@ -1605,6 +1621,7 @@ void GroupCallManager::on_group_call_left_impl(GroupCall *group_call) {
CHECK(group_call != nullptr && group_call->is_inited && group_call->is_joined);
group_call->is_joined = false;
group_call->is_speaking = false;
group_call->can_self_unmute = false;
group_call->source = 0;
group_call->loaded_all_participants = false;
group_call->version = -1;
@ -1705,6 +1722,8 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
auto *group_call = add_group_call(input_group_call_id, dialog_id);
call.group_call_id = group_call->group_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());
if (!group_call->dialog_id.is_valid()) {
group_call->dialog_id = dialog_id;
}
@ -1750,6 +1769,10 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
}
if (need_group_call_participants(input_group_call_id) && !join_params.empty()) {
LOG(INFO) << "Init " << call.group_call_id << " version to " << call.version;
if (group_call->can_self_unmute != call.can_self_unmute) {
group_call->can_self_unmute = call.can_self_unmute;
need_update = true;
}
group_call->version = call.version;
if (process_pending_group_call_participant_updates(input_group_call_id)) {
need_update = false;
@ -2014,9 +2037,9 @@ tl_object_ptr<td_api::groupCall> GroupCallManager::get_group_call_object(const G
CHECK(group_call->is_inited);
return td_api::make_object<td_api::groupCall>(
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);
group_call->group_call_id.get(), group_call->is_active, group_call->is_joined, 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->allowed_change_mute_new_participants, group_call->duration);
}
tl_object_ptr<td_api::updateGroupCall> GroupCallManager::get_update_group_call_object(