From e8ea4b5c9efdc564de8803965709e343cce6cde9 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 25 Oct 2019 18:01:33 +0300 Subject: [PATCH] Better type for unique_id. GitOrigin-RevId: 2b5f5948f798bc44d0cbc9fba6b483ee2e275025 --- td/telegram/files/FileLocation.hpp | 36 +++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/td/telegram/files/FileLocation.hpp b/td/telegram/files/FileLocation.hpp index 2d6c5634..a762ba48 100644 --- a/td/telegram/files/FileLocation.hpp +++ b/td/telegram/files/FileLocation.hpp @@ -215,7 +215,41 @@ template void FullRemoteFileLocation::AsUnique::store(StorerT &storer) const { using td::store; - store(key.location_type(), storer); + int32 type = [key = &key] { + if (key->is_web()) { + return 0; + } + switch (key->file_type_) { + case FileType::Photo: + case FileType::ProfilePhoto: + case FileType::Thumbnail: + case FileType::EncryptedThumbnail: + case FileType::Wallpaper: + return 1; + case FileType::Video: + case FileType::VoiceNote: + case FileType::Document: + case FileType::Sticker: + case FileType::Audio: + case FileType::Animation: + case FileType::VideoNote: + case FileType::Background: + return 2; + case FileType::SecureRaw: + case FileType::Secure: + return 3; + case FileType::Encrypted: + return 4; + case FileType::Temp: + return 5; + case FileType::None: + case FileType::Size: + default: + UNREACHABLE(); + return -1; + } + }(); + store(type, storer); key.variant_.visit([&](auto &&value) { using td::store; store(value.as_key(), storer);