From eecb70d00699f0495e539e3afe34f690355c06ce Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 7 Jan 2020 18:16:57 +0300 Subject: [PATCH] Minor fixes. GitOrigin-RevId: b8276b548fca9ede4bd2caf27bd45ccc54c93dda --- CHANGELOG.md | 2 +- td/generate/scheme/td_api.tl | 2 +- td/telegram/ConfigManager.cpp | 7 +++---- td/telegram/Global.h | 3 --- td/telegram/MessagesManager.cpp | 10 ++++++---- td/telegram/net/AuthDataShared.cpp | 1 - td/telegram/net/Session.cpp | 19 ++++++------------- 7 files changed, 17 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a0bc97f9..28a459e2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,7 +70,7 @@ Changes in 1.6.0: * Improved support for chat backgrounds: - Added the classes `backgroundFillSolid` for solid color backgrounds and `backgroundFillGradient` for gradient backgrounds. - - Added support for TGV (gzipped subset of SVG with mime-type "application/x-tgwallpattern") background patterns + - Added support for TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") background patterns in addition to PNG patterns. Background pattern thumbnails are still always in PNG format. - Replaced the field `color` in the class `backgroundTypePattern` with the field `fill` of type `BackgroundFill`. - Replaced the class `backgroundTypeSolid` with the class `backgroundTypeFill`. diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 727ec0abe..b6f8b3d01 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2113,7 +2113,7 @@ backgroundFillGradient top_color:int32 bottom_color:int32 rotation_angle:int32 = //@is_moving True, if the background needs to be slightly moved when device is tilted backgroundTypeWallpaper is_blurred:Bool is_moving:Bool = BackgroundType; -//@description A PNG or TGV (gzipped subset of SVG with mime-type "application/x-tgwallpattern") pattern to be combined with the background fill chosen by the user +//@description A PNG or TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") pattern to be combined with the background fill chosen by the user //@fill Description of the background fill //@intensity Intensity of the pattern when it is shown above the filled background, 0-100 //@is_moving True, if the background needs to be slightly moved when device is tilted diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 67c9d8cbd..931b2568b 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -55,7 +55,6 @@ #include "td/utils/tl_parsers.h" #include "td/utils/UInt.h" -#include #include #include @@ -203,8 +202,7 @@ Result decode_config(Slice input) { template static ActorOwn<> get_simple_config_impl(Promise promise, int32 scheduler_id, string url, string host, std::vector> headers, bool prefer_ipv6, - F &&get_config, - string content = string(), string content_type = string()) { + F &&get_config, string content = string(), string content_type = string()) { VLOG(config_recoverer) << "Request simple config from " << url; #if TD_EMSCRIPTEN // FIXME return ActorOwn<>(); @@ -243,7 +241,8 @@ ActorOwn<> get_simple_config_azure(Promise promise, const Co << "v2/config.txt"; const bool prefer_ipv6 = shared_config == nullptr ? false : shared_config->get_option_boolean("prefer_ipv6"); return get_simple_config_impl(std::move(promise), scheduler_id, std::move(url), "tcdnb.azureedge.net", {}, - prefer_ipv6, [](auto &http_query) -> Result { return http_query.content_.str(); }); + prefer_ipv6, + [](auto &http_query) -> Result { return http_query.content_.str(); }); } static ActorOwn<> get_simple_config_dns(Slice address, Slice host, Promise promise, diff --git a/td/telegram/Global.h b/td/telegram/Global.h index c9fe2623e..1092da8e8 100644 --- a/td/telegram/Global.h +++ b/td/telegram/Global.h @@ -126,9 +126,6 @@ class Global : public ActorContext { bool is_server_time_reliable() const { return server_time_difference_was_updated_; } - double from_server_time(double date) const { - return date - get_server_time_difference(); - } double to_server_time(double now) const { return now + get_server_time_difference(); } diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 63bc8e47b..4b52237eb 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -17484,8 +17484,10 @@ Result MessagesManager::get_message_schedule_date( } switch (scheduling_state->get_id()) { - case td_api::messageSchedulingStateSendWhenOnline::ID: - return static_cast(SCHEDULE_WHEN_ONLINE_DATE); + case td_api::messageSchedulingStateSendWhenOnline::ID: { + auto send_date = SCHEDULE_WHEN_ONLINE_DATE; + return send_date; + } case td_api::messageSchedulingStateSendAtDate::ID: { auto send_at_date = td_api::move_object_as(scheduling_state); auto send_date = send_at_date->send_date_; @@ -26299,8 +26301,8 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq set_dialog_last_read_inbox_message_id(d, MessageId::min(), server_unread_count, local_unread_count, false, source); } else { - // if non-scheduled outgoing message has id one greater than last_read_inbox_message_id then definitely there are no - // unread incoming messages before it + // if non-scheduled outgoing message has id one greater than last_read_inbox_message_id, + // then definitely there are no unread incoming messages before it if (message_id.is_server() && d->last_read_inbox_message_id.is_valid() && d->last_read_inbox_message_id.is_server() && message_id.get_server_message_id().get() == d->last_read_inbox_message_id.get_server_message_id().get() + 1) { diff --git a/td/telegram/net/AuthDataShared.cpp b/td/telegram/net/AuthDataShared.cpp index b83713411..3c07b51c5 100644 --- a/td/telegram/net/AuthDataShared.cpp +++ b/td/telegram/net/AuthDataShared.cpp @@ -108,7 +108,6 @@ class AuthDataSharedImpl : public AuthDataShared { void log_auth_key(const mtproto::AuthKey &auth_key) { LOG(WARNING) << dc_id_ << " " << tag("auth_key_id", auth_key.id()) << tag("state", get_auth_key_state(auth_key)) << tag("created_at", auth_key.created_at()); - ; } }; diff --git a/td/telegram/net/Session.cpp b/td/telegram/net/Session.cpp index d8a073281..3e1aaf861 100644 --- a/td/telegram/net/Session.cpp +++ b/td/telegram/net/Session.cpp @@ -250,8 +250,6 @@ void Session::on_bind_result(NetQueryPtr query) { if (status.code() == 400 && status.message() == "ENCRYPTED_MESSAGE_INVALID") { bool has_immunity = !G()->is_server_time_reliable() || G()->server_time() - auth_data_.get_main_auth_key().created_at() < 60; - LOG(ERROR) << G()->is_server_time_reliable() << " " - << G()->server_time() - auth_data_.get_auth_key().created_at(); if (!use_pfs_) { if (has_immunity) { LOG(WARNING) << "Do not drop main key, because it was created too recently"; @@ -262,7 +260,7 @@ void Session::on_bind_result(NetQueryPtr query) { } } else { if (has_immunity) { - LOG(WARNING) << "Do not check validate main key, because it was created too recently"; + LOG(WARNING) << "Do not validate main key, because it was created too recently"; } else { need_check_main_key_ = true; auth_data_.set_use_pfs(false); @@ -274,15 +272,12 @@ void Session::on_bind_result(NetQueryPtr query) { auto r_flag = fetch_result(query->ok()); if (r_flag.is_error()) { status = r_flag.move_as_error(); - } else { - auto flag = r_flag.move_as_ok(); - if (!flag) { - status = Status::Error("Returned false"); - } + } else if (!r_flag.ok()) { + status = Status::Error("Returned false"); } } if (status.is_ok()) { - LOG(INFO) << "BOUND!" << tag("tmp_id", auth_data_.get_tmp_auth_key().id()); + LOG(INFO) << "Bound temp auth key " << auth_data_.get_tmp_auth_key().id(); auth_data_.on_bind(); on_tmp_auth_key_updated(); } else { @@ -331,7 +326,6 @@ void Session::on_result(NetQueryPtr query) { return on_check_key_result(std::move(query)); } query->clear(); - return; } void Session::return_query(NetQueryPtr &&query) { @@ -491,9 +485,8 @@ void Session::on_closed(Status status) { auth_data_.drop_main_auth_key(); on_auth_key_updated(); } else { + // log out if has error and or 1 minute is passed from start, or 1 minute has passed since auth_key creation if (!use_pfs_) { - // Logout if has error and or 1 minute is passed from start, or 1 minute has passed - // since auth_key creation auth_data_.set_use_pfs(true); } else if (need_check_main_key_) { LOG(WARNING) << "Invalidate main key"; @@ -503,7 +496,7 @@ void Session::on_closed(Status status) { } } - // resend all queries without ack. + // resend all queries without ack for (auto it = sent_queries_.begin(); it != sent_queries_.end();) { if (!it->second.ack && it->second.connection_id == current_info_->connection_id) { // container vector leak otherwise