Reload ChannelFull before getting channel statistics if needed.

GitOrigin-RevId: 0730f4a8411bf2e5e2841bc95f1960b6619742c6
This commit is contained in:
levlam 2020-04-07 23:11:44 +03:00
parent 1d8004d279
commit fef67252d1
2 changed files with 24 additions and 0 deletions

View File

@ -5727,6 +5727,28 @@ void ContactsManager::get_channel_statistics_dc_id(DialogId dialog_id, Promise<D
}
auto channel_full = get_channel_full_force(channel_id);
if (channel_full == nullptr || !channel_full->stats_dc_id.is_exact()) {
auto input_channel = get_input_channel(channel_id);
CHECK(input_channel != nullptr);
auto query_promise = PromiseCreator::lambda(
[actor_id = actor_id(this), channel_id, promise = std::move(promise)](Result<Unit> result) mutable {
send_closure(actor_id, &ContactsManager::get_channel_statistics_dc_id_impl, channel_id, std::move(promise));
});
send_get_channel_full_query(channel_full, channel_id, std::move(input_channel), std::move(query_promise),
"get_channel_statistics_dc_id");
return;
}
promise.set_value(DcId(channel_full->stats_dc_id));
}
void ContactsManager::get_channel_statistics_dc_id_impl(ChannelId channel_id, Promise<DcId> &&promise) {
if (G()->close_flag()) {
return promise.set_error(Status::Error(500, "Request aborted"));
}
auto channel_full = get_channel_full(channel_id, "get_channel_statistics_dc_id_impl");
if (channel_full == nullptr) {
return promise.set_error(Status::Error(400, "Chat full info not found"));
}

View File

@ -1340,6 +1340,8 @@ class ContactsManager : public Actor {
void get_channel_statistics_dc_id(DialogId dialog_id, Promise<DcId> &&promise);
void get_channel_statistics_dc_id_impl(ChannelId channel_id, Promise<DcId> &&promise);
void send_get_broadcast_stats_query(DcId dc_id, ChannelId channel_id, bool is_dark,
Promise<td_api::object_ptr<td_api::chatStatistics>> &&promise);