From 5c1b94040267998d0968e8d2bacd63a631c8bf0b Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 30 Oct 2023 19:04:14 +0300 Subject: [PATCH] Minor improvements. --- td/telegram/BoostManager.cpp | 7 ++++++- td/telegram/BoostManager.h | 3 +++ td/telegram/DraftMessage.cpp | 2 -- td/telegram/DraftMessage.h | 1 - td/telegram/GiveawayParameters.cpp | 2 ++ td/telegram/InputMessageText.cpp | 1 + td/telegram/InputMessageText.h | 2 ++ td/telegram/MessageContent.h | 1 + td/telegram/MessageInputReplyTo.cpp | 3 +++ td/telegram/MessageReplyHeader.cpp | 2 -- td/telegram/MessageReplyHeader.h | 1 + td/telegram/NotificationType.cpp | 2 +- td/telegram/Payments.cpp | 3 +-- td/telegram/Premium.cpp | 3 +++ td/telegram/RepliedMessageInfo.cpp | 3 +-- td/telegram/RepliedMessageInfo.h | 2 ++ td/telegram/Td.cpp | 1 + td/telegram/UpdatesManager.cpp | 1 + td/telegram/WebPageBlock.cpp | 10 +++++++--- td/telegram/WebPagesManager.cpp | 1 - td/telegram/WebPagesManager.h | 3 +-- 21 files changed, 37 insertions(+), 17 deletions(-) diff --git a/td/telegram/BoostManager.cpp b/td/telegram/BoostManager.cpp index 8409a7518..32075f802 100644 --- a/td/telegram/BoostManager.cpp +++ b/td/telegram/BoostManager.cpp @@ -6,16 +6,21 @@ // #include "td/telegram/BoostManager.h" +#include "td/telegram/AccessRights.h" #include "td/telegram/ContactsManager.h" #include "td/telegram/Global.h" #include "td/telegram/LinkManager.h" +#include "td/telegram/MessageId.h" #include "td/telegram/MessagesManager.h" +#include "td/telegram/ServerMessageId.h" #include "td/telegram/Td.h" +#include "td/telegram/telegram_api.h" +#include "td/telegram/UserId.h" #include "td/utils/algorithm.h" #include "td/utils/buffer.h" +#include "td/utils/logging.h" #include "td/utils/misc.h" -#include "td/utils/SliceBuilder.h" namespace td { diff --git a/td/telegram/BoostManager.h b/td/telegram/BoostManager.h index 723370377..547704c26 100644 --- a/td/telegram/BoostManager.h +++ b/td/telegram/BoostManager.h @@ -15,6 +15,9 @@ #include "td/utils/common.h" #include "td/utils/Promise.h" #include "td/utils/Slice.h" +#include "td/utils/Status.h" + +#include namespace td { diff --git a/td/telegram/DraftMessage.cpp b/td/telegram/DraftMessage.cpp index 46aceea94..fc086950f 100644 --- a/td/telegram/DraftMessage.cpp +++ b/td/telegram/DraftMessage.cpp @@ -12,11 +12,9 @@ #include "td/telegram/MessageEntity.h" #include "td/telegram/MessagesManager.h" #include "td/telegram/misc.h" -#include "td/telegram/ServerMessageId.h" #include "td/telegram/Td.h" #include "td/telegram/telegram_api.h" #include "td/telegram/UpdatesManager.h" -#include "td/telegram/WebPagesManager.h" #include "td/utils/buffer.h" #include "td/utils/logging.h" diff --git a/td/telegram/DraftMessage.h b/td/telegram/DraftMessage.h index f6a2c7f1d..2728cc384 100644 --- a/td/telegram/DraftMessage.h +++ b/td/telegram/DraftMessage.h @@ -19,7 +19,6 @@ namespace td { -class ContactsManager; class Dependencies; class Td; diff --git a/td/telegram/GiveawayParameters.cpp b/td/telegram/GiveawayParameters.cpp index 9d3af5374..6ad32bfaa 100644 --- a/td/telegram/GiveawayParameters.cpp +++ b/td/telegram/GiveawayParameters.cpp @@ -6,9 +6,11 @@ // #include "td/telegram/GiveawayParameters.h" +#include "td/telegram/AccessRights.h" #include "td/telegram/ContactsManager.h" #include "td/telegram/Dependencies.h" #include "td/telegram/DialogId.h" +#include "td/telegram/Global.h" #include "td/telegram/MessagesManager.h" #include "td/telegram/OptionManager.h" #include "td/telegram/Td.h" diff --git a/td/telegram/InputMessageText.cpp b/td/telegram/InputMessageText.cpp index d632a768a..81faa3e7b 100644 --- a/td/telegram/InputMessageText.cpp +++ b/td/telegram/InputMessageText.cpp @@ -7,6 +7,7 @@ #include "td/telegram/InputMessageText.h" #include "td/telegram/ContactsManager.h" +#include "td/telegram/Dependencies.h" #include "td/telegram/MessageEntity.h" #include "td/telegram/misc.h" #include "td/telegram/Td.h" diff --git a/td/telegram/InputMessageText.h b/td/telegram/InputMessageText.h index 02cf3b2d0..c2da584ae 100644 --- a/td/telegram/InputMessageText.h +++ b/td/telegram/InputMessageText.h @@ -9,7 +9,9 @@ #include "td/telegram/DialogId.h" #include "td/telegram/MessageEntity.h" #include "td/telegram/td_api.h" +#include "td/telegram/telegram_api.h" +#include "td/utils/common.h" #include "td/utils/Status.h" namespace td { diff --git a/td/telegram/MessageContent.h b/td/telegram/MessageContent.h index 19136e3db..5a9107d2b 100644 --- a/td/telegram/MessageContent.h +++ b/td/telegram/MessageContent.h @@ -7,6 +7,7 @@ #pragma once #include "td/telegram/BackgroundInfo.h" +#include "td/telegram/ChannelId.h" #include "td/telegram/DialogId.h" #include "td/telegram/EncryptedFile.h" #include "td/telegram/files/FileId.h" diff --git a/td/telegram/MessageInputReplyTo.cpp b/td/telegram/MessageInputReplyTo.cpp index 95087d84f..a40368efb 100644 --- a/td/telegram/MessageInputReplyTo.cpp +++ b/td/telegram/MessageInputReplyTo.cpp @@ -6,14 +6,17 @@ // #include "td/telegram/MessageInputReplyTo.h" +#include "td/telegram/AccessRights.h" #include "td/telegram/ContactsManager.h" #include "td/telegram/Dependencies.h" #include "td/telegram/DialogId.h" #include "td/telegram/InputDialogId.h" #include "td/telegram/MessagesManager.h" #include "td/telegram/misc.h" +#include "td/telegram/ServerMessageId.h" #include "td/telegram/StoryId.h" #include "td/telegram/Td.h" +#include "td/telegram/UserId.h" #include "td/utils/logging.h" diff --git a/td/telegram/MessageReplyHeader.cpp b/td/telegram/MessageReplyHeader.cpp index 22e81fd19..3ae14b1f2 100644 --- a/td/telegram/MessageReplyHeader.cpp +++ b/td/telegram/MessageReplyHeader.cpp @@ -6,8 +6,6 @@ // #include "td/telegram/MessageReplyHeader.h" -#include "td/telegram/MessageFullId.h" -#include "td/telegram/ScheduledServerMessageId.h" #include "td/telegram/ServerMessageId.h" #include "td/telegram/StoryId.h" #include "td/telegram/UserId.h" diff --git a/td/telegram/MessageReplyHeader.h b/td/telegram/MessageReplyHeader.h index 0feeedf19..00e79c19a 100644 --- a/td/telegram/MessageReplyHeader.h +++ b/td/telegram/MessageReplyHeader.h @@ -6,6 +6,7 @@ // #pragma once +#include "td/telegram/DialogId.h" #include "td/telegram/MessageId.h" #include "td/telegram/RepliedMessageInfo.h" #include "td/telegram/StoryFullId.h" diff --git a/td/telegram/NotificationType.cpp b/td/telegram/NotificationType.cpp index 9a81fbb61..64a1387e6 100644 --- a/td/telegram/NotificationType.cpp +++ b/td/telegram/NotificationType.cpp @@ -255,7 +255,7 @@ class NotificationTypePushMessage final : public NotificationType { return td_api::make_object(title, score, is_pinned); } if (key == "MESSAGE_GIFTCODE") { - int32 month_count = to_integer(arg); + auto month_count = to_integer(arg); return td_api::make_object(month_count); } if (key == "MESSAGE_GIVEAWAY") { diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index 224646cf4..237542dc2 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -31,7 +31,6 @@ #include "td/utils/common.h" #include "td/utils/JsonBuilder.h" #include "td/utils/logging.h" -#include "td/utils/Random.h" #include "td/utils/Status.h" namespace td { @@ -74,7 +73,7 @@ Result get_input_invoice_info(Td *td, td_api::object_ptr(input_invoice); if (invoice->purpose_ == nullptr) { - return Status::Error(400, "Purpose must not be empty"); + return Status::Error(400, "Purpose must be non-empty"); } switch (invoice->purpose_->get_id()) { case td_api::telegramPaymentPurposePremiumGiftCodes::ID: { diff --git a/td/telegram/Premium.cpp b/td/telegram/Premium.cpp index bc6bafa36..1f9d8cb01 100644 --- a/td/telegram/Premium.cpp +++ b/td/telegram/Premium.cpp @@ -6,8 +6,10 @@ // #include "td/telegram/Premium.h" +#include "td/telegram/AccessRights.h" #include "td/telegram/AnimationsManager.h" #include "td/telegram/Application.h" +#include "td/telegram/ChannelId.h" #include "td/telegram/ContactsManager.h" #include "td/telegram/DialogId.h" #include "td/telegram/Document.h" @@ -15,6 +17,7 @@ #include "td/telegram/GiveawayParameters.h" #include "td/telegram/Global.h" #include "td/telegram/MessageEntity.h" +#include "td/telegram/MessageId.h" #include "td/telegram/MessageSender.h" #include "td/telegram/MessagesManager.h" #include "td/telegram/misc.h" diff --git a/td/telegram/RepliedMessageInfo.cpp b/td/telegram/RepliedMessageInfo.cpp index 4613c85b5..463084ae3 100644 --- a/td/telegram/RepliedMessageInfo.cpp +++ b/td/telegram/RepliedMessageInfo.cpp @@ -6,16 +6,15 @@ // #include "td/telegram/RepliedMessageInfo.h" -#include "td/telegram/ContactsManager.h" #include "td/telegram/Dependencies.h" #include "td/telegram/MessageContent.h" +#include "td/telegram/MessageContentType.h" #include "td/telegram/MessageFullId.h" #include "td/telegram/MessagesManager.h" #include "td/telegram/misc.h" #include "td/telegram/OptionManager.h" #include "td/telegram/ScheduledServerMessageId.h" #include "td/telegram/ServerMessageId.h" -#include "td/telegram/StoryId.h" #include "td/telegram/Td.h" #include "td/utils/algorithm.h" diff --git a/td/telegram/RepliedMessageInfo.h b/td/telegram/RepliedMessageInfo.h index 3b22c9ba5..9756695d0 100644 --- a/td/telegram/RepliedMessageInfo.h +++ b/td/telegram/RepliedMessageInfo.h @@ -8,6 +8,7 @@ #include "td/telegram/ChannelId.h" #include "td/telegram/DialogId.h" +#include "td/telegram/files/FileId.h" #include "td/telegram/MessageContent.h" #include "td/telegram/MessageEntity.h" #include "td/telegram/MessageFullId.h" @@ -19,6 +20,7 @@ #include "td/telegram/UserId.h" #include "td/utils/common.h" +#include "td/utils/StringBuilder.h" #include diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index a4ae432c2..928b51f1b 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6,6 +6,7 @@ // #include "td/telegram/Td.h" +#include "td/telegram/AccentColorId.h" #include "td/telegram/AccountManager.h" #include "td/telegram/AnimationsManager.h" #include "td/telegram/Application.h" diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 2cb314cc6..f642c610d 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -14,6 +14,7 @@ #include "td/telegram/CallbackQueriesManager.h" #include "td/telegram/CallManager.h" #include "td/telegram/ChannelId.h" +#include "td/telegram/ChannelType.h" #include "td/telegram/ChatId.h" #include "td/telegram/ConfigManager.h" #include "td/telegram/ContactsManager.h" diff --git a/td/telegram/WebPageBlock.cpp b/td/telegram/WebPageBlock.cpp index 599ffc6da..d9e000f24 100644 --- a/td/telegram/WebPageBlock.cpp +++ b/td/telegram/WebPageBlock.cpp @@ -1471,9 +1471,9 @@ class WebPageBlockChatLink final : public WebPageBlock { template void parse(ParserT &parser) { using ::td::parse; - bool has_title = true; - bool has_photo = true; - bool has_username = true; + bool has_title; + bool has_photo; + bool has_username; bool has_accent_color_id = false; if (parser.version() >= static_cast(Version::AddPageBlockChatLinkFlags)) { BEGIN_PARSE_FLAGS(); @@ -1482,6 +1482,10 @@ class WebPageBlockChatLink final : public WebPageBlock { PARSE_FLAG(has_username); PARSE_FLAG(has_accent_color_id); END_PARSE_FLAGS(); + } else { + has_title = true; + has_photo = true; + has_username = true; } if (has_title) { parse(title, parser); diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index c803dba25..fe8b5c522 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -25,7 +25,6 @@ #include "td/telegram/MessagesManager.h" #include "td/telegram/Photo.h" #include "td/telegram/PhotoFormat.h" -#include "td/telegram/secret_api.h" #include "td/telegram/StickersManager.h" #include "td/telegram/StoryFullId.h" #include "td/telegram/StoryId.h" diff --git a/td/telegram/WebPagesManager.h b/td/telegram/WebPagesManager.h index e25b70a86..92d343f3c 100644 --- a/td/telegram/WebPagesManager.h +++ b/td/telegram/WebPagesManager.h @@ -11,7 +11,6 @@ #include "td/telegram/files/FileId.h" #include "td/telegram/files/FileSourceId.h" #include "td/telegram/MessageFullId.h" -#include "td/telegram/SecretInputMedia.h" #include "td/telegram/StoryFullId.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" @@ -197,7 +196,7 @@ class WebPagesManager final : public Actor { FlatHashMap, StoryFullIdHash> story_web_pages_; - FlatHashMap> url_to_web_page_id_; // url -> [WebPageId, from_database] + FlatHashMap> url_to_web_page_id_; // URL -> [WebPageId, from_database] FlatHashMap url_to_file_source_id_;