From e5f068e47a4b8ca2e9558d62b596472e16ac3180 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 12 Jun 2019 16:05:22 +0300 Subject: [PATCH] Minor fixes. GitOrigin-RevId: 49ed5d6671efa92dec7b09fa8e7863e3665ea355 --- td/telegram/Photo.cpp | 27 +++++++++++++++++++++++++++ td/telegram/Photo.h | 26 ++------------------------ td/telegram/Photo.hpp | 1 - td/telegram/StickersManager.cpp | 9 ++++++--- td/telegram/WebPageBlock.cpp | 1 + td/telegram/files/FileData.hpp | 1 + td/telegram/files/FileLocation.h | 5 +++-- td/telegram/files/FileManager.cpp | 2 ++ 8 files changed, 42 insertions(+), 30 deletions(-) diff --git a/td/telegram/Photo.cpp b/td/telegram/Photo.cpp index 83eb3740..ea599de7 100644 --- a/td/telegram/Photo.cpp +++ b/td/telegram/Photo.cpp @@ -9,10 +9,13 @@ #include "td/telegram/secret_api.h" #include "td/telegram/telegram_api.h" +#include "td/telegram/ChannelId.h" +#include "td/telegram/ChatId.h" #include "td/telegram/files/FileEncryptionKey.h" #include "td/telegram/files/FileLocation.h" #include "td/telegram/files/FileManager.h" #include "td/telegram/net/DcId.h" +#include "td/telegram/UserId.h" #include "td/utils/base64.h" #include "td/utils/common.h" @@ -27,6 +30,30 @@ namespace td { +tl_object_ptr OfflineInputPeer::get_input_peer() const { + switch (dialog_id.get_type()) { + case DialogType::User: { + UserId user_id = dialog_id.get_user_id(); + return make_tl_object(user_id.get(), dialog_access_hash); + } + case DialogType::Chat: { + ChatId chat_id = dialog_id.get_chat_id(); + return make_tl_object(chat_id.get()); + } + case DialogType::Channel: { + ChannelId channel_id = dialog_id.get_channel_id(); + return make_tl_object(channel_id.get(), dialog_access_hash); + } + case DialogType::SecretChat: + return nullptr; + case DialogType::None: + return make_tl_object(); + default: + UNREACHABLE(); + return nullptr; + } +} + static uint16 get_dimension(int32 size) { if (size < 0 || size > 65535) { LOG(ERROR) << "Wrong image dimension = " << size; diff --git a/td/telegram/Photo.h b/td/telegram/Photo.h index 65b9cc41..57b7dc66 100644 --- a/td/telegram/Photo.h +++ b/td/telegram/Photo.h @@ -56,7 +56,7 @@ struct OfflineInputStickerSet { : sticker_set_id(sticker_set_id), sticker_set_access_hash(sticker_set_access_hash) { } - tl_object_ptr as_telegram_api() const { + tl_object_ptr get_input_sticker_set() const { return make_tl_object(sticker_set_id, sticker_set_access_hash); } @@ -85,29 +85,7 @@ struct OfflineInputPeer { : dialog_id(dialog_id), dialog_access_hash(dialog_access_hash) { } - tl_object_ptr as_telegram_api() const { - switch (dialog_id.get_type()) { - case DialogType::User: { - UserId user_id = dialog_id.get_user_id(); - return make_tl_object(user_id.get(), dialog_access_hash); - } - case DialogType::Chat: { - ChatId chat_id = dialog_id.get_chat_id(); - return make_tl_object(chat_id.get()); - } - case DialogType::Channel: { - ChannelId channel_id = dialog_id.get_channel_id(); - return make_tl_object(channel_id.get(), dialog_access_hash); - } - case DialogType::SecretChat: - return nullptr; - case DialogType::None: - return make_tl_object(); - default: - UNREACHABLE(); - return nullptr; - } - } + tl_object_ptr get_input_peer() const; template void store(StorerT &storer) const; diff --git a/td/telegram/Photo.hpp b/td/telegram/Photo.hpp index 4c47a52c..dbe1fe78 100644 --- a/td/telegram/Photo.hpp +++ b/td/telegram/Photo.hpp @@ -6,7 +6,6 @@ // #pragma once -#include "td/telegram/DialogId.h" #include "td/telegram/Photo.h" #include "td/telegram/files/FileId.hpp" diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 2312293c..e292ebf1 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -27,6 +27,7 @@ #include "td/telegram/MessagesManager.h" #include "td/telegram/misc.h" #include "td/telegram/net/DcId.h" +#include "td/telegram/net/MtprotoHeader.h" #include "td/telegram/StickersManager.hpp" #include "td/telegram/Td.h" #include "td/telegram/TdDb.h" @@ -34,6 +35,7 @@ #include "td/actor/MultiPromise.h" #include "td/actor/PromiseFuture.h" +#include "td/db/SqliteKeyValue.h" #include "td/db/SqliteKeyValueAsync.h" #include "td/utils/format.h" @@ -43,6 +45,7 @@ #include "td/utils/Slice.h" #include "td/utils/Time.h" #include "td/utils/tl_helpers.h" +#include "td/utils/utf8.h" #include #include @@ -4792,7 +4795,7 @@ void StickersManager::on_get_language_codes(const string &key, Resultclose_flag()) { - LOG(ERROR) << "Reseive " << result.error() << " from GetEmojiKeywordsLanguageQuery"; + LOG(ERROR) << "Receive " << result.error() << " from GetEmojiKeywordsLanguageQuery"; } for (auto &promise : promises) { promise.set_error(result.error().clone()); @@ -4887,7 +4890,7 @@ void StickersManager::on_get_emoji_keywords( if (result.is_error()) { if (!G()->close_flag()) { - LOG(ERROR) << "Reseive " << result.error() << " from GetEmojiKeywordsQuery"; + LOG(ERROR) << "Receive " << result.error() << " from GetEmojiKeywordsQuery"; } for (auto &promise : promises) { promise.set_error(result.error().clone()); @@ -4969,7 +4972,7 @@ void StickersManager::on_get_emoji_keywords_difference( Result> &&result) { if (result.is_error()) { if (!G()->close_flag()) { - LOG(ERROR) << "Reseive " << result.error() << " from GetEmojiKeywordsDifferenceQuery"; + LOG(ERROR) << "Receive " << result.error() << " from GetEmojiKeywordsDifferenceQuery"; } emoji_language_code_last_difference_times_[language_code] = Time::now_cached() - EMOJI_KEYWORDS_UPDATE_DELAY - 2; return; diff --git a/td/telegram/WebPageBlock.cpp b/td/telegram/WebPageBlock.cpp index f8ef18fa..b41e7660 100644 --- a/td/telegram/WebPageBlock.cpp +++ b/td/telegram/WebPageBlock.cpp @@ -12,6 +12,7 @@ #include "td/telegram/AudiosManager.hpp" #include "td/telegram/ChannelId.h" #include "td/telegram/ContactsManager.h" +#include "td/telegram/DialogId.h" #include "td/telegram/DocumentsManager.h" #include "td/telegram/DocumentsManager.hpp" #include "td/telegram/files/FileId.h" diff --git a/td/telegram/files/FileData.hpp b/td/telegram/files/FileData.hpp index 13af0d0e..e3be9c76 100644 --- a/td/telegram/files/FileData.hpp +++ b/td/telegram/files/FileData.hpp @@ -15,6 +15,7 @@ #include "td/telegram/files/FileLocation.hpp" #include "td/telegram/Global.h" #include "td/telegram/Td.h" +#include "td/telegram/Version.h" #include "td/utils/common.h" #include "td/utils/misc.h" diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index 0974b51a..8cddc990 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -18,6 +18,7 @@ #include "td/utils/common.h" #include "td/utils/format.h" #include "td/utils/logging.h" +#include "td/utils/misc.h" #include "td/utils/Slice.h" #include "td/utils/StringBuilder.h" #include "td/utils/Variant.h" @@ -500,12 +501,12 @@ class FullRemoteFileLocation { auto &dialog_photo = photo().source_.dialog_photo(); return make_tl_object( dialog_photo.is_big * telegram_api::inputPeerPhotoFileLocation::Flags::BIG_MASK, dialog_photo.is_big, - dialog_photo.input_peer.as_telegram_api(), photo().volume_id_, photo().local_id_); + dialog_photo.input_peer.get_input_peer(), photo().volume_id_, photo().local_id_); } case PhotoSizeSource::Type::StickerSetThumbnail: { auto &sticker_set_thumbnail = photo().source_.sticker_set_thumbnail(); return make_tl_object( - sticker_set_thumbnail.input_sticker_set.as_telegram_api(), photo().volume_id_, photo().local_id_); + sticker_set_thumbnail.input_sticker_set.get_input_sticker_set(), photo().volume_id_, photo().local_id_); } } } diff --git a/td/telegram/files/FileManager.cpp b/td/telegram/files/FileManager.cpp index 73a10bd9..cdb6e770 100644 --- a/td/telegram/files/FileManager.cpp +++ b/td/telegram/files/FileManager.cpp @@ -20,6 +20,7 @@ #include "td/telegram/misc.h" #include "td/telegram/SecureStorage.h" #include "td/telegram/TdDb.h" +#include "td/telegram/Version.h" #include "td/actor/SleepActor.h" @@ -35,6 +36,7 @@ #include "td/utils/ScopeGuard.h" #include "td/utils/StringBuilder.h" #include "td/utils/tl_helpers.h" +#include "td/utils/tl_parsers.h" #include #include