From 61f7da7215c137ff4f8854255bd8991ef7017dc3 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 11 Jul 2022 12:57:42 +0300 Subject: [PATCH] Add option "commit_hash". --- td/telegram/OptionManager.cpp | 4 ++++ td/telegram/Td.cpp | 7 +++++++ td/telegram/Td.h | 2 ++ 3 files changed, 13 insertions(+) diff --git a/td/telegram/OptionManager.cpp b/td/telegram/OptionManager.cpp index ba8248627..757ba7577 100644 --- a/td/telegram/OptionManager.cpp +++ b/td/telegram/OptionManager.cpp @@ -398,6 +398,9 @@ void OptionManager::get_option(const string &name, Promiseconfig_manager_, &ConfigManager::get_content_settings, wrap_promise()); } + if (name == "commit_hash") { + return promise.set_value(Td::get_commit_hash_option_value_object()); + } break; case 'd': if (!is_bot && name == "disable_contact_registered_notifications") { @@ -761,6 +764,7 @@ td_api::object_ptr OptionManager::get_option_value_object(S void OptionManager::get_current_state(vector> &updates) const { updates.push_back(td_api::make_object("version", Td::get_version_option_value_object())); + updates.push_back(td_api::make_object("commit_hash", Td::get_commit_hash_option_value_object())); updates.push_back(td_api::make_object( "online", td_api::make_object(td_->is_online()))); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 528be8bb5..104ffc0dd 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -52,6 +52,7 @@ #include "td/telegram/FolderId.h" #include "td/telegram/FullMessageId.h" #include "td/telegram/GameManager.h" +#include "td/telegram/GitCommitHash.h" #include "td/telegram/Global.h" #include "td/telegram/GroupCallId.h" #include "td/telegram/GroupCallManager.h" @@ -3058,6 +3059,7 @@ void Td::run_request(uint64 id, tl_object_ptr function) { case td_api::getCurrentState::ID: { vector> updates; updates.push_back(td_api::make_object("version", get_version_option_value_object())); + updates.push_back(td_api::make_object("commit_hash", get_commit_hash_option_value_object())); updates.push_back(td_api::make_object(get_fake_authorization_state_object())); // send response synchronously to prevent "Request aborted" return send_result(id, td_api::make_object(std::move(updates))); @@ -3258,6 +3260,10 @@ td_api::object_ptr Td::get_version_option_value_object() { return td_api::make_object(TDLIB_VERSION); } +td_api::object_ptr Td::get_commit_hash_option_value_object() { + return td_api::make_object(get_git_commit_hash()); +} + void Td::start_up() { always_wait_for_mailbox(); @@ -3279,6 +3285,7 @@ void Td::start_up() { CHECK(state_ == State::WaitParameters); send_update(td_api::make_object("version", get_version_option_value_object())); + send_update(td_api::make_object("commit_hash", get_commit_hash_option_value_object())); send_update(td_api::make_object( td_api::make_object())); } diff --git a/td/telegram/Td.h b/td/telegram/Td.h index db6ad82ad..bee0d6bdd 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -248,6 +248,8 @@ class Td final : public Actor { static td_api::object_ptr get_version_option_value_object(); + static td_api::object_ptr get_commit_hash_option_value_object(); + private: static constexpr int64 ONLINE_ALARM_ID = 0; static constexpr int64 PING_SERVER_ALARM_ID = -1;