Add toggleGroupCallMuteNewMembers method.

This commit is contained in:
levlam 2020-11-27 01:58:36 +03:00
parent 54cfb02698
commit 1eca39c4ee
8 changed files with 56 additions and 2 deletions

View File

@ -4316,6 +4316,10 @@ createChatGroupCall chat_id:int53 = GroupCallId;
//@description Joins a group call @group_call_id Group call identifier @payload Group join payload, received from tgcalls @source Caller source identifier, received from tgcalls @is_muted True, if the user's microphone is muted
joinGroupCall group_call_id:string 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_calls 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:string mute_new_members:Bool = Ok;
//@description Leaves a group call @group_call_id Group call identifier @source Caller source identifier
leaveGroupCall group_call_id:string source:int32 = Ok;

Binary file not shown.

View File

@ -103,6 +103,37 @@ class JoinGroupCallQuery : public Td::ResultHandler {
}
};
class ToggleGroupCallSettingsQuery : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit ToggleGroupCallSettingsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(int32 flags, InputGroupCallId group_call_id, bool join_muted) {
send_query(G()->net_query_creator().create(
telegram_api::phone_toggleGroupCallSettings(flags, group_call_id.get_input_group_call(), join_muted)));
}
void on_result(uint64 id, BufferSlice packet) override {
auto result_ptr = fetch_result<telegram_api::phone_toggleGroupCallSettings>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for ToggleGroupCallSettingsQuery: " << to_string(ptr);
td->updates_manager_->on_get_updates(std::move(ptr));
// TODO set promise after updates are processed
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) override {
promise_.set_error(std::move(status));
}
};
class LeaveGroupCallQuery : public Td::ResultHandler {
Promise<Unit> promise_;
@ -368,6 +399,12 @@ void GroupCallManager::finish_join_group_call(InputGroupCallId group_call_id, ui
pending_join_requests_.erase(it);
}
void GroupCallManager::toggle_group_call_mute_new_members(InputGroupCallId group_call_id, bool mute_new_members,
Promise<Unit> &&promise) {
int32 flags = telegram_api::phone_toggleGroupCallSettings::JOIN_MUTED_MASK;
td_->create_handler<ToggleGroupCallSettingsQuery>(std::move(promise))->send(flags, group_call_id, mute_new_members);
}
void GroupCallManager::leave_group_call(InputGroupCallId group_call_id, int32 source, Promise<Unit> &&promise) {
td_->create_handler<LeaveGroupCallQuery>(std::move(promise))->send(group_call_id, source);
}

View File

@ -35,6 +35,9 @@ class GroupCallManager : public Actor {
int32 source, bool is_muted,
Promise<td_api::object_ptr<td_api::groupCallJoinResponse>> &&promise);
void toggle_group_call_mute_new_members(InputGroupCallId group_call_id, bool mute_new_members,
Promise<Unit> &&promise);
void leave_group_call(InputGroupCallId group_call_id, int32 source, Promise<Unit> &&promise);
void discard_group_call(InputGroupCallId group_call_id, Promise<Unit> &&promise);

View File

@ -6050,6 +6050,14 @@ void Td::on_request(uint64 id, td_api::joinGroupCall &request) {
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleGroupCallMuteNewMembers &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
TRY_RESULT_PROMISE(promise, group_call_id, InputGroupCallId::from_group_call_id(request.group_call_id_));
group_call_manager_->toggle_group_call_mute_new_members(group_call_id, request.mute_new_members_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::leaveGroupCall &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();

View File

@ -696,6 +696,8 @@ 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::leaveGroupCall &request);
void on_request(uint64 id, const td_api::discardGroupCall &request);

View File

@ -917,8 +917,6 @@ vector<InputGroupCallId> UpdatesManager::get_update_new_group_call_ids(const tel
if (group_call_id.is_valid()) {
group_call_ids.push_back(group_call_id);
} else {
LOG(ERROR) << "Receive unexpected " << to_string(update);
}
}
}

View File

@ -2844,6 +2844,8 @@ class CliClient final : public Actor {
args, 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>(args, nullptr, 123, true));
} else if (op == "tgcmnm" || op == "tgcmnme") {
send_request(td_api::make_object<td_api::toggleGroupCallMuteNewMembers>(args, op == "tgcmnme"));
} else if (op == "lgc") {
send_request(td_api::make_object<td_api::leaveGroupCall>(args, 123));
} else if (op == "dgc") {