Make optionValueInteger value int64.

GitOrigin-RevId: 7da1c4f051691ff7df31627115a9a37e6c5d5802
This commit is contained in:
levlam 2020-09-25 00:46:16 +03:00
parent b9e27e28b9
commit 1fe397e43d
17 changed files with 56 additions and 50 deletions

View File

@ -2595,7 +2595,7 @@ optionValueBoolean value:Bool = OptionValue;
optionValueEmpty = OptionValue;
//@description Represents an integer option @value The value of the option
optionValueInteger value:int32 = OptionValue;
optionValueInteger value:int64 = OptionValue;
//@description Represents a string option @value The value of the option
optionValueString value:string = OptionValue;

Binary file not shown.

View File

@ -160,7 +160,7 @@ void AuthManager::check_bot_token(uint64 query_id, string bot_token) {
if (state_ == State::Ok) {
if (!is_bot_) {
// fix old bots
const int32 AUTH_IS_BOT_FIXED_DATE = 1500940800;
const int64 AUTH_IS_BOT_FIXED_DATE = 1500940800;
if (G()->shared_config().get_option_integer("authorization_date") < AUTH_IS_BOT_FIXED_DATE) {
G()->td_db()->get_binlog_pmc()->set("auth_is_bot", "true");
is_bot_ = true;

View File

@ -370,7 +370,7 @@ Status CallActor::do_update_call(telegram_api::phoneCallWaiting &call) {
if ((call.flags_ & telegram_api::phoneCallWaiting::RECEIVE_DATE_MASK) != 0) {
call_state_.is_received = true;
call_state_need_flush_ = true;
int32 call_ring_timeout_ms = G()->shared_config().get_option_integer("call_ring_timeout_ms", 90000);
int64 call_ring_timeout_ms = G()->shared_config().get_option_integer("call_ring_timeout_ms", 90000);
set_timeout_in(call_ring_timeout_ms * 0.001);
}
}
@ -453,7 +453,7 @@ Status CallActor::do_update_call(telegram_api::phoneCallAccepted &call) {
void CallActor::on_begin_exchanging_key() {
call_state_.type = CallState::Type::ExchangingKey;
call_state_need_flush_ = true;
int32 call_receive_timeout_ms = G()->shared_config().get_option_integer("call_receive_timeout_ms", 20000);
int64 call_receive_timeout_ms = G()->shared_config().get_option_integer("call_receive_timeout_ms", 20000);
double timeout = call_receive_timeout_ms * 0.001;
LOG(INFO) << "Set call timeout to " << timeout;
set_timeout_in(timeout);
@ -631,7 +631,7 @@ void CallActor::try_send_request_query() {
call_state_.protocol.get_input_phone_call_protocol());
auto query = G()->net_query_creator().create(tl_query);
state_ = State::WaitRequestResult;
int32 call_receive_timeout_ms = G()->shared_config().get_option_integer("call_receive_timeout_ms", 20000);
int64 call_receive_timeout_ms = G()->shared_config().get_option_integer("call_receive_timeout_ms", 20000);
double timeout = call_receive_timeout_ms * 0.001;
LOG(INFO) << "Set call timeout to " << timeout;
set_timeout_in(timeout);

View File

@ -39,7 +39,7 @@ void ConfigShared::set_option_empty(Slice name) {
}
}
void ConfigShared::set_option_integer(Slice name, int32 value) {
void ConfigShared::set_option_integer(Slice name, int64 value) {
if (set_option(name, PSLICE() << "I" << value)) {
on_option_updated(name);
}
@ -78,7 +78,7 @@ bool ConfigShared::get_option_boolean(Slice name, bool default_value) const {
return default_value;
}
int32 ConfigShared::get_option_integer(Slice name, int32 default_value) const {
int64 ConfigShared::get_option_integer(Slice name, int64 default_value) const {
auto str_value = get_option(name);
if (str_value.empty()) {
return default_value;
@ -87,7 +87,7 @@ int32 ConfigShared::get_option_integer(Slice name, int32 default_value) const {
LOG(ERROR) << "Found \"" << str_value << "\" instead of integer option";
return default_value;
}
return to_integer<int32>(str_value.substr(1));
return to_integer<int64>(str_value.substr(1));
}
string ConfigShared::get_option_string(Slice name, string default_value) const {
@ -129,7 +129,7 @@ tl_object_ptr<td_api::OptionValue> ConfigShared::get_option_value_object(Slice v
}
break;
case 'I':
return make_tl_object<td_api::optionValueInteger>(to_integer<int32>(value.substr(1)));
return make_tl_object<td_api::optionValueInteger>(to_integer<int64>(value.substr(1)));
case 'S':
return make_tl_object<td_api::optionValueString>(value.substr(1).str());
}

View File

@ -37,14 +37,14 @@ class ConfigShared {
void set_option_boolean(Slice name, bool value);
void set_option_empty(Slice name);
void set_option_integer(Slice name, int32 value);
void set_option_integer(Slice name, int64 value);
void set_option_string(Slice name, Slice value);
bool have_option(Slice name) const;
std::unordered_map<string, string> get_options() const;
bool get_option_boolean(Slice name, bool default_value = false) const;
int32 get_option_integer(Slice name, int32 default_value = 0) const;
int64 get_option_integer(Slice name, int64 default_value = 0) const;
string get_option_string(Slice name, string default_value = "") const;
tl_object_ptr<td_api::OptionValue> get_option_value(Slice name) const;

View File

@ -19,6 +19,7 @@
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/tl_helpers.h"
@ -200,7 +201,7 @@ double Global::get_dns_time_difference() const {
DcId Global::get_webfile_dc_id() const {
CHECK(shared_config_ != nullptr);
int32 dc_id = shared_config_->get_option_integer("webfile_dc_id");
auto dc_id = narrow_cast<int32>(shared_config_->get_option_integer("webfile_dc_id"));
if (!DcId::is_valid(dc_id)) {
if (is_test_dc()) {
dc_id = 2;

View File

@ -363,7 +363,7 @@ void LanguagePackManager::on_language_pack_version_changed(bool is_base, int32 n
if (new_version < 0) {
Slice version_key = is_base ? Slice("base_language_pack_version") : Slice("language_pack_version");
new_version = G()->shared_config().get_option_integer(version_key, -1);
new_version = narrow_cast<int32>(G()->shared_config().get_option_integer(version_key, -1));
}
if (new_version <= 0) {
return;

View File

@ -9634,7 +9634,7 @@ bool MessagesManager::can_revoke_message(DialogId dialog_id, const Message *m) c
switch (dialog_id.get_type()) {
case DialogType::User: {
bool can_revoke_incoming = G()->shared_config().get_option_boolean("revoke_pm_inbox", true);
int32 revoke_time_limit =
int64 revoke_time_limit =
G()->shared_config().get_option_integer("revoke_pm_time_limit", DEFAULT_REVOKE_TIME_LIMIT);
if (G()->unix_time_cached() - m->date < 86400 && content_type == MessageContentType::Dice) {
@ -9647,7 +9647,7 @@ bool MessagesManager::can_revoke_message(DialogId dialog_id, const Message *m) c
case DialogType::Chat: {
bool is_appointed_administrator =
td_->contacts_manager_->is_appointed_chat_administrator(dialog_id.get_chat_id());
int32 revoke_time_limit = G()->shared_config().get_option_integer("revoke_time_limit", DEFAULT_REVOKE_TIME_LIMIT);
int64 revoke_time_limit = G()->shared_config().get_option_integer("revoke_time_limit", DEFAULT_REVOKE_TIME_LIMIT);
return ((m->is_outgoing && !is_service_message_content(content_type)) || is_appointed_administrator) &&
G()->unix_time_cached() - m->date <= revoke_time_limit;
@ -17569,7 +17569,7 @@ int32 MessagesManager::get_pinned_dialogs_limit(DialogListId dialog_list_id) {
key = Slice("pinned_archived_chat_count_max");
default_limit = 100;
}
int32 limit = clamp(G()->shared_config().get_option_integer(key), 0, 1000);
int32 limit = clamp(narrow_cast<int32>(G()->shared_config().get_option_integer(key)), 0, 1000);
if (limit <= 0) {
return default_limit;
}
@ -23363,7 +23363,7 @@ bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, boo
if (has_edit_time_limit) {
const int32 DEFAULT_EDIT_TIME_LIMIT = 2 * 86400;
int32 edit_time_limit = G()->shared_config().get_option_integer("edit_time_limit", DEFAULT_EDIT_TIME_LIMIT);
int64 edit_time_limit = G()->shared_config().get_option_integer("edit_time_limit", DEFAULT_EDIT_TIME_LIMIT);
if (G()->unix_time_cached() - m->date - (is_editing ? 300 : 0) >= edit_time_limit) {
return false;
}

View File

@ -2362,8 +2362,8 @@ void NotificationManager::on_notification_group_count_max_changed(bool send_upda
return;
}
auto new_max_notification_group_count =
G()->shared_config().get_option_integer("notification_group_count_max", DEFAULT_GROUP_COUNT_MAX);
auto new_max_notification_group_count = narrow_cast<int32>(
G()->shared_config().get_option_integer("notification_group_count_max", DEFAULT_GROUP_COUNT_MAX));
CHECK(MIN_NOTIFICATION_GROUP_COUNT_MAX <= new_max_notification_group_count &&
new_max_notification_group_count <= MAX_NOTIFICATION_GROUP_COUNT_MAX);
@ -2425,8 +2425,8 @@ void NotificationManager::on_notification_group_size_max_changed() {
return;
}
auto new_max_notification_group_size =
G()->shared_config().get_option_integer("notification_group_size_max", DEFAULT_GROUP_SIZE_MAX);
auto new_max_notification_group_size = narrow_cast<int32>(
G()->shared_config().get_option_integer("notification_group_size_max", DEFAULT_GROUP_SIZE_MAX));
CHECK(MIN_NOTIFICATION_GROUP_SIZE_MAX <= new_max_notification_group_size &&
new_max_notification_group_size <= MAX_NOTIFICATION_GROUP_SIZE_MAX);
@ -2508,8 +2508,8 @@ void NotificationManager::on_online_cloud_timeout_changed() {
return;
}
online_cloud_timeout_ms_ =
G()->shared_config().get_option_integer("online_cloud_timeout_ms", DEFAULT_ONLINE_CLOUD_TIMEOUT_MS);
online_cloud_timeout_ms_ = narrow_cast<int32>(
G()->shared_config().get_option_integer("online_cloud_timeout_ms", DEFAULT_ONLINE_CLOUD_TIMEOUT_MS));
VLOG(notifications) << "Set online_cloud_timeout_ms to " << online_cloud_timeout_ms_;
}
@ -2518,8 +2518,8 @@ void NotificationManager::on_notification_cloud_delay_changed() {
return;
}
notification_cloud_delay_ms_ =
G()->shared_config().get_option_integer("notification_cloud_delay_ms", DEFAULT_ONLINE_CLOUD_DELAY_MS);
notification_cloud_delay_ms_ = narrow_cast<int32>(
G()->shared_config().get_option_integer("notification_cloud_delay_ms", DEFAULT_ONLINE_CLOUD_DELAY_MS));
VLOG(notifications) << "Set notification_cloud_delay_ms to " << notification_cloud_delay_ms_;
}
@ -2528,8 +2528,8 @@ void NotificationManager::on_notification_default_delay_changed() {
return;
}
notification_default_delay_ms_ =
G()->shared_config().get_option_integer("notification_default_delay_ms", DEFAULT_DEFAULT_DELAY_MS);
notification_default_delay_ms_ = narrow_cast<int32>(
G()->shared_config().get_option_integer("notification_default_delay_ms", DEFAULT_DEFAULT_DELAY_MS));
VLOG(notifications) << "Set notification_default_delay_ms to " << notification_default_delay_ms_;
}

View File

@ -1132,8 +1132,10 @@ class StickersManager::UploadStickerFileCallback : public FileManager::UploadCal
StickersManager::StickersManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
upload_sticker_file_callback_ = std::make_shared<UploadStickerFileCallback>();
on_update_recent_stickers_limit(G()->shared_config().get_option_integer("recent_stickers_limit", 200));
on_update_favorite_stickers_limit(G()->shared_config().get_option_integer("favorite_stickers_limit", 5));
on_update_recent_stickers_limit(
narrow_cast<int32>(G()->shared_config().get_option_integer("recent_stickers_limit", 200)));
on_update_favorite_stickers_limit(
narrow_cast<int32>(G()->shared_config().get_option_integer("favorite_stickers_limit", 5)));
on_update_dice_emojis();
}

View File

@ -3618,17 +3618,20 @@ void Td::on_config_option_updated(const string &name) {
if (name == "auth") {
return on_authorization_lost();
} else if (name == "saved_animations_limit") {
return animations_manager_->on_update_saved_animations_limit(G()->shared_config().get_option_integer(name));
return animations_manager_->on_update_saved_animations_limit(
narrow_cast<int32>(G()->shared_config().get_option_integer(name)));
} else if (name == "animation_search_emojis") {
return animations_manager_->on_update_animation_search_emojis(G()->shared_config().get_option_string(name));
} else if (name == "animation_search_provider") {
return animations_manager_->on_update_animation_search_provider(G()->shared_config().get_option_string(name));
} else if (name == "recent_stickers_limit") {
return stickers_manager_->on_update_recent_stickers_limit(G()->shared_config().get_option_integer(name));
return stickers_manager_->on_update_recent_stickers_limit(
narrow_cast<int32>(G()->shared_config().get_option_integer(name)));
} else if (name == "favorite_stickers_limit") {
stickers_manager_->on_update_favorite_stickers_limit(G()->shared_config().get_option_integer(name));
stickers_manager_->on_update_favorite_stickers_limit(
narrow_cast<int32>(G()->shared_config().get_option_integer(name)));
} else if (name == "my_id") {
G()->set_my_id(G()->shared_config().get_option_integer(name));
G()->set_my_id(static_cast<int32>(G()->shared_config().get_option_integer(name)));
} else if (name == "session_count") {
G()->net_query_dispatcher().update_session_count();
} else if (name == "use_pfs") {
@ -6974,7 +6977,7 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
LOG(INFO) << "Set option " << request.name_;
auto set_integer_option = [&](Slice name, int32 min = 0, int32 max = std::numeric_limits<int32>::max()) {
auto set_integer_option = [&](Slice name, int64 min = 0, int64 max = std::numeric_limits<int32>::max()) {
if (request.name_ != name) {
return false;
}
@ -6986,7 +6989,7 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
if (value_constructor_id == td_api::optionValueEmpty::ID) {
G()->shared_config().set_option_empty(name);
} else {
int32 value = static_cast<td_api::optionValueInteger *>(request.value_.get())->value_;
int64 value = static_cast<td_api::optionValueInteger *>(request.value_.get())->value_;
if (value < min || value > max) {
send_error_raw(id, 3,
PSLICE() << "Option's \"" << name << "\" value " << value << " is outside of a valid range ["

View File

@ -240,7 +240,7 @@ void TopDialogManager::update_rating_e_decay() {
if (!is_active_) {
return;
}
rating_e_decay_ = G()->shared_config().get_option_integer("rating_e_decay", rating_e_decay_);
rating_e_decay_ = narrow_cast<int32>(G()->shared_config().get_option_integer("rating_e_decay", rating_e_decay_));
}
template <class StorerT>

View File

@ -286,11 +286,9 @@ class CliClient final : public Actor {
}
void update_option(const td_api::updateOption &option) {
if (option.name_ == "my_id") {
if (option.value_->get_id() == td_api::optionValueInteger::ID) {
my_id_ = static_cast<const td_api::optionValueInteger *>(option.value_.get())->value_;
LOG(INFO) << "Set my id to " << my_id_;
}
if (option.name_ == "my_id" && option.value_->get_id() == td_api::optionValueInteger::ID) {
my_id_ = static_cast<int32>(static_cast<const td_api::optionValueInteger *>(option.value_.get())->value_);
LOG(INFO) << "Set my id to " << my_id_;
}
}
@ -2190,7 +2188,7 @@ class CliClient final : public Actor {
string value;
std::tie(name, value) = split(args);
int32 value_int = to_integer<int32>(value);
auto value_int = to_integer<int64>(value);
send_request(
td_api::make_object<td_api::setOption>(name, td_api::make_object<td_api::optionValueInteger>(value_int)));
} else if (op == "sos") {

View File

@ -10,6 +10,7 @@
#include "td/telegram/Global.h"
#include "td/utils/format.h"
#include "td/utils/misc.h"
namespace td {
@ -21,16 +22,17 @@ FileGcParameters::FileGcParameters(int64 size, int32 ttl, int32 count, int32 imm
, exclude_owner_dialog_ids(std::move(exclude_owner_dialog_ids))
, dialog_limit(dialog_limit) {
auto &config = G()->shared_config();
this->max_files_size =
size >= 0 ? size : static_cast<int64>(config.get_option_integer("storage_max_files_size", 100 << 10)) << 10;
this->max_files_size = size >= 0 ? size : config.get_option_integer("storage_max_files_size", 100 << 10) << 10;
this->max_time_from_last_access =
ttl >= 0 ? ttl : config.get_option_integer("storage_max_time_from_last_access", 60 * 60 * 23);
ttl >= 0 ? ttl : narrow_cast<int32>(config.get_option_integer("storage_max_time_from_last_access", 60 * 60 * 23));
this->max_file_count = count >= 0 ? count : config.get_option_integer("storage_max_file_count", 40000);
this->max_file_count =
count >= 0 ? count : narrow_cast<int32>(config.get_option_integer("storage_max_file_count", 40000));
this->immunity_delay =
immunity_delay >= 0 ? immunity_delay : config.get_option_integer("storage_immunity_delay", 60 * 60);
this->immunity_delay = immunity_delay >= 0
? immunity_delay
: narrow_cast<int32>(config.get_option_integer("storage_immunity_delay", 60 * 60));
}
StringBuilder &operator<<(StringBuilder &string_builder, const FileGcParameters &parameters) {

View File

@ -271,7 +271,7 @@ bool NetQueryDispatcher::is_dc_inited(int32 raw_dc_id) {
return dcs_[raw_dc_id - 1].is_valid_.load(std::memory_order_relaxed);
}
int32 NetQueryDispatcher::get_session_count() {
return max(G()->shared_config().get_option_integer("session_count"), 1);
return max(narrow_cast<int32>(G()->shared_config().get_option_integer("session_count")), 1);
}
bool NetQueryDispatcher::get_use_pfs() {

View File

@ -219,7 +219,7 @@ void NetStatsManager::start_up() {
since_total_ = unix_time;
G()->td_db()->get_binlog_pmc()->set("net_stats_since", to_string(since_total_));
} else if (since < authorization_date - 3600) {
since_total_ = authorization_date;
since_total_ = narrow_cast<int32>(authorization_date);
G()->td_db()->get_binlog_pmc()->set("net_stats_since", to_string(since_total_));
} else {
since_total_ = since;