Allow to create scheduled voice chats.

This commit is contained in:
levlam 2021-04-06 02:54:55 +03:00
parent 02fe7e47e6
commit 2241058f85
5 changed files with 17 additions and 10 deletions

View File

@ -4601,8 +4601,10 @@ sendCallDebugInformation call_id:int32 debug_information:string = Ok;
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 @title Group call title; if empty, chat title will be used
createVoiceChat chat_id:int53 title:string = GroupCallId;
//@chat_id Chat identifier, in which the voice chat will be created
//@title Group call title; if empty, chat title will be used
//@start_date Point in time (Unix timestamp) when the group call will be started. Pass 0 to start the voice chat immediately
createVoiceChat chat_id:int53 title:string start_date:int32 = GroupCallId;
//@description Returns information about a group call @group_call_id Group call identifier
getGroupCall group_call_id:int32 = GroupCall;

View File

@ -131,7 +131,7 @@ class CreateGroupCallQuery : public Td::ResultHandler {
explicit CreateGroupCallQuery(Promise<InputGroupCallId> &&promise) : promise_(std::move(promise)) {
}
void send(DialogId dialog_id, const string &title) {
void send(DialogId dialog_id, const string &title, int32 start_date) {
dialog_id_ = dialog_id;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
@ -141,8 +141,11 @@ class CreateGroupCallQuery : public Td::ResultHandler {
if (!title.empty()) {
flags |= telegram_api::phone_createGroupCall::TITLE_MASK;
}
if (start_date > 0) {
flags |= telegram_api::phone_createGroupCall::SCHEDULE_DATE_MASK;
}
send_query(G()->net_query_creator().create(
telegram_api::phone_createGroupCall(flags, std::move(input_peer), Random::secure_int32(), title, 0)));
telegram_api::phone_createGroupCall(flags, std::move(input_peer), Random::secure_int32(), title, start_date)));
}
void on_result(uint64 id, BufferSlice packet) override {
@ -1039,7 +1042,8 @@ 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, string title, Promise<GroupCallId> &&promise) {
void GroupCallManager::create_voice_chat(DialogId dialog_id, string title, int32 start_date,
Promise<GroupCallId> &&promise) {
if (!dialog_id.is_valid()) {
return promise.set_error(Status::Error(400, "Invalid chat identifier specified"));
}
@ -1063,7 +1067,7 @@ void GroupCallManager::create_voice_chat(DialogId dialog_id, string title, Promi
std::move(promise));
}
});
td_->create_handler<CreateGroupCallQuery>(std::move(query_promise))->send(dialog_id, title);
td_->create_handler<CreateGroupCallQuery>(std::move(query_promise))->send(dialog_id, title, start_date);
}
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, string title, Promise<GroupCallId> &&promise);
void create_voice_chat(DialogId dialog_id, string title, int32 start_date, Promise<GroupCallId> &&promise);
void get_group_call(GroupCallId group_call_id, Promise<td_api::object_ptr<td_api::groupCall>> &&promise);

View File

@ -5985,7 +5985,7 @@ void Td::on_request(uint64 id, 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(request.title_),
group_call_manager_->create_voice_chat(DialogId(request.chat_id_), std::move(request.title_), request.start_date_,
std::move(query_promise));
}

View File

@ -2675,8 +2675,9 @@ class CliClient final : public Actor {
} else if (op == "cvc") {
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));
int32 start_date;
get_args(args, chat_id, title, start_date);
send_request(td_api::make_object<td_api::createVoiceChat>(as_chat_id(chat_id), title, start_date));
} else if (op == "ggc") {
send_request(td_api::make_object<td_api::getGroupCall>(as_group_call_id(args)));
} else if (op == "ggcss") {