Embed English list of countries.
GitOrigin-RevId: 4a40f72939c2d394d0da772afd0e58e21b9144ab
This commit is contained in:
parent
cfa202a589
commit
6bc70724f2
@ -11,13 +11,16 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/utils/base64.h"
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/Gzip.h"
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/Random.h"
|
||||
#include "td/utils/Slice.h"
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/Time.h"
|
||||
#include "td/utils/tl_parsers.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
@ -289,10 +292,10 @@ void CountryInfoManager::on_get_country_list(const string &language_code,
|
||||
CHECK(!promises.empty());
|
||||
pending_load_country_queries_.erase(query_it);
|
||||
|
||||
auto &countries = countries_[language_code];
|
||||
if (r_country_list.is_error()) {
|
||||
if (countries != nullptr) {
|
||||
countries->next_reload_time = Time::now() + Random::fast(60, 120);
|
||||
auto it = countries_.find(language_code);
|
||||
if (it != countries_.end()) {
|
||||
it->second->next_reload_time = Time::now() + Random::fast(60, 120);
|
||||
}
|
||||
for (auto &promise : promises) {
|
||||
promise.set_error(r_country_list.error().clone());
|
||||
@ -300,8 +303,17 @@ void CountryInfoManager::on_get_country_list(const string &language_code,
|
||||
return;
|
||||
}
|
||||
|
||||
auto country_list = r_country_list.move_as_ok();
|
||||
on_get_country_list_impl(language_code, r_country_list.move_as_ok());
|
||||
|
||||
for (auto &promise : promises) {
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
}
|
||||
|
||||
void CountryInfoManager::on_get_country_list_impl(const string &language_code,
|
||||
tl_object_ptr<telegram_api::help_CountriesList> country_list) {
|
||||
CHECK(country_list != nullptr);
|
||||
auto &countries = countries_[language_code];
|
||||
switch (country_list->get_id()) {
|
||||
case telegram_api::help_countriesListNotModified::ID:
|
||||
if (countries == nullptr) {
|
||||
@ -353,15 +365,94 @@ void CountryInfoManager::on_get_country_list(const string &language_code,
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
for (auto &promise : promises) {
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
}
|
||||
|
||||
const CountryInfoManager::CountryList *CountryInfoManager::get_country_list(const string &language_code) {
|
||||
auto it = countries_.find(language_code);
|
||||
if (it == countries_.end()) {
|
||||
if (language_code == "en") {
|
||||
static const BufferSlice en = gzdecode(
|
||||
base64url_decode(
|
||||
"eJyNW81y6kiWzmv8f3-qbnd19SwmKhQxET3dEV0doH8tAQPGIMxF4Gt7l0AWZFlILiHZbb9A7-YRZjOLjl7MbuYJ7sx-"
|
||||
"IuYdZjGbeYU5AhsJ6ZC6EbbBIk_myfP7nZPJP0f_9Zff_Me___3_EkL-4Z_-8gVeyF71jBxVvakfBDT-7A08-7__LNX24LWkGPrrs-"
|
||||
"Pra2n1s0XbIN-NPB6yqVQN6FhqLHhAQ7aEz3JzWUbl9dnb1USr3-tkriZ5W_1pNqceX4bUy9LvWQpJ0W8mSOhb5GPVC_"
|
||||
"ksotLvpBoNxtGU5vnYr8i6meLv-"
|
||||
"JWRrX21yXHVm0XcdSmyl3gOtXCOLsjVHcN2ELlqmlgWNtAGC4bSGurrs9OENrXuJTkE3n3gPEcrq6pYhgNyUg1mDMToZWS3-lxTU-"
|
||||
"s45EN1wQI-oZ7k0IWfX2-_opvFchrCXqNlGOT3uqcmOj9dU15v73UE_"
|
||||
"Ma01OWIrvf0SspmVvQZOX8mB9UgGiO0JdkyxHzfktPqMwvGlP9MPcTeLVWo41qVfFfzl6BiMNdzFjyzmf-wEnt-"
|
||||
"LsU0hDqv1chxbPF06mO-B_"
|
||||
"aq6kV6qJ2R0xr1Zi6dsuU8z4NplsU8NMhRjbkzHi1yelDkzXzvrl8DSSaW1JrkXS0K7kAEUpMufUwOsqxvy3T9k8zRAjlE7owGPCtHsv"
|
||||
"Y7Kxl7DvzSeUB5LtZArFJen51c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nuF9kartMHTJskf2hP9tx59kU2uXwnBwP55Svj6CRGFVwf254QU6H9Gf-gsryerDEPa1hhxwN_TsGqCGfA6wEMwyhdhnyhR_"
|
||||
"82AV8w5B8kRprk3exbuJvQOzAisBX2kbXNr6lX4gTQ0AJS_SOkDhWDi_JwdCHuI9i4qQfMhyQw5hPhtRO1lecXw-"
|
||||
"H5OMQQgqf0imY4dAf09gI8vZnFn9nZXgV8_JA3QjDbgmWHQJ2GFL-iOnaNHWhzw3B54bUe6Y7cpBc8L2WUZUcje7iK_"
|
||||
"csR6sk3y9I7txl-oqjFjkczXbhHjFmGTmkNHKqObxV-Qq8NboBvoMohrtI3N_GLtl-3-iWnI6ex2y3f2X9e5v-qk5-WGOIK-5NGLz-"
|
||||
"TgrnTFrfz4lLMSz2Fn_v5qpBTq4gjz5D-YPE3z3tK85pr1rk-1rcTVvOgbtgxkXnSfJX8NQmH0dOdir0bKpcOBf4_xVnIeTrrD_"
|
||||
"smanvMV2NYBz1Ihoi8ctI_OZzk3zzmboujxNGMwojL3--p5vJHbLP8X271deiMH9c1dXxs73rFvmh5YLnu5Ltj7nLIC2HgJN5CO-"
|
||||
"eIFIu8vRmap3rDjns-Ev_AcNT5s48vl77inzf9kIWeKtiBFjosfDRh6SYx6mmKafeJz2XmwY5uGELhmFzSzd2xZPV-jdQy9_8mKvlV5-"
|
||||
"pcnJ2qK7ros2at3ENs8JS6xv3SCzakw0ijAe3Njm83XX_Kunj4rSfyfEtX4zp-BHHwTp6N2T6P3_97_8HHeuAFA==")
|
||||
.ok());
|
||||
TlBufferParser parser(&en);
|
||||
auto result = telegram_api::help_getCountriesList::fetch_result(parser);
|
||||
parser.fetch_end();
|
||||
CHECK(parser.get_error() == nullptr);
|
||||
on_get_country_list_impl(language_code, std::move(result));
|
||||
|
||||
it = countries_.find(language_code);
|
||||
CHECK(it != countries_.end())
|
||||
auto *country = it->second.get();
|
||||
load_country_list(language_code, country->hash, Auto());
|
||||
return country;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,9 @@ class CountryInfoManager : public Actor {
|
||||
void on_get_country_list(const string &language_code,
|
||||
Result<tl_object_ptr<telegram_api::help_CountriesList>> r_country_list);
|
||||
|
||||
void on_get_country_list_impl(const string &language_code,
|
||||
tl_object_ptr<telegram_api::help_CountriesList> country_list);
|
||||
|
||||
const CountryList *get_country_list(const string &language_code);
|
||||
|
||||
std::unordered_map<string, vector<Promise<Unit>>> pending_load_country_queries_;
|
||||
|
Loading…
Reference in New Issue
Block a user