Allow to specify title of created voice chats.

This commit is contained in:
levlam 2021-04-06 02:13:57 +03:00
parent 47066bbffb
commit 02fe7e47e6
6 changed files with 22 additions and 11 deletions

View File

@ -4600,8 +4600,9 @@ sendCallDebugInformation call_id:int32 debug_information:string = Ok;
//@description Returns list of user and chat, which can be used as aliases to join a voice chat in the chat @chat_id Chat identifier
getAvailableVoiceChatAliases chat_id:int53 = MessageSenders;
//@description Creates a voice chat (a group call bound to a chat). Available only for basic groups, supergroups and channels; requires can_manage_voice_chats rights @chat_id Chat identifier
createVoiceChat chat_id:int53 = GroupCallId;
//@description Creates a voice chat (a group call bound to a chat). Available only for basic groups, supergroups and channels; requires can_manage_voice_chats rights
//@chat_id Chat identifier @title Group call title; if empty, chat title will be used
createVoiceChat chat_id:int53 title:string = GroupCallId;
//@description Returns information about a group call @group_call_id Group call identifier
getGroupCall group_call_id:int32 = GroupCall;

View File

@ -131,15 +131,18 @@ class CreateGroupCallQuery : public Td::ResultHandler {
explicit CreateGroupCallQuery(Promise<InputGroupCallId> &&promise) : promise_(std::move(promise)) {
}
void send(DialogId dialog_id) {
void send(DialogId dialog_id, const string &title) {
dialog_id_ = dialog_id;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
int32 flags = 0;
if (!title.empty()) {
flags |= telegram_api::phone_createGroupCall::TITLE_MASK;
}
send_query(G()->net_query_creator().create(
telegram_api::phone_createGroupCall(flags, std::move(input_peer), Random::secure_int32(), string(), 0)));
telegram_api::phone_createGroupCall(flags, std::move(input_peer), Random::secure_int32(), title, 0)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1036,7 +1039,7 @@ void GroupCallManager::get_group_call_join_as(DialogId dialog_id,
td_->create_handler<GetGroupCallJoinAsQuery>(std::move(promise))->send(dialog_id);
}
void GroupCallManager::create_voice_chat(DialogId dialog_id, Promise<GroupCallId> &&promise) {
void GroupCallManager::create_voice_chat(DialogId dialog_id, string title, Promise<GroupCallId> &&promise) {
if (!dialog_id.is_valid()) {
return promise.set_error(Status::Error(400, "Invalid chat identifier specified"));
}
@ -1049,6 +1052,8 @@ void GroupCallManager::create_voice_chat(DialogId dialog_id, Promise<GroupCallId
TRY_STATUS_PROMISE(promise, can_manage_group_calls(dialog_id));
title = clean_name(title, MAX_TITLE_LENGTH);
auto query_promise = PromiseCreator::lambda(
[actor_id = actor_id(this), dialog_id, promise = std::move(promise)](Result<InputGroupCallId> result) mutable {
if (result.is_error()) {
@ -1058,7 +1063,7 @@ void GroupCallManager::create_voice_chat(DialogId dialog_id, Promise<GroupCallId
std::move(promise));
}
});
td_->create_handler<CreateGroupCallQuery>(std::move(query_promise))->send(dialog_id);
td_->create_handler<CreateGroupCallQuery>(std::move(query_promise))->send(dialog_id, title);
}
void GroupCallManager::on_voice_chat_created(DialogId dialog_id, InputGroupCallId input_group_call_id,

View File

@ -48,7 +48,7 @@ class GroupCallManager : public Actor {
void get_group_call_join_as(DialogId dialog_id, Promise<td_api::object_ptr<td_api::messageSenders>> &&promise);
void create_voice_chat(DialogId dialog_id, Promise<GroupCallId> &&promise);
void create_voice_chat(DialogId dialog_id, string title, Promise<GroupCallId> &&promise);
void get_group_call(GroupCallId group_call_id, Promise<td_api::object_ptr<td_api::groupCall>> &&promise);

View File

@ -5974,8 +5974,9 @@ void Td::on_request(uint64 id, const td_api::getAvailableVoiceChatAliases &reque
group_call_manager_->get_group_call_join_as(DialogId(request.chat_id_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::createVoiceChat &request) {
void Td::on_request(uint64 id, td_api::createVoiceChat &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.title_);
CREATE_REQUEST_PROMISE();
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<GroupCallId> result) mutable {
if (result.is_error()) {
@ -5984,7 +5985,8 @@ void Td::on_request(uint64 id, const td_api::createVoiceChat &request) {
promise.set_value(td_api::make_object<td_api::groupCallId>(result.ok().get()));
}
});
group_call_manager_->create_voice_chat(DialogId(request.chat_id_), std::move(query_promise));
group_call_manager_->create_voice_chat(DialogId(request.chat_id_), std::move(request.title_),
std::move(query_promise));
}
void Td::on_request(uint64 id, const td_api::getGroupCall &request) {

View File

@ -703,7 +703,7 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, const td_api::getAvailableVoiceChatAliases &request);
void on_request(uint64 id, const td_api::createVoiceChat &request);
void on_request(uint64 id, td_api::createVoiceChat &request);
void on_request(uint64 id, const td_api::getGroupCall &request);

View File

@ -2673,7 +2673,10 @@ class CliClient final : public Actor {
} else if (op == "gavca") {
send_request(td_api::make_object<td_api::getAvailableVoiceChatAliases>(as_chat_id(args)));
} else if (op == "cvc") {
send_request(td_api::make_object<td_api::createVoiceChat>(as_chat_id(args)));
string chat_id;
string title;
get_args(args, chat_id, title);
send_request(td_api::make_object<td_api::createVoiceChat>(as_chat_id(chat_id), title));
} else if (op == "ggc") {
send_request(td_api::make_object<td_api::getGroupCall>(as_group_call_id(args)));
} else if (op == "ggcss") {