Various improvements.
GitOrigin-RevId: e2480ad06ef003e2d0e8db769c837d5b713d96c1
This commit is contained in:
parent
a4f664e697
commit
2b75f6030f
@ -3016,7 +3016,7 @@ getPassportData type:PassportDataType password:string = PassportData;
|
|||||||
//@description Returns all filled Telegram Passport data @password Password of the current user
|
//@description Returns all filled Telegram Passport data @password Password of the current user
|
||||||
getAllPassportData password:string = AllPassportData;
|
getAllPassportData password:string = AllPassportData;
|
||||||
|
|
||||||
//@description Sets Telegram Passport data @data Input Telegram Passport data @password Password of the current user
|
//@description Sets Telegram Passport data. May return an error with a message "PHONE_VERIFICATION_NEEDED" or "EMAIL_VERIFICATION_NEEDED" if the set phone number or the set email address must be verified first @data Input Telegram Passport data @password Password of the current user
|
||||||
setPassportData data:InputPassportData password:string = PassportData;
|
setPassportData data:InputPassportData password:string = PassportData;
|
||||||
|
|
||||||
//@description Deletes Telegram Passport data @type Data type
|
//@description Deletes Telegram Passport data @type Data type
|
||||||
@ -3095,7 +3095,7 @@ getInviteText = Text;
|
|||||||
//@description Returns the terms of service. Can be called before authorization
|
//@description Returns the terms of service. Can be called before authorization
|
||||||
getTermsOfService = Text;
|
getTermsOfService = Text;
|
||||||
|
|
||||||
//@description Returns information about a tg:// deep link. Returns a 404 error for unknown links. Can be called before authorization @link The link
|
//@description Returns information about a tg:// deep link. Use "tg://need_update_for_some_feature" or "tg:some_unsupported_feature" for testing. Returns a 404 error for unknown links. Can be called before authorization @link The link
|
||||||
getDeepLinkInfo link:string = DeepLinkInfo;
|
getDeepLinkInfo link:string = DeepLinkInfo;
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "td/utils/misc.h"
|
#include "td/utils/misc.h"
|
||||||
#include "td/utils/overloaded.h"
|
#include "td/utils/overloaded.h"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
StringBuilder &operator<<(StringBuilder &string_builder, const SecureValueType &type) {
|
StringBuilder &operator<<(StringBuilder &string_builder, const SecureValueType &type) {
|
||||||
@ -541,6 +543,18 @@ static Result<string> get_date(td_api::object_ptr<td_api::date> &&date) {
|
|||||||
<< lpad0(to_string(date->year_), 4);
|
<< lpad0(to_string(date->year_), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Result<int32> to_int32(Slice str) {
|
||||||
|
CHECK(str.size() <= static_cast<size_t>(std::numeric_limits<int32>::digits10));
|
||||||
|
int32 integer_value = 0;
|
||||||
|
for (auto c : str) {
|
||||||
|
if (!is_digit(c)) {
|
||||||
|
return Status::Error(PSLICE() << "Can't parse \"" << str << "\" as number");
|
||||||
|
}
|
||||||
|
integer_value = integer_value * 10 + c - '0';
|
||||||
|
}
|
||||||
|
return integer_value;
|
||||||
|
}
|
||||||
|
|
||||||
static Result<td_api::object_ptr<td_api::date>> get_date_object(Slice date) {
|
static Result<td_api::object_ptr<td_api::date>> get_date_object(Slice date) {
|
||||||
if (date.empty()) {
|
if (date.empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -552,9 +566,9 @@ static Result<td_api::object_ptr<td_api::date>> get_date_object(Slice date) {
|
|||||||
if (parts.size() != 3 || parts[0].size() != 2 || parts[1].size() != 2 || parts[2].size() != 4) {
|
if (parts.size() != 3 || parts[0].size() != 2 || parts[1].size() != 2 || parts[2].size() != 4) {
|
||||||
return Status::Error(400, "Date has wrong parts");
|
return Status::Error(400, "Date has wrong parts");
|
||||||
}
|
}
|
||||||
TRY_RESULT(day, to_integer_safe<int32>(parts[0]));
|
TRY_RESULT(day, to_int32(parts[0]));
|
||||||
TRY_RESULT(month, to_integer_safe<int32>(parts[1]));
|
TRY_RESULT(month, to_int32(parts[1]));
|
||||||
TRY_RESULT(year, to_integer_safe<int32>(parts[2]));
|
TRY_RESULT(year, to_int32(parts[2]));
|
||||||
TRY_STATUS(check_date(day, month, year));
|
TRY_STATUS(check_date(day, month, year));
|
||||||
|
|
||||||
return td_api::make_object<td_api::date>(day, month, year);
|
return td_api::make_object<td_api::date>(day, month, year);
|
||||||
|
@ -41,7 +41,11 @@ TEST(Mtproto, config) {
|
|||||||
{
|
{
|
||||||
auto guard = sched.get_current_guard();
|
auto guard = sched.get_current_guard();
|
||||||
get_simple_config_azure(PromiseCreator::lambda([&](Result<SimpleConfig> r_simple_config) {
|
get_simple_config_azure(PromiseCreator::lambda([&](Result<SimpleConfig> r_simple_config) {
|
||||||
|
if (r_simple_config.is_ok()) {
|
||||||
LOG(ERROR) << to_string(r_simple_config.ok());
|
LOG(ERROR) << to_string(r_simple_config.ok());
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << r_simple_config.error();
|
||||||
|
}
|
||||||
if (--cnt == 0) {
|
if (--cnt == 0) {
|
||||||
Scheduler::instance()->finish();
|
Scheduler::instance()->finish();
|
||||||
}
|
}
|
||||||
@ -49,7 +53,11 @@ TEST(Mtproto, config) {
|
|||||||
.release();
|
.release();
|
||||||
|
|
||||||
get_simple_config_google_app(PromiseCreator::lambda([&](Result<SimpleConfig> r_simple_config) {
|
get_simple_config_google_app(PromiseCreator::lambda([&](Result<SimpleConfig> r_simple_config) {
|
||||||
|
if (r_simple_config.is_ok()) {
|
||||||
LOG(ERROR) << to_string(r_simple_config.ok());
|
LOG(ERROR) << to_string(r_simple_config.ok());
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << r_simple_config.error();
|
||||||
|
}
|
||||||
if (--cnt == 0) {
|
if (--cnt == 0) {
|
||||||
Scheduler::instance()->finish();
|
Scheduler::instance()->finish();
|
||||||
}
|
}
|
||||||
@ -57,7 +65,11 @@ TEST(Mtproto, config) {
|
|||||||
.release();
|
.release();
|
||||||
|
|
||||||
get_simple_config_google_dns(PromiseCreator::lambda([&](Result<SimpleConfig> r_simple_config) {
|
get_simple_config_google_dns(PromiseCreator::lambda([&](Result<SimpleConfig> r_simple_config) {
|
||||||
|
if (r_simple_config.is_ok()) {
|
||||||
LOG(ERROR) << to_string(r_simple_config.ok());
|
LOG(ERROR) << to_string(r_simple_config.ok());
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << r_simple_config.error();
|
||||||
|
}
|
||||||
if (--cnt == 0) {
|
if (--cnt == 0) {
|
||||||
Scheduler::instance()->finish();
|
Scheduler::instance()->finish();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user