Improve group call method and field names.

This commit is contained in:
levlam 2020-12-08 17:51:37 +03:00
parent 901d603808
commit 6e3e129b13
8 changed files with 82 additions and 78 deletions

View File

@ -1638,7 +1638,7 @@ messageCall is_video:Bool discard_reason:CallDiscardReason duration:int32 = Mess
messageGroupCall group_call_id:int32 duration:int32 = MessageContent;
//@description A message with information about an invite to a group call @group_call_id Group call identifier @user_ids Invited user identifiers
messageInviteGroupCallMembers group_call_id:int32 user_ids:vector<int32> = MessageContent;
messageInviteGroupCallParticipants group_call_id:int32 user_ids:vector<int32> = MessageContent;
//@description A newly created basic group @title Title of the basic group @member_user_ids User identifiers of members in the basic group
messageBasicGroupChatCreate title:string member_user_ids:vector<int32> = MessageContent;
@ -2066,12 +2066,12 @@ callStateError error:error = CallState;
//@id Group call identifier
//@is_active True, if the call is active
//@is_joined True, if the call is joined
//@member_count Number of members in the group call
//@participant_count Number of participants in the group call
//@recent_speaker_user_ids Identifiers of recently speaking users in the group call
//@mute_new_members True, if only group call administrators can unmute new members
//@allowed_change_mute_new_members True, if group call administrators can enable or disable mute_new_members setting
//@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 member_count:int32 recent_speaker_user_ids:vector<int32> mute_new_members:Bool allowed_change_mute_new_members:Bool duration:int32 = GroupCall;
groupCall id:int32 is_active:Bool is_joined:Bool participant_count:int32 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;
@ -2088,7 +2088,7 @@ 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 setGroupCallMemberIsSpeaking @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_self_unmute 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
groupCallParticipant user_id:int32 source:int32 is_speaking:Bool is_muted:Bool can_self_unmute:Bool order:int64 = GroupCallParticipant;
@ -4342,21 +4342,21 @@ getGroupCall group_call_id:int32 = GroupCall;
//@description Joins a group call @group_call_id Group call identifier @payload Group join payload, received from tgcalls @source Caller synchronization source identifier; received from tgcalls @is_muted True, if the user's microphone is muted
joinGroupCall group_call_id:int32 payload:groupCallPayload source:int32 is_muted:Bool = GroupCallJoinResponse;
//@description Toggles whether new members of a group call can be unmuted only by administrators of the group call. Requires can_manage_voice_chats rights in the corresponding chat and allowed_change_mute_mew_members group call flag
//@group_call_id Group call identifier @mute_new_members New value of the mute_new_members setting
toggleGroupCallMuteNewMembers group_call_id:int32 mute_new_members:Bool = Ok;
//@description Toggles whether new participants of a group call can be unmuted only by administrators of the group call. Requires can_manage_voice_chats rights in the corresponding chat and allowed_change_mute_mew_participants group call flag
//@group_call_id Group call identifier @mute_new_participants New value of the mute_new_participants setting
toggleGroupCallMuteNewParticipants group_call_id:int32 mute_new_participants:Bool = Ok;
//@description Invites users to a group call. Sends a service message of type messageInviteToGroupCall for voice chats
//@group_call_id Group call identifier @user_ids User identifiers. At most 10 users can be invited simultaneously
inviteGroupCallMembers group_call_id:int32 user_ids:vector<int32> = Ok;
inviteGroupCallParticipants group_call_id:int32 user_ids:vector<int32> = Ok;
//@description Informs TDLib that a group call member speaking state has changed @group_call_id Group call identifier
//@source Group call member's synchronization source identifier @is_speaking True, if the user is speaking
setGroupCallMemberIsSpeaking group_call_id:int32 source:int32 is_speaking:Bool = Ok;
//@description Informs TDLib that a group call participant speaking state has changed @group_call_id Group call identifier
//@source Group call participant's synchronization source identifier @is_speaking True, if the user is speaking
setGroupCallParticipantIsSpeaking group_call_id:int32 source:int32 is_speaking:Bool = Ok;
//@description Toggles whether a group call member is muted. Requires can_manage_voice_chats rights to mute other group call members
//@description Toggles whether a group call participant is muted. Requires can_manage_voice_chats rights to mute other group call participants
//@group_call_id Group call identifier @user_id User identifier @is_muted Pass true if the user must be muted and false otherwise
toggleGroupCallMemberIsMuted group_call_id:int32 user_id:int32 is_muted:Bool = Ok;
toggleGroupCallParticipantIsMuted group_call_id:int32 user_id:int32 is_muted:Bool = Ok;
//@description Checks whether a group call is still joined. Should be called every 10 seconds when tgcalls notifies about lost connection with the server @group_call_id Group call identifier
checkGroupCallIsJoined group_call_id:int32 = Ok;

