Add td_api::endGroupCallScreenSharing.

This commit is contained in:
levlam 2021-04-30 20:21:07 +03:00
parent 2225e56906
commit 31c36aaa7a
6 changed files with 79 additions and 0 deletions

View File

@ -4624,6 +4624,9 @@ joinGroupCall group_call_id:int32 participant_id:MessageSender audio_source:int3
//@description Starts screen sharing in a joined group call. Returns join response payload for tgcalls @group_call_id Group call identifier @payload Group call join payload; received from tgcalls
startGroupCallScreenSharing group_call_id:int32 payload:string = Text;
//@description Ends screen sharing in a joined group call @group_call_id Group call identifier
endGroupCallScreenSharing group_call_id:int32 = Ok;
//@description Sets group call title. Requires groupCall.can_be_managed group call flag @group_call_id Group call identifier @title New group call title; 1-64 characters
setGroupCallTitle group_call_id:int32 title:string = Ok;

View File

@ -439,6 +439,38 @@ class JoinGroupCallPresentationQuery : public Td::ResultHandler {
}
};
class LeaveGroupCallPresentationQuery : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit LeaveGroupCallPresentationQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(InputGroupCallId input_group_call_id) {
send_query(G()->net_query_creator().create(
telegram_api::phone_leaveGroupCallPresentation(input_group_call_id.get_input_group_call())));
}
void on_result(uint64 id, BufferSlice packet) override {
auto result_ptr = fetch_result<telegram_api::phone_editGroupCallTitle>(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 LeaveGroupCallPresentationQuery: " << to_string(ptr);
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) override {
if (status.message() == "PARTICIPANT_PRESENTATION_MISSING") {
promise_.set_value(Unit());
return;
}
promise_.set_error(std::move(status));
}
};
class EditGroupCallTitleQuery : public Td::ResultHandler {
Promise<Unit> promise_;
@ -2476,6 +2508,36 @@ void GroupCallManager::start_group_call_screen_sharing(GroupCallId group_call_id
}
}
void GroupCallManager::end_group_call_screen_sharing(GroupCallId group_call_id, Promise<Unit> &&promise) {
TRY_RESULT_PROMISE(promise, input_group_call_id, get_input_group_call_id(group_call_id));
auto *group_call = get_group_call(input_group_call_id);
CHECK(group_call != nullptr);
if (!group_call->is_inited || !group_call->is_active) {
return promise.set_error(Status::Error(400, "GROUPCALL_JOIN_MISSING"));
}
if (!group_call->is_joined || group_call->is_being_left) {
if (is_group_call_being_joined(input_group_call_id) || group_call->need_rejoin) {
group_call->after_join.push_back(
PromiseCreator::lambda([actor_id = actor_id(this), group_call_id,
promise = std::move(promise)](Result<Unit> &&result) mutable {
if (result.is_error()) {
promise.set_error(Status::Error(400, "GROUPCALL_JOIN_MISSING"));
} else {
send_closure(actor_id, &GroupCallManager::end_group_call_screen_sharing, group_call_id,
std::move(promise));
}
}));
return;
}
return promise.set_error(Status::Error(400, "GROUPCALL_JOIN_MISSING"));
}
cancel_join_group_call_presentation_request(input_group_call_id);
td_->create_handler<LeaveGroupCallPresentationQuery>(std::move(promise))->send(input_group_call_id);
}
void GroupCallManager::try_load_group_call_administrators(InputGroupCallId input_group_call_id, DialogId dialog_id) {
if (!dialog_id.is_valid() || !need_group_call_participants(input_group_call_id) ||
can_manage_group_calls(dialog_id).is_error()) {

View File

@ -69,6 +69,8 @@ class GroupCallManager : public Actor {
void start_group_call_screen_sharing(GroupCallId group_call_id, string &&payload, Promise<string> &&promise);
void end_group_call_screen_sharing(GroupCallId group_call_id, Promise<Unit> &&promise);
void set_group_call_title(GroupCallId group_call_id, string title, Promise<Unit> &&promise);
void toggle_group_call_start_subscribed(GroupCallId group_call_id, bool start_subscribed, Promise<Unit> &&promise);

View File

@ -6050,6 +6050,13 @@ void Td::on_request(uint64 id, td_api::startGroupCallScreenSharing &request) {
std::move(query_promise));
}
void Td::on_request(uint64 id, const td_api::endGroupCallScreenSharing &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
group_call_manager_->end_group_call_screen_sharing(GroupCallId(request.group_call_id_),
std::move(promise));
}
void Td::on_request(uint64 id, td_api::setGroupCallTitle &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.title_);

View File

@ -717,6 +717,8 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, td_api::startGroupCallScreenSharing &request);
void on_request(uint64 id, const td_api::endGroupCallScreenSharing &request);
void on_request(uint64 id, td_api::setGroupCallTitle &request);
void on_request(uint64 id, const td_api::toggleGroupCallMuteNewParticipants &request);

View File

@ -2719,6 +2719,9 @@ class CliClient final : public Actor {
as_message_sender(participant_id), group_call_source_,
std::move(payload), true, invite_hash));
}
} else if (op == "egcss") {
string group_call_id = args;
send_request(td_api::make_object<td_api::endGroupCallScreenSharing>(as_group_call_id(group_call_id)));
} else if (op == "sgct") {
string chat_id;
string title;