From d4646d4cd91274f9667ea77fc7bb0a140dc7db12 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 6 Mar 2023 16:59:18 +0300 Subject: [PATCH] Minor improvements. --- .gitattributes | 1 - td/generate/scheme/td_api.tl | 6 +++--- td/telegram/AttachMenuManager.cpp | 2 +- td/telegram/AutosaveManager.cpp | 9 +++++---- td/telegram/EmojiGroup.cpp | 1 + td/telegram/FileReferenceManager.cpp | 2 +- td/telegram/StickersManager.cpp | 5 +++-- td/telegram/WebApp.h | 1 - tddb/td/db/binlog/BinlogEvent.cpp | 2 +- tdutils/td/utils/port/FileFd.cpp | 2 +- tdutils/td/utils/port/sleep.cpp | 6 ++++-- test/link.cpp | 2 +- 12 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.gitattributes b/.gitattributes index 06e5328a4..f657278f3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,7 +10,6 @@ *.sh text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent eol=lf *.php text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.ps1 text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent eol=crlf -*.yml text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.cmake text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.md text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent *.in text whitespace=blank-at-eol,space-before-tab,blank-at-eof,tab-in-indent diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 2011f5d7e..5b092b62e 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -6145,7 +6145,7 @@ getMessageLinkInfo url:string = MessageLinkInfo; //@description Translates a text to the given language. If the current user is a Telegram Premium user, then text formatting is preserved //@text Text to translate -//@to_language_code ISO language code of the language to which the message is translated. Must be one of +//@to_language_code Language code of the language to which the message is translated. Must be one of //-"af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et", //-"fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko", //-"ku", "ky", "lo", "la", "lv", "lt", "lb", "mk", "mg", "ms", "ml", "mt", "mi", "mr", "mn", "my", "ne", "no", "ny", "or", "ps", "fa", "pl", "pt", "pa", "ro", "ru", "sm", "gd", "sr", @@ -6155,7 +6155,7 @@ translateText text:formattedText to_language_code:string = FormattedText; //@description Extracts text or caption of the given message and translates it to the given language. If the current user is a Telegram Premium user, then text formatting is preserved //@chat_id Identifier of the chat to which the message belongs //@message_id Identifier of the message -//@to_language_code ISO language code of the language to which the message is translated. Must be one of +//@to_language_code Language code of the language to which the message is translated. Must be one of //-"af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et", //-"fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko", //-"ku", "ky", "lo", "la", "lv", "lt", "lb", "mk", "mg", "ms", "ml", "mt", "mi", "mr", "mn", "my", "ne", "no", "ny", "or", "ps", "fa", "pl", "pt", "pa", "ro", "ru", "sm", "gd", "sr", @@ -8070,7 +8070,7 @@ checkStickerSetName name:string = CheckStickerSetNameResult; //@name Sticker set name. Can contain only English letters, digits and underscores. Must end with *"_by_"* (** is case insensitive) for bots; 1-64 characters //@sticker_format Format of the stickers in the set //@sticker_type Type of the stickers in the set -//@needs_repainting True, if stickers in the sticker set must be repainted; for custom emoji sticker sets only +//@needs_repainting Pass true if stickers in the sticker set must be repainted; for custom emoji sticker sets only //@stickers List of stickers to be added to the set; must be non-empty. All stickers must have the same format. For TGS stickers, uploadStickerFile must be used before the sticker is shown //@source Source of the sticker set; may be empty if unknown createNewStickerSet user_id:int53 title:string name:string sticker_format:StickerFormat sticker_type:StickerType needs_repainting:Bool stickers:vector source:string = StickerSet; diff --git a/td/telegram/AttachMenuManager.cpp b/td/telegram/AttachMenuManager.cpp index 54f7f15df..ecac42570 100644 --- a/td/telegram/AttachMenuManager.cpp +++ b/td/telegram/AttachMenuManager.cpp @@ -1161,7 +1161,7 @@ FileSourceId AttachMenuManager::get_web_app_file_source_id(UserId user_id, const if (!source_id.is_valid()) { source_id = td_->file_reference_manager_->create_web_app_file_source(user_id, short_name); } - VLOG(file_references) << "Return " << source_id << " for web app " << user_id << '/' << short_name; + VLOG(file_references) << "Return " << source_id << " for Web App " << user_id << '/' << short_name; return source_id; } diff --git a/td/telegram/AutosaveManager.cpp b/td/telegram/AutosaveManager.cpp index d96b3e8de..5d578841b 100644 --- a/td/telegram/AutosaveManager.cpp +++ b/td/telegram/AutosaveManager.cpp @@ -19,11 +19,11 @@ namespace td { -class GetAutosaveSettingsQuery final : public Td::ResultHandler { +class GetAutoSaveSettingsQuery final : public Td::ResultHandler { Promise> promise_; public: - explicit GetAutosaveSettingsQuery(Promise> &&promise) + explicit GetAutoSaveSettingsQuery(Promise> &&promise) : promise_(std::move(promise)) { } @@ -350,11 +350,13 @@ void AutosaveManager::reload_autosave_settings() { [actor_id = actor_id(this)](Result> r_settings) { send_closure(actor_id, &AutosaveManager::on_get_autosave_settings, std::move(r_settings)); }); - td_->create_handler(std::move(query_promise))->send(); + td_->create_handler(std::move(query_promise))->send(); } void AutosaveManager::on_get_autosave_settings( Result> r_settings) { + G()->ignore_result_if_closing(r_settings); + CHECK(settings_.are_being_reloaded_); settings_.are_being_reloaded_ = false; SCOPE_EXIT { @@ -363,7 +365,6 @@ void AutosaveManager::on_get_autosave_settings( reload_autosave_settings(); } }; - G()->ignore_result_if_closing(r_settings); if (r_settings.is_error()) { return fail_promises(load_settings_queries_, r_settings.move_as_error()); } diff --git a/td/telegram/EmojiGroup.cpp b/td/telegram/EmojiGroup.cpp index d3c94ef38..693696af6 100644 --- a/td/telegram/EmojiGroup.cpp +++ b/td/telegram/EmojiGroup.cpp @@ -5,6 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/telegram/EmojiGroup.h" + #include "td/telegram/StickersManager.h" #include "td/utils/algorithm.h" diff --git a/td/telegram/FileReferenceManager.cpp b/td/telegram/FileReferenceManager.cpp index 7a0fbc2c8..bd9d89c9e 100644 --- a/td/telegram/FileReferenceManager.cpp +++ b/td/telegram/FileReferenceManager.cpp @@ -158,7 +158,7 @@ FileSourceId FileReferenceManager::create_attach_menu_bot_file_source(UserId use FileSourceId FileReferenceManager::create_web_app_file_source(UserId user_id, const string &short_name) { FileSourceWebApp source{user_id, short_name}; - return add_file_source_id(source, PSLICE() << "web app " << user_id << '/' << short_name); + return add_file_source_id(source, PSLICE() << "Web App " << user_id << '/' << short_name); } FileReferenceManager::Node &FileReferenceManager::add_node(NodeId node_id) { diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 726abc915..22b30cabc 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -6792,10 +6792,11 @@ void StickersManager::on_get_default_dialog_photo_custom_emoji_ids( if (!are_default_dialog_photo_custom_emoji_ids_loaded_[for_user]) { on_get_default_dialog_photo_custom_emoji_ids_success(for_user, {}, 0); } - for (auto &promise : default_dialog_photo_custom_emoji_ids_load_queries_[for_user]) { + auto promises = std::move(default_dialog_photo_custom_emoji_ids_load_queries_[for_user]); + reset_to_empty(default_dialog_photo_custom_emoji_ids_load_queries_[for_user]); + for (auto &promise : promises) { CHECK(!promise); } - reset_to_empty(default_dialog_photo_custom_emoji_ids_load_queries_[for_user]); return; } CHECK(constructor_id == telegram_api::emojiList::ID); diff --git a/td/telegram/WebApp.h b/td/telegram/WebApp.h index 15e8ef78d..182ad4eb9 100644 --- a/td/telegram/WebApp.h +++ b/td/telegram/WebApp.h @@ -18,7 +18,6 @@ namespace td { -class ContactsManager; class Td; class WebApp { diff --git a/tddb/td/db/binlog/BinlogEvent.cpp b/tddb/td/db/binlog/BinlogEvent.cpp index c74acd2b7..f1ff50ab9 100644 --- a/tddb/td/db/binlog/BinlogEvent.cpp +++ b/tddb/td/db/binlog/BinlogEvent.cpp @@ -38,7 +38,7 @@ Status BinlogEvent::validate() const { return Status::Error("Too small event"); } TlParser parser(as_slice(raw_event_)); - uint32 size = static_cast(parser.fetch_int()); + auto size = static_cast(parser.fetch_int()); if (size_ != size || size_ != raw_event_.size()) { return Status::Error(PSLICE() << "Size of event changed: " << tag("was", size_) << tag("now", size)); } diff --git a/tdutils/td/utils/port/FileFd.cpp b/tdutils/td/utils/port/FileFd.cpp index b78a82d7c..179d06c1a 100644 --- a/tdutils/td/utils/port/FileFd.cpp +++ b/tdutils/td/utils/port/FileFd.cpp @@ -157,7 +157,7 @@ Result FileFd::open(CSlice filepath, int32 flags, int32 mode) { } #endif - while (1) { + while (true) { int native_fd = detail::skip_eintr([&] { return ::open(filepath.c_str(), native_flags, static_cast(mode)); }); if (native_fd < 0) { diff --git a/tdutils/td/utils/port/sleep.cpp b/tdutils/td/utils/port/sleep.cpp index ee693537c..3352ff67d 100644 --- a/tdutils/td/utils/port/sleep.cpp +++ b/tdutils/td/utils/port/sleep.cpp @@ -8,14 +8,16 @@ #include "td/utils/port/config.h" +#if TD_PORT_WINDOWS +#include "td/utils/port/Clocks.h" +#endif + #if TD_PORT_POSIX #if _POSIX_C_SOURCE >= 199309L #include #else #include #endif -#else -#include "td/utils/port/Clocks.h" #endif namespace td { diff --git a/test/link.cpp b/test/link.cpp index 7ee7b2174..633a746fe 100644 --- a/test/link.cpp +++ b/test/link.cpp @@ -112,7 +112,7 @@ static void parse_internal_link(const td::string &url, td::td_api::object_ptr