Add td_api::startScheduledGroupCall.
This commit is contained in:
parent
ef93bde7a2
commit
a7c34c5c49
|
@ -4612,6 +4612,9 @@ 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;
|
||||
|
||||
//@description Starts a scheduled group call @group_call_id Group call identifier
|
||||
startScheduledGroupCall group_call_id:int32 = Ok;
|
||||
|
||||
//@description Joins a group call
|
||||
//@group_call_id Group call identifier
|
||||
//@participant_alias Identifier of the group call participant, which will be used to join the call; voice chats only
|
||||
|
|
|
@ -280,6 +280,38 @@ class GetGroupCallParticipantsQuery : public Td::ResultHandler {
|
|||
}
|
||||
};
|
||||
|
||||
class StartScheduledGroupCallQuery : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit StartScheduledGroupCallQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(InputGroupCallId input_group_call_id) {
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::phone_startScheduledGroupCall(input_group_call_id.get_input_group_call())));
|
||||
}
|
||||
|
||||
void on_result(uint64 id, BufferSlice packet) override {
|
||||
auto result_ptr = fetch_result<telegram_api::phone_startScheduledGroupCall>(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 StartScheduledGroupCallQuery: " << to_string(ptr);
|
||||
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
|
||||
}
|
||||
|
||||
void on_error(uint64 id, Status status) override {
|
||||
if (status.message() == "GROUPCALL_NOT_MODIFIED") {
|
||||
promise_.set_value(Unit());
|
||||
return;
|
||||
}
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class JoinGroupCallQuery : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
InputGroupCallId input_group_call_id_;
|
||||
|
@ -2069,6 +2101,40 @@ void GroupCallManager::finish_get_group_call_stream_segment(InputGroupCallId inp
|
|||
promise.set_result(std::move(result));
|
||||
}
|
||||
|
||||
void GroupCallManager::start_scheduled_group_call(GroupCallId group_call_id, Promise<Unit> &&promise) {
|
||||
if (G()->close_flag()) {
|
||||
return promise.set_error(Status::Error(500, "Request aborted"));
|
||||
}
|
||||
|
||||
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) {
|
||||
reload_group_call(input_group_call_id,
|
||||
PromiseCreator::lambda([actor_id = actor_id(this), group_call_id, promise = std::move(promise)](
|
||||
Result<td_api::object_ptr<td_api::groupCall>> &&result) mutable {
|
||||
if (result.is_error()) {
|
||||
promise.set_error(result.move_as_error());
|
||||
} else {
|
||||
send_closure(actor_id, &GroupCallManager::start_scheduled_group_call, group_call_id,
|
||||
std::move(promise));
|
||||
}
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (!group_call->can_be_managed) {
|
||||
return promise.set_error(Status::Error(400, "Not enough rights to start the group call"));
|
||||
}
|
||||
if (!group_call->is_active) {
|
||||
return promise.set_error(Status::Error(400, "Group call already ended"));
|
||||
}
|
||||
if (group_call->scheduled_start_date == 0) {
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
|
||||
td_->create_handler<StartScheduledGroupCallQuery>(std::move(promise))->send(input_group_call_id);
|
||||
}
|
||||
|
||||
void GroupCallManager::join_group_call(GroupCallId group_call_id, DialogId as_dialog_id,
|
||||
td_api::object_ptr<td_api::groupCallPayload> &&payload, int32 audio_source,
|
||||
bool is_muted, const string &invite_hash,
|
||||
|
|
|
@ -60,6 +60,8 @@ class GroupCallManager : public Actor {
|
|||
void get_group_call_stream_segment(GroupCallId group_call_id, int64 time_offset, int32 scale,
|
||||
Promise<string> &&promise);
|
||||
|
||||
void start_scheduled_group_call(GroupCallId group_call_id, Promise<Unit> &&promise);
|
||||
|
||||
void join_group_call(GroupCallId group_call_id, DialogId as_dialog_id,
|
||||
td_api::object_ptr<td_api::groupCallPayload> &&payload, int32 audio_source, bool is_muted,
|
||||
const string &invite_hash, Promise<td_api::object_ptr<td_api::GroupCallJoinResponse>> &&promise);
|
||||
|
|
|
@ -5995,6 +5995,12 @@ void Td::on_request(uint64 id, const td_api::getGroupCall &request) {
|
|||
group_call_manager_->get_group_call(GroupCallId(request.group_call_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::startScheduledGroupCall &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
group_call_manager_->start_scheduled_group_call(GroupCallId(request.group_call_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::joinGroupCall &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.invite_hash_);
|
||||
|
|
|
@ -707,6 +707,8 @@ class Td final : public NetQueryCallback {
|
|||
|
||||
void on_request(uint64 id, const td_api::getGroupCall &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::startScheduledGroupCall &request);
|
||||
|
||||
void on_request(uint64 id, td_api::joinGroupCall &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setGroupCallTitle &request);
|
||||
|
|
|
@ -2683,6 +2683,8 @@ class CliClient final : public Actor {
|
|||
} else if (op == "ggcss") {
|
||||
send_request(td_api::make_object<td_api::getGroupCallStreamSegment>(as_group_call_id(args),
|
||||
(std::time(nullptr) - 5) * 1000, 0));
|
||||
} else if (op == "ssgc") {
|
||||
send_request(td_api::make_object<td_api::startScheduledGroupCall>(as_group_call_id(args)));
|
||||
} else if (op == "jgc") {
|
||||
string group_call_id;
|
||||
string participant_alias;
|
||||
|
|
Loading…
Reference in New Issue
Block a user