diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 21f25ddac..e766445b0 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1804,9 +1804,6 @@ fileTypeSecretThumbnail = FileType; //@description The file is a file from Secure storage used for storing Telegram Passport files fileTypeSecure = FileType; -//@description The file is an encrypted file from Secure storage used for storing Telegram Passport files; for bots only -fileTypeSecureEncrypted = FileType; - //@description The file is a sticker fileTypeSticker = FileType; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 2631df6cd..8dbadbcbe 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/CallManager.cpp b/td/telegram/CallManager.cpp index 4b17b26de..7952d4b13 100644 --- a/td/telegram/CallManager.cpp +++ b/td/telegram/CallManager.cpp @@ -38,7 +38,7 @@ void CallManager::update_call(Update call) { auto actor = get_call_actor(info.call_id); if (actor.empty()) { - LOG(WARNING) << "Drop update: " << to_string(call); + LOG(INFO) << "Drop update: " << to_string(call); } send_closure(actor, &CallActor::update_call, std::move(call->phone_call_)); } diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 4376770eb..09b6fdd8c 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1732,6 +1732,7 @@ class CliClient final : public Actor { types.push_back(make_tl_object()); types.push_back(make_tl_object()); types.push_back(make_tl_object()); + types.push_back(make_tl_object()); send_request(make_tl_object(0, -1, -1, 0, std::move(types), as_chat_ids(args, ','), as_chat_ids(""), 20)); } else if (op == "network") { @@ -2026,7 +2027,7 @@ class CliClient final : public Actor { } } else if (op == "cdf") { send_request(make_tl_object(as_file_id(args), true)); - } else if (op == "uf" || op == "ufs" || op == "ufse" || op == "ufsr") { + } else if (op == "uf" || op == "ufs" || op == "ufse") { string file_path; string priority; std::tie(file_path, priority) = split(args); @@ -2039,9 +2040,6 @@ class CliClient final : public Actor { type = make_tl_object(); } if (op == "ufse") { - type = make_tl_object(); - } - if (op == "ufsr") { type = make_tl_object(); } diff --git a/td/telegram/files/FileLoaderUtils.cpp b/td/telegram/files/FileLoaderUtils.cpp index 4bb9cb2f1..edad3c639 100644 --- a/td/telegram/files/FileLoaderUtils.cpp +++ b/td/telegram/files/FileLoaderUtils.cpp @@ -138,10 +138,10 @@ Result search_file(CSlice dir, CSlice name, int64 expected_size) { return res; } -const char *file_type_name[file_type_size] = {"thumbnails", "profile_photos", "photos", "voice", - "videos", "documents", "secret", "temp", - "stickers", "music", "animations", "secret_thumbnails", - "wallpapers", "video_notes", "passport_temp", "passport"}; +const char *file_type_name[file_type_size] = {"thumbnails", "profile_photos", "photos", "voice", + "videos", "documents", "secret", "temp", + "stickers", "music", "animations", "secret_thumbnails", + "wallpapers", "video_notes", "passport", "passport"}; string get_file_base_dir(const FileDirType &file_dir_type) { switch (file_dir_type) { diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index c449404d7..b11c74294 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -83,8 +83,6 @@ inline FileType from_td_api(const td_api::FileType &file_type) { return FileType::VideoNote; case td_api::fileTypeSecure::ID: return FileType::Secure; - case td_api::fileTypeSecureEncrypted::ID: - return FileType::SecureRaw; case td_api::fileTypeNone::ID: return FileType::None; default: @@ -126,7 +124,8 @@ inline tl_object_ptr as_td_api(FileType file_type) { case FileType::Secure: return make_tl_object(); case FileType::SecureRaw: - return make_tl_object(); + UNREACHABLE(); + return make_tl_object(); case FileType::None: return make_tl_object(); default: diff --git a/td/telegram/files/FileStats.cpp b/td/telegram/files/FileStats.cpp index 2dae092eb..07a9e7bc0 100644 --- a/td/telegram/files/FileStats.cpp +++ b/td/telegram/files/FileStats.cpp @@ -122,14 +122,30 @@ void FileStats::apply_dialog_limit(int32 limit) { tl_object_ptr as_td_api(DialogId dialog_id, const FileStats::StatByType &stat_by_type) { auto stats = make_tl_object(dialog_id.get(), 0, 0, Auto()); + int64 secure_raw_size = 0; + int32 secure_raw_cnt = 0; for (size_t i = 0; i < file_type_size; i++) { - if (stat_by_type[i].size == 0) { + FileType file_type = static_cast(i); + auto size = stat_by_type[i].size; + auto cnt = stat_by_type[i].cnt; + + if (file_type == FileType::SecureRaw) { + secure_raw_size = size; + secure_raw_cnt = cnt; continue; } - stats->size_ += stat_by_type[i].size; - stats->count_ += stat_by_type[i].cnt; - stats->by_file_type_.push_back(make_tl_object( - as_td_api(FileType(i)), stat_by_type[i].size, stat_by_type[i].cnt)); + if (file_type == FileType::Secure) { + size += secure_raw_size; + cnt += secure_raw_cnt; + } + if (size == 0) { + continue; + } + + stats->size_ += size; + stats->count_ += cnt; + stats->by_file_type_.push_back( + make_tl_object(as_td_api(file_type), size, cnt)); } return stats; } diff --git a/td/telegram/files/FileStatsWorker.cpp b/td/telegram/files/FileStatsWorker.cpp index 999402ae2..a53dc5bda 100644 --- a/td/telegram/files/FileStatsWorker.cpp +++ b/td/telegram/files/FileStatsWorker.cpp @@ -92,6 +92,9 @@ template Status scan_fs(CallbackT &&callback) { for (int i = 0; i < file_type_size; i++) { auto file_type = static_cast(i); + if (file_type == FileType::SecureRaw) { + continue; + } auto files_dir = get_files_dir(file_type); td::walk_path(files_dir, [&](CSlice path, bool is_dir) { if (is_dir) { diff --git a/td/telegram/net/NetStatsManager.cpp b/td/telegram/net/NetStatsManager.cpp index 28b60eb8a..69259cc33 100644 --- a/td/telegram/net/NetStatsManager.cpp +++ b/td/telegram/net/NetStatsManager.cpp @@ -56,7 +56,10 @@ void NetStatsManager::init() { } }; - for_each_stat([&](NetStatsInfo &stat, size_t id, CSlice name, FileType) { + for_each_stat([&](NetStatsInfo &stat, size_t id, CSlice name, FileType file_type) { + if (file_type == FileType::SecureRaw) { + id++; + } stat.key = "net_stats_" + name.str(); stat.stats.set_callback(std::make_unique(actor_id(this), id)); }); @@ -107,6 +110,10 @@ void NetStatsManager::get_network_stats(bool current, Promise prom entry.is_call = true; result.entries.push_back(std::move(entry)); } else if (file_type != FileType::None) { + if (file_type == FileType::SecureRaw) { + return; + } + if (total_files.read_size != 0) { entry.rx = static_cast(static_cast(total.read_size) * (static_cast(entry.rx) / static_cast(total_files.read_size))); @@ -182,7 +189,11 @@ void NetStatsManager::add_network_stats_impl(NetStatsInfo &info, const NetworkSt } void NetStatsManager::start_up() { - for_each_stat([&](NetStatsInfo &info, size_t id, CSlice name, FileType) { + for_each_stat([&](NetStatsInfo &info, size_t id, CSlice name, FileType file_type) { + if (file_type == FileType::SecureRaw) { + return; + } + for (size_t net_type_i = 0; net_type_i < net_type_size(); net_type_i++) { auto net_type = NetType(net_type_i); auto key = PSTRING() << info.key << "#" << net_type_string(net_type); @@ -237,7 +248,9 @@ std::shared_ptr NetStatsManager::get_media_stats_callback() co } std::vector> NetStatsManager::get_file_stats_callbacks() const { - return transform(files_stats_, [](auto &stat) { return stat.stats.get_callback(); }); + auto result = transform(files_stats_, [](auto &stat) { return stat.stats.get_callback(); }); + result[static_cast(FileType::SecureRaw)] = result[static_cast(FileType::Secure)]; + return result; } void NetStatsManager::update(NetStatsInfo &info, bool force_save) { diff --git a/td/telegram/net/NetStatsManager.h b/td/telegram/net/NetStatsManager.h index e363f181c..d9758b333 100644 --- a/td/telegram/net/NetStatsManager.h +++ b/td/telegram/net/NetStatsManager.h @@ -53,7 +53,7 @@ struct NetworkStats { result->since_date_ = since; result->entries_.reserve(entries.size()); for (const auto &entry : entries) { - if (entry.rx != 0 || entry.tx != 0) { + if ((entry.rx != 0 || entry.tx != 0) && entry.file_type != FileType::SecureRaw) { result->entries_.push_back(entry.as_td_api()); } }