Download emoji sounds from main DC.

This commit is contained in:
levlam 2021-10-06 00:55:22 +03:00
parent 038abf5466
commit 6ecba8cb5d
4 changed files with 10 additions and 7 deletions

View File

@ -1319,7 +1319,7 @@ void ConfigManager::save_config_expire(Timestamp timestamp) {
}
void ConfigManager::process_config(tl_object_ptr<telegram_api::config> config) {
bool is_from_main_dc = G()->net_query_dispatcher().main_dc_id().get_value() == config->this_dc_;
bool is_from_main_dc = G()->net_query_dispatcher().get_main_dc_id().get_value() == config->this_dc_;
LOG(INFO) << to_string(config);
auto reload_in = clamp(config->expires_ - config->date_, 60, 86400);

View File

@ -25,6 +25,7 @@
#include "td/telegram/misc.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/MtprotoHeader.h"
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/StickerSetId.hpp"
#include "td/telegram/StickersManager.hpp"
@ -4103,12 +4104,14 @@ void StickersManager::on_update_emoji_sounds() {
CHECK(parts.size() == 3);
auto id = to_integer<int64>(parts[0]);
auto access_hash = to_integer<int64>(parts[1]);
auto dc_id = G()->net_query_dispatcher().get_main_dc_id();
auto file_reference = base64url_decode(parts[2]).move_as_ok();
int32 expected_size = 7000;
auto suggested_file_name = PSTRING() << static_cast<uint64>(id) << '.'
<< MimeType::to_extension("audio/ogg", "oga");
auto file_id = td_->file_manager_->register_remote(
FullRemoteFileLocation(FileType::VoiceNote, id, access_hash, DcId::internal(2), std::move(file_reference)),
FileLocationSource::FromServer, DialogId(), 0, 0, std::move(suggested_file_name));
FullRemoteFileLocation(FileType::VoiceNote, id, access_hash, dc_id, std::move(file_reference)),
FileLocationSource::FromServer, DialogId(), 0, expected_size, std::move(suggested_file_name));
CHECK(file_id.is_valid());
emoji_sounds_.emplace(remove_fitzpatrick_modifier(sounds[i]).str(), file_id);
}

View File

@ -295,7 +295,7 @@ ActorId<GetHostByNameActor> ConnectionCreator::get_dns_resolver() {
void ConnectionCreator::ping_proxy(int32 proxy_id, Promise<double> promise) {
CHECK(!close_flag_);
if (proxy_id == 0) {
auto main_dc_id = G()->net_query_dispatcher().main_dc_id();
auto main_dc_id = G()->net_query_dispatcher().get_main_dc_id();
bool prefer_ipv6 = G()->shared_config().get_option_boolean("prefer_ipv6");
auto infos = dc_options_set_.find_all_connections(main_dc_id, false, false, prefer_ipv6, false);
if (infos.empty()) {
@ -361,7 +361,7 @@ void ConnectionCreator::ping_proxy_resolved(int32 proxy_id, IPAddress ip_address
return promise.set_error(Status::Error(400, "Unknown proxy identifier"));
}
const Proxy &proxy = it->second;
auto main_dc_id = G()->net_query_dispatcher().main_dc_id();
auto main_dc_id = G()->net_query_dispatcher().get_main_dc_id();
FindConnectionExtra extra;
auto r_socket_fd = find_connection(proxy, ip_address, main_dc_id, false, extra);
if (r_socket_fd.is_error()) {

View File

@ -52,8 +52,8 @@ class NetQueryDispatcher {
void update_valid_dc(DcId dc_id);
DcId main_dc_id() const {
return DcId::internal(main_dc_id_.load());
DcId get_main_dc_id() const {
return DcId::internal(main_dc_id_.load(std::memory_order_relaxed));
}
void set_main_dc_id(int32 new_main_dc_id);