GitOrigin-RevId: fc78a152bf587172f9c06a3b6af2030fcc6a4976
This commit is contained in:
Arseny Smirnov 2018-12-26 19:35:07 +03:00
parent ac3fa705a2
commit 427110b811
2 changed files with 57 additions and 58 deletions

View File

@ -162,7 +162,7 @@ LanguagePackManager::LanguageDatabase *LanguagePackManager::add_language_databas
database = r_database.move_as_ok();
}
it = language_databases_.emplace(path, make_unique<LanguageDatabase>()).first;
it = language_databases_.emplace(path, nullptr).first;
it->second->path_ = std::move(path);
it->second->database_ = std::move(database);
return it->second.get();

View File

@ -6253,7 +6253,9 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
int32 value_constructor_id = request.value_ == nullptr ? td_api::optionValueEmpty::ID : request.value_->get_id();
auto set_integer_option = [&](Slice name, int32 min = 0, int32 max = std::numeric_limits<int32>::max()) {
if (request.name_ == name) {
if (request.name_ != name) {
return false;
}
if (value_constructor_id != td_api::optionValueInteger::ID &&
value_constructor_id != td_api::optionValueEmpty::ID) {
send_error_raw(id, 3, PSLICE() << "Option \"" << name << "\" must have integer value");
@ -6273,12 +6275,12 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
}
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
return true;
}
return false;
};
auto set_boolean_option = [&](Slice name) {
if (request.name_ == name) {
if (request.name_ != name) {
return false;
}
if (value_constructor_id != td_api::optionValueBoolean::ID &&
value_constructor_id != td_api::optionValueEmpty::ID) {
send_error_raw(id, 3, PSLICE() << "Option \"" << name << "\" must have boolean value");
@ -6292,14 +6294,13 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
}
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
return true;
}
return false;
};
auto set_string_option = [&](Slice name, auto check_value) {
if (request.name_ == name) {
if (value_constructor_id != td_api::optionValueString::ID &&
value_constructor_id != td_api::optionValueEmpty::ID) {
if (request.name_ != name) {
return false;
}
if (value_constructor_id != td_api::optionValueString::ID && value_constructor_id != td_api::optionValueEmpty::ID) {
send_error_raw(id, 3, PSLICE() << "Option \"" << name << "\" must have string value");
return true;
}
@ -6320,8 +6321,6 @@ void Td::on_request(uint64 id, td_api::setOption &request) {
}
send_closure(actor_id(this), &Td::send_result, id, make_tl_object<td_api::ok>());
return true;
}
return false;
};
bool is_bot = auth_manager_ != nullptr && auth_manager_->is_authorized() && auth_manager_->is_bot();