Improve sending and response handling for GetGroupCallStreamChannelsQuery.

This commit is contained in:
levlam 2022-03-01 03:12:56 +03:00
parent 84af0e176f
commit 017949d861
2 changed files with 26 additions and 2 deletions

View File

@ -43,7 +43,8 @@ class GetGroupCallStreamChannelsQuery final : public Td::ResultHandler {
void send(InputGroupCallId input_group_call_id, DcId stream_dc_id) {
send_query(G()->net_query_creator().create(
telegram_api::phone_getGroupCallStreamChannels(input_group_call_id.get_input_group_call()), {}, stream_dc_id));
telegram_api::phone_getGroupCallStreamChannels(input_group_call_id.get_input_group_call()), {}, stream_dc_id,
NetQuery::Type::DownloadSmall));
}
void on_result(BufferSlice packet) final {
@ -2425,10 +2426,29 @@ void GroupCallManager::get_group_call_streams(GroupCallId group_call_id,
return promise.set_error(Status::Error(400, "GROUPCALL_JOIN_MISSING"));
}
td_->create_handler<GetGroupCallStreamChannelsQuery>(std::move(promise))
auto query_promise = PromiseCreator::lambda(
[actor_id = actor_id(this), input_group_call_id, audio_source = group_call->audio_source,
promise = std::move(promise)](Result<td_api::object_ptr<td_api::groupCallStreams>> &&result) mutable {
send_closure(actor_id, &GroupCallManager::finish_get_group_call_streams, input_group_call_id, audio_source,
std::move(result), std::move(promise));
});
td_->create_handler<GetGroupCallStreamChannelsQuery>(std::move(query_promise))
->send(input_group_call_id, group_call->stream_dc_id);
}
void GroupCallManager::finish_get_group_call_streams(InputGroupCallId input_group_call_id, int32 audio_source,
Result<td_api::object_ptr<td_api::groupCallStreams>> &&result,
Promise<td_api::object_ptr<td_api::groupCallStreams>> &&promise) {
if (!G()->close_flag() && result.is_error()) {
auto message = result.error().message();
if (message == "GROUPCALL_JOIN_MISSING" || message == "GROUPCALL_FORBIDDEN" || message == "GROUPCALL_INVALID") {
on_group_call_left(input_group_call_id, audio_source, message == "GROUPCALL_JOIN_MISSING");
}
}
promise.set_result(std::move(result));
}
void GroupCallManager::get_group_call_stream_segment(GroupCallId group_call_id, int64 time_offset, int32 scale,
int32 channel_id,
td_api::object_ptr<td_api::GroupCallVideoQuality> quality,

View File

@ -201,6 +201,10 @@ class GroupCallManager final : public Actor {
void finish_get_group_call(InputGroupCallId input_group_call_id,
Result<tl_object_ptr<telegram_api::phone_groupCall>> &&result);
void finish_get_group_call_streams(InputGroupCallId input_group_call_id, int32 audio_source,
Result<td_api::object_ptr<td_api::groupCallStreams>> &&result,
Promise<td_api::object_ptr<td_api::groupCallStreams>> &&promise);
void finish_get_group_call_stream_segment(InputGroupCallId input_group_call_id, int32 audio_source,
Result<string> &&result, Promise<string> &&promise);