Add inviteGroupCallMember method.

This commit is contained in:
levlam 2020-11-27 15:22:19 +03:00
parent 1eca39c4ee
commit f10db772f5
7 changed files with 64 additions and 0 deletions

View File

@ -4320,6 +4320,10 @@ joinGroupCall group_call_id:string payload:groupCallPayload source:int32 is_mute
//@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 Invites a user to a chat group call by sending a service message of type messageInviteToGroupCall
//@group_call_id Group call identifier @user_id User identifier
inviteGroupCallMember group_call_id:string user_id: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

@ -134,6 +134,40 @@ class ToggleGroupCallSettingsQuery : public Td::ResultHandler {
}
};
class InviteToGroupCallQuery : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit InviteToGroupCallQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(InputGroupCallId group_call_id, UserId user_id) {
auto input_user = td->contacts_manager_->get_input_user(user_id);
CHECK(input_user != nullptr);
send_query(G()->net_query_creator().create(
telegram_api::phone_inviteToGroupCall(group_call_id.get_input_group_call(), std::move(input_user))));
}
void on_result(uint64 id, BufferSlice packet) override {
auto result_ptr = fetch_result<telegram_api::phone_inviteToGroupCall>(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 InviteToGroupCallQuery: " << 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_;
@ -405,6 +439,14 @@ void GroupCallManager::toggle_group_call_mute_new_members(InputGroupCallId group
td_->create_handler<ToggleGroupCallSettingsQuery>(std::move(promise))->send(flags, group_call_id, mute_new_members);
}
void GroupCallManager::invite_group_call_member(InputGroupCallId group_call_id, UserId user_id,
Promise<Unit> &&promise) {
if (!td_->contacts_manager_->have_input_user(user_id)) {
return promise.set_error(Status::Error(400, "Have no access to the user"));
}
td_->create_handler<InviteToGroupCallQuery>(std::move(promise))->send(group_call_id, user_id);
}
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

@ -10,6 +10,7 @@
#include "td/telegram/InputGroupCallId.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
#include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h"
@ -38,6 +39,8 @@ class GroupCallManager : public Actor {
void toggle_group_call_mute_new_members(InputGroupCallId group_call_id, bool mute_new_members,
Promise<Unit> &&promise);
void invite_group_call_member(InputGroupCallId group_call_id, UserId user_id, 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

@ -6058,6 +6058,14 @@ void Td::on_request(uint64 id, const td_api::toggleGroupCallMuteNewMembers &requ
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::inviteGroupCallMember &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_->invite_group_call_member(group_call_id, UserId(request.user_id_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::leaveGroupCall &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();

View File

@ -698,6 +698,8 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, const td_api::toggleGroupCallMuteNewMembers &request);
void on_request(uint64 id, const td_api::inviteGroupCallMember &request);
void on_request(uint64 id, const td_api::leaveGroupCall &request);
void on_request(uint64 id, const td_api::discardGroupCall &request);

View File

@ -2846,6 +2846,11 @@ class CliClient final : public Actor {
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 == "igcm") {
string group_call_id;
string user_id;
std::tie(group_call_id, user_id) = split(args);
send_request(td_api::make_object<td_api::inviteGroupCallMember>(group_call_id, as_user_id(user_id)));
} else if (op == "lgc") {
send_request(td_api::make_object<td_api::leaveGroupCall>(args, 123));
} else if (op == "dgc") {