diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 5bb571e9a..617559daa 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4324,6 +4324,9 @@ toggleGroupCallMuteNewMembers group_call_id:string mute_new_members:Bool = Ok; //@group_call_id Group call identifier @user_id User identifier inviteGroupCallMember group_call_id:string user_id:int32 = Ok; +//@description Checks group call source for validness. If the method returns an error with a message "GROUP_CALL_JOIN_MISSING", the call needs to be rejoined @group_call_id Group call identifier @source Caller source identifier +checkGroupCallSource group_call_id:string source:int32 = Ok; + //@description Leaves a group call @group_call_id Group call identifier @source Caller source identifier leaveGroupCall group_call_id:string source:int32 = Ok; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index c728ab362..0c818aaaa 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index 766a0a4b5..7497a3fe7 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -168,6 +168,39 @@ class InviteToGroupCallQuery : public Td::ResultHandler { } }; +class CheckGroupCallQuery : public Td::ResultHandler { + Promise promise_; + + public: + explicit CheckGroupCallQuery(Promise &&promise) : promise_(std::move(promise)) { + } + + void send(InputGroupCallId group_call_id, int32 source) { + send_query(G()->net_query_creator().create( + telegram_api::phone_checkGroupCall(group_call_id.get_input_group_call(), source))); + } + + void on_result(uint64 id, BufferSlice packet) override { + auto result_ptr = fetch_result(packet); + if (result_ptr.is_error()) { + return on_error(id, result_ptr.move_as_error()); + } + + bool success = result_ptr.move_as_ok(); + LOG(INFO) << "Receive result for CheckGroupCallQuery: " << success; + + if (success) { + promise_.set_value(Unit()); + } else { + promise_.set_error(Status::Error(200, "Group call left")); + } + } + + void on_error(uint64 id, Status status) override { + promise_.set_error(std::move(status)); + } +}; + class LeaveGroupCallQuery : public Td::ResultHandler { Promise promise_; @@ -447,6 +480,10 @@ void GroupCallManager::invite_group_call_member(InputGroupCallId group_call_id, td_->create_handler(std::move(promise))->send(group_call_id, user_id); } +void GroupCallManager::check_group_call_source(InputGroupCallId group_call_id, int32 source, Promise &&promise) { + td_->create_handler(std::move(promise))->send(group_call_id, source); +} + void GroupCallManager::leave_group_call(InputGroupCallId group_call_id, int32 source, Promise &&promise) { td_->create_handler(std::move(promise))->send(group_call_id, source); } diff --git a/td/telegram/GroupCallManager.h b/td/telegram/GroupCallManager.h index f47fed8ce..5669e1723 100644 --- a/td/telegram/GroupCallManager.h +++ b/td/telegram/GroupCallManager.h @@ -41,6 +41,8 @@ class GroupCallManager : public Actor { void invite_group_call_member(InputGroupCallId group_call_id, UserId user_id, Promise &&promise); + void check_group_call_source(InputGroupCallId group_call_id, int32 source, Promise &&promise); + void leave_group_call(InputGroupCallId group_call_id, int32 source, Promise &&promise); void discard_group_call(InputGroupCallId group_call_id, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 7c0b78539..24a411c93 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6066,6 +6066,14 @@ void Td::on_request(uint64 id, const td_api::inviteGroupCallMember &request) { group_call_manager_->invite_group_call_member(group_call_id, UserId(request.user_id_), std::move(promise)); } +void Td::on_request(uint64 id, const td_api::checkGroupCallSource &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_->check_group_call_source(group_call_id, request.source_, std::move(promise)); +} + void Td::on_request(uint64 id, const td_api::leaveGroupCall &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index b1479bb18..c711c0201 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -700,6 +700,8 @@ class Td final : public NetQueryCallback { void on_request(uint64 id, const td_api::inviteGroupCallMember &request); + void on_request(uint64 id, const td_api::checkGroupCallSource &request); + void on_request(uint64 id, const td_api::leaveGroupCall &request); void on_request(uint64 id, const td_api::discardGroupCall &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 5a47f09a0..a9adad591 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2857,6 +2857,8 @@ class CliClient final : public Actor { std::tie(group_call_id, user_id) = split(args); send_request( td_api::make_object(as_group_call_id(group_call_id), as_user_id(user_id))); + } else if (op == "cgcs") { + send_request(td_api::make_object(as_group_call_id(args), 123)); } else if (op == "lgc") { send_request(td_api::make_object(as_group_call_id(args), 123)); } else if (op == "dgc") {