Add checkGroupCall method.

This commit is contained in:
levlam 2020-11-27 17:07:12 +03:00
parent daf93cd157
commit 1aa5822bf8
7 changed files with 54 additions and 0 deletions

View File

@ -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;

Binary file not shown.

View File

@ -168,6 +168,39 @@ class InviteToGroupCallQuery : public Td::ResultHandler {
}
};
class CheckGroupCallQuery : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit CheckGroupCallQuery(Promise<Unit> &&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<telegram_api::phone_checkGroupCall>(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<Unit> promise_;
@ -447,6 +480,10 @@ void GroupCallManager::invite_group_call_member(InputGroupCallId group_call_id,
td_->create_handler<InviteToGroupCallQuery>(std::move(promise))->send(group_call_id, user_id);
}
void GroupCallManager::check_group_call_source(InputGroupCallId group_call_id, int32 source, Promise<Unit> &&promise) {
td_->create_handler<CheckGroupCallQuery>(std::move(promise))->send(group_call_id, source);
}
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

@ -41,6 +41,8 @@ class GroupCallManager : public Actor {
void invite_group_call_member(InputGroupCallId group_call_id, UserId user_id, Promise<Unit> &&promise);
void check_group_call_source(InputGroupCallId group_call_id, int32 source, 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

@ -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();

View File

@ -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);

View File

@ -2857,6 +2857,8 @@ class CliClient final : public Actor {
std::tie(group_call_id, user_id) = split(args);
send_request(
td_api::make_object<td_api::inviteGroupCallMember>(as_group_call_id(group_call_id), as_user_id(user_id)));
} else if (op == "cgcs") {
send_request(td_api::make_object<td_api::checkGroupCallSource>(as_group_call_id(args), 123));
} else if (op == "lgc") {
send_request(td_api::make_object<td_api::leaveGroupCall>(as_group_call_id(args), 123));
} else if (op == "dgc") {