Add option "commit_hash".

This commit is contained in:
levlam 2022-07-11 12:57:42 +03:00
parent 4300c64a30
commit 61f7da7215
3 changed files with 13 additions and 0 deletions

View File

@ -398,6 +398,9 @@ void OptionManager::get_option(const string &name, Promise<td_api::object_ptr<td
if (!is_bot && name == "can_ignore_sensitive_content_restrictions") {
return send_closure_later(td_->config_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<td_api::OptionValue> OptionManager::get_option_value_object(S
void OptionManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
updates.push_back(td_api::make_object<td_api::updateOption>("version", Td::get_version_option_value_object()));
updates.push_back(td_api::make_object<td_api::updateOption>("commit_hash", Td::get_commit_hash_option_value_object()));
updates.push_back(td_api::make_object<td_api::updateOption>(
"online", td_api::make_object<td_api::optionValueBoolean>(td_->is_online())));

View File

@ -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<td_api::Function> function) {
case td_api::getCurrentState::ID: {
vector<td_api::object_ptr<td_api::Update>> updates;
updates.push_back(td_api::make_object<td_api::updateOption>("version", get_version_option_value_object()));
updates.push_back(td_api::make_object<td_api::updateOption>("commit_hash", get_commit_hash_option_value_object()));
updates.push_back(td_api::make_object<td_api::updateAuthorizationState>(get_fake_authorization_state_object()));
// send response synchronously to prevent "Request aborted"
return send_result(id, td_api::make_object<td_api::updates>(std::move(updates)));
@ -3258,6 +3260,10 @@ td_api::object_ptr<td_api::OptionValue> Td::get_version_option_value_object() {
return td_api::make_object<td_api::optionValueString>(TDLIB_VERSION);
}
td_api::object_ptr<td_api::OptionValue> Td::get_commit_hash_option_value_object() {
return td_api::make_object<td_api::optionValueString>(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<td_api::updateOption>("version", get_version_option_value_object()));
send_update(td_api::make_object<td_api::updateOption>("commit_hash", get_commit_hash_option_value_object()));
send_update(td_api::make_object<td_api::updateAuthorizationState>(
td_api::make_object<td_api::authorizationStateWaitTdlibParameters>()));
}

View File

@ -248,6 +248,8 @@ class Td final : public Actor {
static td_api::object_ptr<td_api::OptionValue> get_version_option_value_object();
static td_api::object_ptr<td_api::OptionValue> get_commit_hash_option_value_object();
private:
static constexpr int64 ONLINE_ALARM_ID = 0;
static constexpr int64 PING_SERVER_ALARM_ID = -1;