Add td_api::getGroupCallInviteLink.

This commit is contained in:
levlam 2021-03-12 19:29:06 +03:00
parent 73bed3ed80
commit 0ec4c2084e
6 changed files with 76 additions and 0 deletions

View File

@ -4587,6 +4587,11 @@ resetGroupCallInviteHash group_call_id:int32 = Ok;
//@group_call_id Group call identifier @user_ids User identifiers. At most 10 users can be invited simultaneously
inviteGroupCallParticipants group_call_id:int32 user_ids:vector<int32> = Ok;
//@description Returns invite link to a voice chat in a public chat
//@group_call_id Group call identifier
//@can_self_unmute Pass true if the invite_link should contain an invite hash, passing which to joinGroupCall would allow the invited user to unmute themself. Requires groupCall.can_be_managed group call flag
getGroupCallInviteLink group_call_id:int32 can_self_unmute:Bool = HttpUrl;
//@description Starts recording of a group call. Requires groupCall.can_be_managed group call flag @group_call_id Group call identifier @title Group call recording title; 0-128 characters
startGroupCallRecording group_call_id:int32 title:string = Ok;

View File

@ -420,6 +420,37 @@ class InviteToGroupCallQuery : public Td::ResultHandler {
}
};
class ExportGroupCallInviteQuery : public Td::ResultHandler {
Promise<string> promise_;
public:
explicit ExportGroupCallInviteQuery(Promise<string> &&promise) : promise_(std::move(promise)) {
}
void send(InputGroupCallId input_group_call_id, bool can_self_unmute) {
int32 flags = 0;
if (can_self_unmute) {
flags |= telegram_api::phone_exportGroupCallInvite::CAN_SELF_UNMUTE_MASK;
}
send_query(G()->net_query_creator().create(telegram_api::phone_exportGroupCallInvite(
flags, false /*ignored*/, input_group_call_id.get_input_group_call())));
}
void on_result(uint64 id, BufferSlice packet) override {
auto result_ptr = fetch_result<telegram_api::phone_exportGroupCallInvite>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
promise_.set_value(std::move(ptr->link_));
}
void on_error(uint64 id, Status status) override {
promise_.set_error(std::move(status));
}
};
class ToggleGroupCallRecordQuery : public Td::ResultHandler {
Promise<Unit> promise_;
@ -2302,6 +2333,22 @@ void GroupCallManager::invite_group_call_participants(GroupCallId group_call_id,
td_->create_handler<InviteToGroupCallQuery>(std::move(promise))->send(input_group_call_id, std::move(input_users));
}
void GroupCallManager::get_group_call_invite_link(GroupCallId group_call_id, bool can_self_unmute,
Promise<string> &&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);
if (group_call == nullptr || !group_call->is_inited || !group_call->is_active) {
return promise.set_error(Status::Error(400, "Can't get group call invite link"));
}
if (can_self_unmute && !group_call->can_be_managed) {
return promise.set_error(Status::Error(400, "Not enough rights in the group call"));
}
td_->create_handler<ExportGroupCallInviteQuery>(std::move(promise))->send(input_group_call_id, can_self_unmute);
}
void GroupCallManager::toggle_group_call_recording(GroupCallId group_call_id, bool is_enabled, string title,
Promise<Unit> &&promise) {
TRY_RESULT_PROMISE(promise, input_group_call_id, get_input_group_call_id(group_call_id));

View File

@ -72,6 +72,8 @@ class GroupCallManager : public Actor {
void invite_group_call_participants(GroupCallId group_call_id, vector<UserId> &&user_ids, Promise<Unit> &&promise);
void get_group_call_invite_link(GroupCallId group_call_id, bool can_self_unmute, Promise<string> &&promise);
void toggle_group_call_recording(GroupCallId group_call_id, bool is_enabled, string title, Promise<Unit> &&promise);
void set_group_call_participant_is_speaking(GroupCallId group_call_id, int32 audio_source, bool is_speaking,

View File

@ -6030,6 +6030,20 @@ void Td::on_request(uint64 id, const td_api::inviteGroupCallParticipants &reques
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getGroupCallInviteLink &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<string> result) mutable {
if (result.is_error()) {
promise.set_error(result.move_as_error());
} else {
promise.set_value(td_api::make_object<td_api::httpUrl>(result.move_as_ok()));
}
});
group_call_manager_->get_group_call_invite_link(GroupCallId(request.group_call_id_), request.can_self_unmute_,
std::move(query_promise));
}
void Td::on_request(uint64 id, td_api::startGroupCallRecording &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.title_);

View File

@ -715,6 +715,8 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, const td_api::inviteGroupCallParticipants &request);
void on_request(uint64 id, const td_api::getGroupCallInviteLink &request);
void on_request(uint64 id, td_api::startGroupCallRecording &request);
void on_request(uint64 id, const td_api::endGroupCallRecording &request);

View File

@ -2709,6 +2709,12 @@ class CliClient final : public Actor {
get_args(args, group_call_id, user_ids);
send_request(td_api::make_object<td_api::inviteGroupCallParticipants>(as_group_call_id(group_call_id),
as_user_ids(user_ids)));
} else if (op == "ggcil") {
string group_call_id;
bool can_self_unmute;
get_args(args, group_call_id, can_self_unmute);
send_request(
td_api::make_object<td_api::getGroupCallInviteLink>(as_group_call_id(group_call_id), can_self_unmute));
} else if (op == "sgcr") {
string chat_id;
string title;