Binary file not shown.

View File

@ -371,9 +371,9 @@ struct GroupCallManager::GroupCall {
bool is_active = false;
bool is_joined = false;
bool is_speaking = false;
bool mute_new_members = false;
bool allowed_change_mute_new_members = false;
int32 member_count = 0;
bool mute_new_participants = false;
bool allowed_change_mute_new_participants = false;
int32 participant_count = 0;
int32 version = -1;
int32 duration = 0;
int32 source = 0;
@ -586,7 +586,7 @@ void GroupCallManager::finish_get_group_call(InputGroupCallId input_group_call_i
void GroupCallManager::on_get_group_call_participants(
InputGroupCallId input_group_call_id, tl_object_ptr<telegram_api::phone_groupParticipants> &&participants,
bool is_load) {
LOG(INFO) << "Receive group call members: " << to_string(participants);
LOG(INFO) << "Receive group call participants: " << to_string(participants);
CHECK(participants != nullptr);
td_->contacts_manager_->on_get_users(std::move(participants->users_), "on_get_group_call_participants");
@ -798,16 +798,16 @@ void GroupCallManager::finish_join_group_call(InputGroupCallId input_group_call_
pending_join_requests_.erase(it);
}
void GroupCallManager::toggle_group_call_mute_new_members(GroupCallId group_call_id, bool mute_new_members,
void GroupCallManager::toggle_group_call_mute_new_participants(GroupCallId group_call_id, bool mute_new_participants,
Promise<Unit> &&promise) {
TRY_RESULT_PROMISE(promise, input_group_call_id, get_input_group_call_id(group_call_id));
int32 flags = telegram_api::phone_toggleGroupCallSettings::JOIN_MUTED_MASK;
td_->create_handler<ToggleGroupCallSettingsQuery>(std::move(promise))
->send(flags, input_group_call_id, mute_new_members);
->send(flags, input_group_call_id, mute_new_participants);
}
void GroupCallManager::invite_group_call_members(GroupCallId group_call_id, vector<UserId> &&user_ids,
void GroupCallManager::invite_group_call_participants(GroupCallId group_call_id, vector<UserId> &&user_ids,
Promise<Unit> &&promise) {
TRY_RESULT_PROMISE(promise, input_group_call_id, get_input_group_call_id(group_call_id));
@ -833,7 +833,7 @@ void GroupCallManager::invite_group_call_members(GroupCallId group_call_id, vect
td_->create_handler<InviteToGroupCallQuery>(std::move(promise))->send(input_group_call_id, std::move(input_users));
}
void GroupCallManager::set_group_call_member_is_speaking(GroupCallId group_call_id, int32 source, bool is_speaking,
void GroupCallManager::set_group_call_participant_is_speaking(GroupCallId group_call_id, int32 source, bool is_speaking,
Promise<Unit> &&promise) {
TRY_RESULT_PROMISE(promise, input_group_call_id, get_input_group_call_id(group_call_id));
@ -858,12 +858,12 @@ void GroupCallManager::set_group_call_member_is_speaking(GroupCallId group_call_
on_source_speaking_in_group_call(group_call_id, source, G()->unix_time(), false);
}
// TODO update member list by others speaking actions
// TODO update participant list by others speaking actions
promise.set_value(Unit());
}
void GroupCallManager::toggle_group_call_member_is_muted(GroupCallId group_call_id, UserId user_id, bool is_muted,
void GroupCallManager::toggle_group_call_participant_is_muted(GroupCallId group_call_id, UserId user_id, bool is_muted,
Promise<Unit> &&promise) {
TRY_RESULT_PROMISE(promise, input_group_call_id, get_input_group_call_id(group_call_id));
@ -963,9 +963,9 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
auto group_call = static_cast<const telegram_api::groupCall *>(group_call_ptr.get());
call_id = InputGroupCallId(group_call->id_, group_call->access_hash_);
call.is_active = true;
call.mute_new_members = group_call->join_muted_;
call.allowed_change_mute_new_members = group_call->can_change_join_muted_;
call.member_count = group_call->participants_count_;
call.mute_new_participants = group_call->join_muted_;
call.allowed_change_mute_new_participants = group_call->can_change_join_muted_;
call.participant_count = group_call->participants_count_;
call.version = group_call->version_;
if (group_call->params_ != nullptr) {
join_params = std::move(group_call->params_->data_);
@ -982,7 +982,7 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
default:
UNREACHABLE();
}
if (!call_id.is_valid() || call.member_count < 0) {
if (!call_id.is_valid() || call.participant_count < 0) {
return {};
}
@ -1004,18 +1004,20 @@ InputGroupCallId GroupCallManager::update_group_call(const tl_object_ptr<telegra
td_->contacts_manager_->on_update_channel_group_call(group_call->channel_id, false, false);
}
} else {
auto mute_flags_changed = call.mute_new_members != group_call->mute_new_members ||
call.allowed_change_mute_new_members != group_call->allowed_change_mute_new_members;
auto mute_flags_changed =
call.mute_new_participants != group_call->mute_new_participants ||
call.allowed_change_mute_new_participants != group_call->allowed_change_mute_new_participants;
if (call.version > group_call->version) {
if (group_call->channel_id.is_valid()) {
td_->contacts_manager_->on_update_channel_group_call(group_call->channel_id, true, call.member_count == 0);
td_->contacts_manager_->on_update_channel_group_call(group_call->channel_id, true,
call.participant_count == 0);
}
need_update = call.member_count != group_call->member_count || mute_flags_changed;
need_update = call.participant_count != group_call->participant_count || mute_flags_changed;
*group_call = std::move(call);
} else if (call.version == group_call->version) {
if (mute_flags_changed) {
group_call->mute_new_members = call.mute_new_members;
group_call->allowed_change_mute_new_members = call.allowed_change_mute_new_members;
group_call->mute_new_participants = call.mute_new_participants;
group_call->allowed_change_mute_new_participants = call.allowed_change_mute_new_participants;
need_update = true;
}
}
@ -1118,7 +1120,7 @@ void GroupCallManager::on_source_speaking_in_group_call(GroupCallId group_call_i
return;
}
UserId user_id = get_group_call_member_by_source(group_call_id, source);
UserId user_id = get_group_call_participant_by_source(group_call_id, source);
if (user_id.is_valid()) {
on_user_speaking_in_group_call(group_call_id, user_id, G()->unix_time());
} else if (!recursive) {
@ -1148,7 +1150,7 @@ void GroupCallManager::on_group_call_recent_speakers_updated(const GroupCall *gr
recent_speaker_update_timeout_.set_timeout_in(group_call->group_call_id.get(), MAX_RECENT_SPEAKER_UPDATE_DELAY);
}
UserId GroupCallManager::get_group_call_member_by_source(GroupCallId group_call_id, int32 source) {
UserId GroupCallManager::get_group_call_participant_by_source(GroupCallId group_call_id, int32 source) {
// TODO
return UserId();
}
@ -1200,9 +1202,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->member_count,
std::move(recent_speaker_user_ids), group_call->mute_new_members,
group_call->allowed_change_mute_new_members, group_call->duration);
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);
}
tl_object_ptr<td_api::updateGroupCall> GroupCallManager::get_update_group_call_object(

View File

@ -43,14 +43,15 @@ class GroupCallManager : public Actor {
void join_group_call(GroupCallId group_call_id, td_api::object_ptr<td_api::groupCallPayload> &&payload, int32 source,
bool is_muted, Promise<td_api::object_ptr<td_api::groupCallJoinResponse>> &&promise);
void toggle_group_call_mute_new_members(GroupCallId group_call_id, bool mute_new_members, Promise<Unit> &&promise);
void invite_group_call_members(GroupCallId group_call_id, vector<UserId> &&user_ids, Promise<Unit> &&promise);
void set_group_call_member_is_speaking(GroupCallId group_call_id, int32 source, bool is_speaking,
void toggle_group_call_mute_new_participants(GroupCallId group_call_id, bool mute_new_participants,
Promise<Unit> &&promise);
void toggle_group_call_member_is_muted(GroupCallId group_call_id, UserId user_id, bool is_muted,
void invite_group_call_participants(GroupCallId group_call_id, vector<UserId> &&user_ids, Promise<Unit> &&promise);
void set_group_call_participant_is_speaking(GroupCallId group_call_id, int32 source, bool is_speaking,
Promise<Unit> &&promise);
void toggle_group_call_participant_is_muted(GroupCallId group_call_id, UserId user_id, bool is_muted,
Promise<Unit> &&promise);
void check_group_call_is_joined(GroupCallId group_call_id, Promise<Unit> &&promise);
@ -117,7 +118,7 @@ class GroupCallManager : public Actor {
void on_group_call_recent_speakers_updated(const GroupCall *group_call, GroupCallRecentSpeakers *recent_speakers);
UserId get_group_call_member_by_source(GroupCallId group_call_id, int32 source);
UserId get_group_call_participant_by_source(GroupCallId group_call_id, int32 source);
static Result<td_api::object_ptr<td_api::groupCallJoinResponse>> get_group_call_join_response_object(
string json_response);

View File

@ -4792,7 +4792,7 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
}
case MessageContentType::InviteToGroupCall: {
auto *m = static_cast<const MessageInviteToGroupCall *>(content);
return make_tl_object<td_api::messageInviteGroupCallMembers>(
return make_tl_object<td_api::messageInviteGroupCallParticipants>(
td->group_call_manager_->get_group_call_id(m->input_group_call_id, ChannelId()).get(),
td->contacts_manager_->get_user_ids_object(m->user_ids, "MessageInviteToGroupCall"));
}

View File

@ -6053,36 +6053,36 @@ void Td::on_request(uint64 id, td_api::joinGroupCall &request) {
request.source_, request.is_muted_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleGroupCallMuteNewMembers &request) {
void Td::on_request(uint64 id, const td_api::toggleGroupCallMuteNewParticipants &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
group_call_manager_->toggle_group_call_mute_new_members(GroupCallId(request.group_call_id_),
request.mute_new_members_, std::move(promise));
group_call_manager_->toggle_group_call_mute_new_participants(GroupCallId(request.group_call_id_),
request.mute_new_participants_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::inviteGroupCallMembers &request) {
void Td::on_request(uint64 id, const td_api::inviteGroupCallParticipants &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
vector<UserId> user_ids;
for (auto &user_id : request.user_ids_) {
user_ids.emplace_back(user_id);
}
group_call_manager_->invite_group_call_members(GroupCallId(request.group_call_id_), std::move(user_ids),
group_call_manager_->invite_group_call_participants(GroupCallId(request.group_call_id_), std::move(user_ids),
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::setGroupCallMemberIsSpeaking &request) {
void Td::on_request(uint64 id, const td_api::setGroupCallParticipantIsSpeaking &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
group_call_manager_->set_group_call_member_is_speaking(GroupCallId(request.group_call_id_), request.source_,
group_call_manager_->set_group_call_participant_is_speaking(GroupCallId(request.group_call_id_), request.source_,
request.is_speaking_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleGroupCallMemberIsMuted &request) {
void Td::on_request(uint64 id, const td_api::toggleGroupCallParticipantIsMuted &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
group_call_manager_->toggle_group_call_member_is_muted(GroupCallId(request.group_call_id_), UserId(request.user_id_),
request.is_muted_, std::move(promise));
group_call_manager_->toggle_group_call_participant_is_muted(
GroupCallId(request.group_call_id_), UserId(request.user_id_), request.is_muted_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::checkGroupCallIsJoined &request) {

View File

@ -698,13 +698,13 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, td_api::joinGroupCall &request);
void on_request(uint64 id, const td_api::toggleGroupCallMuteNewMembers &request);
void on_request(uint64 id, const td_api::toggleGroupCallMuteNewParticipants &request);
void on_request(uint64 id, const td_api::inviteGroupCallMembers &request);
void on_request(uint64 id, const td_api::inviteGroupCallParticipants &request);
void on_request(uint64 id, const td_api::setGroupCallMemberIsSpeaking &request);
void on_request(uint64 id, const td_api::setGroupCallParticipantIsSpeaking &request);
void on_request(uint64 id, const td_api::toggleGroupCallMemberIsMuted &request);
void on_request(uint64 id, const td_api::toggleGroupCallParticipantIsMuted &request);
void on_request(uint64 id, const td_api::checkGroupCallIsJoined &request);

View File

@ -2848,30 +2848,31 @@ class CliClient final : public Actor {
td_api::make_object<td_api::groupCallPayload>("ufrag", "pwd", std::move(fingerprints)), 123, true));
} else if (op == "jgcc") {
send_request(td_api::make_object<td_api::joinGroupCall>(as_group_call_id(args), nullptr, 123, true));
} else if (op == "tgcmnm" || op == "tgcmnme") {
send_request(td_api::make_object<td_api::toggleGroupCallMuteNewMembers>(as_group_call_id(args), op == "tgcmnme"));
} else if (op == "sgcmis") {
} else if (op == "tgcmnp" || op == "tgcmnpe") {
send_request(
td_api::make_object<td_api::toggleGroupCallMuteNewParticipants>(as_group_call_id(args), op == "tgcmnme"));
} else if (op == "sgcpis") {
string group_call_id;
string source;
string is_speaking;
std::tie(group_call_id, args) = split(args);
std::tie(source, is_speaking) = split(args);
send_request(td_api::make_object<td_api::setGroupCallMemberIsSpeaking>(
send_request(td_api::make_object<td_api::setGroupCallParticipantIsSpeaking>(
as_group_call_id(group_call_id), to_integer<int32>(source), as_bool(is_speaking)));
} else if (op == "igcm") {
} else if (op == "igcp") {
string group_call_id;
string user_ids;
std::tie(group_call_id, user_ids) = split(args);
send_request(
td_api::make_object<td_api::inviteGroupCallMembers>(as_group_call_id(group_call_id), as_user_ids(user_ids)));
} else if (op == "tgcmim") {
send_request(td_api::make_object<td_api::inviteGroupCallParticipants>(as_group_call_id(group_call_id),
as_user_ids(user_ids)));
} else if (op == "tgcpim") {
string group_call_id;
string user_id;
string is_muted;
std::tie(group_call_id, args) = split(args);
std::tie(user_id, is_muted) = split(args);
send_request(td_api::make_object<td_api::toggleGroupCallMemberIsMuted>(as_group_call_id(group_call_id),
as_user_id(user_id), as_bool(is_muted)));
send_request(td_api::make_object<td_api::toggleGroupCallParticipantIsMuted>(
as_group_call_id(group_call_id), as_user_id(user_id), as_bool(is_muted)));
} else if (op == "cgcij") {
send_request(td_api::make_object<td_api::checkGroupCallIsJoined>(as_group_call_id(args)));
} else if (op == "lgc") {