Add SendCodeHelper.h.

GitOrigin-RevId: 0e8ad767eb1415856b329f508d8741bf4e7912f7
This commit is contained in:
levlam 2019-02-16 18:49:39 +03:00
parent 8ffcd29f11
commit b52a66bf12
6 changed files with 312 additions and 227 deletions

View File

@ -423,6 +423,7 @@ set(TDLIB_SOURCE
td/telegram/SecureManager.cpp
td/telegram/SecureStorage.cpp
td/telegram/SecureValue.cpp
td/telegram/SendCodeHelper.cpp
td/telegram/SequenceDispatcher.cpp
td/telegram/StateManager.cpp
td/telegram/StickersManager.cpp
@ -488,10 +489,8 @@ set(TDLIB_SOURCE
td/telegram/DocumentsManager.h
td/telegram/DraftMessage.h
td/telegram/FileReferenceManager.h
td/telegram/FileReferenceManager.hpp
td/telegram/files/FileBitmask.h
td/telegram/files/FileData.h
td/telegram/files/FileData.hpp
td/telegram/files/FileDb.h
td/telegram/files/FileDbId.h
td/telegram/files/FileDownloader.h
@ -507,7 +506,6 @@ set(TDLIB_SOURCE
td/telegram/files/FileLoaderUtils.h
td/telegram/files/FileLoadManager.h
td/telegram/files/FileLocation.h
td/telegram/files/FileLocation.hpp
td/telegram/files/FileManager.h
td/telegram/files/FileSourceId.h
td/telegram/files/FileStats.h
@ -579,6 +577,7 @@ set(TDLIB_SOURCE
td/telegram/SecureManager.h
td/telegram/SecureStorage.h
td/telegram/SecureValue.h
td/telegram/SendCodeHelper.h
td/telegram/SequenceDispatcher.h
td/telegram/SetWithPosition.h
td/telegram/StateManager.h
@ -606,7 +605,10 @@ set(TDLIB_SOURCE
td/telegram/AuthManager.hpp
td/telegram/DocumentsManager.hpp
td/telegram/DraftMessage.hpp
td/telegram/FileReferenceManager.hpp
td/telegram/files/FileData.hpp
td/telegram/files/FileId.hpp
td/telegram/files/FileLocation.hpp
td/telegram/files/FileManager.hpp
td/telegram/Game.hpp
td/telegram/InputMessageText.hpp
@ -616,6 +618,7 @@ set(TDLIB_SOURCE
td/telegram/Photo.hpp
td/telegram/ReplyMarkup.hpp
td/telegram/SecureValue.hpp
td/telegram/SendCodeHelper.hpp
td/telegram/StickersManager.hpp
td/telegram/VideoNotesManager.hpp
td/telegram/VideosManager.hpp

View File

@ -33,151 +33,6 @@
namespace td {
// SendCodeHelper
void SendCodeHelper::on_sent_code(telegram_api::object_ptr<telegram_api::auth_sentCode> sent_code) {
phone_registered_ = (sent_code->flags_ & SENT_CODE_FLAG_IS_USER_REGISTERED) != 0;
phone_code_hash_ = sent_code->phone_code_hash_;
sent_code_info_ = get_authentication_code_info(std::move(sent_code->type_));
next_code_info_ = get_authentication_code_info(std::move(sent_code->next_type_));
next_code_timestamp_ = Timestamp::in((sent_code->flags_ & SENT_CODE_FLAG_HAS_TIMEOUT) != 0 ? sent_code->timeout_ : 0);
}
td_api::object_ptr<td_api::authorizationStateWaitCode> SendCodeHelper::get_authorization_state_wait_code(
const TermsOfService &terms_of_service) const {
return make_tl_object<td_api::authorizationStateWaitCode>(
phone_registered_, terms_of_service.get_terms_of_service_object(), get_authentication_code_info_object());
}
td_api::object_ptr<td_api::authenticationCodeInfo> SendCodeHelper::get_authentication_code_info_object() const {
return make_tl_object<td_api::authenticationCodeInfo>(
phone_number_, get_authentication_code_type_object(sent_code_info_),
get_authentication_code_type_object(next_code_info_),
max(static_cast<int32>(next_code_timestamp_.in() + 1 - 1e-9), 0));
}
Result<telegram_api::auth_resendCode> SendCodeHelper::resend_code() {
if (next_code_info_.type == AuthenticationCodeInfo::Type::None) {
return Status::Error(8, "Authentication code can't be resend");
}
sent_code_info_ = next_code_info_;
next_code_info_ = {};
next_code_timestamp_ = {};
return telegram_api::auth_resendCode(phone_number_, phone_code_hash_);
}
Result<telegram_api::auth_sendCode> SendCodeHelper::send_code(Slice phone_number, bool allow_flash_call,
bool is_current_phone_number, int32 api_id,
const string &api_hash) {
if (!phone_number_.empty()) {
return Status::Error(8, "Can't change phone");
}
phone_number_ = phone_number.str();
int32 flags = 0;
if (allow_flash_call) {
flags |= AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL;
}
return telegram_api::auth_sendCode(flags, false /*ignored*/, phone_number_, is_current_phone_number, api_id,
api_hash);
}
Result<telegram_api::account_sendChangePhoneCode> SendCodeHelper::send_change_phone_code(Slice phone_number,
bool allow_flash_call,
bool is_current_phone_number) {
phone_number_ = phone_number.str();
int32 flags = 0;
if (allow_flash_call) {
flags |= AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL;
}
return telegram_api::account_sendChangePhoneCode(flags, false /*ignored*/, phone_number_, is_current_phone_number);
}
Result<telegram_api::account_sendVerifyPhoneCode> SendCodeHelper::send_verify_phone_code(const string &hash,
Slice phone_number,
bool allow_flash_call,
bool is_current_phone_number) {
phone_number_ = phone_number.str();
int32 flags = 0;
if (allow_flash_call) {
flags |= AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL;
}
return telegram_api::account_sendVerifyPhoneCode(flags, false /*ignored*/, hash, is_current_phone_number);
}
Result<telegram_api::account_sendConfirmPhoneCode> SendCodeHelper::send_confirm_phone_code(
Slice phone_number, bool allow_flash_call, bool is_current_phone_number) {
phone_number_ = phone_number.str();
int32 flags = 0;
if (allow_flash_call) {
flags |= AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL;
}
return telegram_api::account_sendConfirmPhoneCode(flags, false /*ignored*/, phone_number_, is_current_phone_number);
}
SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_authentication_code_info(
tl_object_ptr<telegram_api::auth_CodeType> &&code_type_ptr) {
if (code_type_ptr == nullptr) {
return AuthenticationCodeInfo();
}
switch (code_type_ptr->get_id()) {
case telegram_api::auth_codeTypeSms::ID:
return {AuthenticationCodeInfo::Type::Sms, 0, ""};
case telegram_api::auth_codeTypeCall::ID:
return {AuthenticationCodeInfo::Type::Call, 0, ""};
case telegram_api::auth_codeTypeFlashCall::ID:
return {AuthenticationCodeInfo::Type::FlashCall, 0, ""};
default:
UNREACHABLE();
return AuthenticationCodeInfo();
}
}
SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_authentication_code_info(
tl_object_ptr<telegram_api::auth_SentCodeType> &&sent_code_type_ptr) {
CHECK(sent_code_type_ptr != nullptr);
switch (sent_code_type_ptr->get_id()) {
case telegram_api::auth_sentCodeTypeApp::ID: {
auto code_type = move_tl_object_as<telegram_api::auth_sentCodeTypeApp>(sent_code_type_ptr);
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::Message, code_type->length_, ""};
}
case telegram_api::auth_sentCodeTypeSms::ID: {
auto code_type = move_tl_object_as<telegram_api::auth_sentCodeTypeSms>(sent_code_type_ptr);
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::Sms, code_type->length_, ""};
}
case telegram_api::auth_sentCodeTypeCall::ID: {
auto code_type = move_tl_object_as<telegram_api::auth_sentCodeTypeCall>(sent_code_type_ptr);
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::Call, code_type->length_, ""};
}
case telegram_api::auth_sentCodeTypeFlashCall::ID: {
auto code_type = move_tl_object_as<telegram_api::auth_sentCodeTypeFlashCall>(sent_code_type_ptr);
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::FlashCall, 0, code_type->pattern_};
}
default:
UNREACHABLE();
return AuthenticationCodeInfo();
}
}
tl_object_ptr<td_api::AuthenticationCodeType> SendCodeHelper::get_authentication_code_type_object(
const AuthenticationCodeInfo &authentication_code_info) {
switch (authentication_code_info.type) {
case AuthenticationCodeInfo::Type::None:
return nullptr;
case AuthenticationCodeInfo::Type::Message:
return make_tl_object<td_api::authenticationCodeTypeTelegramMessage>(authentication_code_info.length);
case AuthenticationCodeInfo::Type::Sms:
return make_tl_object<td_api::authenticationCodeTypeSms>(authentication_code_info.length);
case AuthenticationCodeInfo::Type::Call:
return make_tl_object<td_api::authenticationCodeTypeCall>(authentication_code_info.length);
case AuthenticationCodeInfo::Type::FlashCall:
return make_tl_object<td_api::authenticationCodeTypeFlashCall>(authentication_code_info.pattern);
default:
UNREACHABLE();
return nullptr;
}
}
// PhoneNumberManager
void PhoneNumberManager::get_state(uint64 query_id) {
tl_object_ptr<td_api::Object> obj;
switch (state_) {
@ -411,7 +266,6 @@ void PhoneNumberManager::tear_down() {
parent_.reset();
}
// AuthManager
AuthManager::AuthManager(int32 api_id, const string &api_hash, ActorShared<> parent)
: parent_(std::move(parent)), api_id_(api_id), api_hash_(api_hash) {
string auth_str = G()->td_db()->get_binlog_pmc()->get("auth");

View File

@ -8,6 +8,7 @@
#include "td/telegram/net/NetActor.h"
#include "td/telegram/net/NetQuery.h"
#include "td/telegram/SendCodeHelper.h"
#include "td/telegram/TermsOfService.h"
#include "td/telegram/td_api.h"
@ -16,89 +17,11 @@
#include "td/actor/actor.h"
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/Time.h"
namespace td {
class SendCodeHelper {
public:
void on_sent_code(telegram_api::object_ptr<telegram_api::auth_sentCode> sent_code);
td_api::object_ptr<td_api::authorizationStateWaitCode> get_authorization_state_wait_code(
const TermsOfService &terms_of_service) const;
td_api::object_ptr<td_api::authenticationCodeInfo> get_authentication_code_info_object() const;
Result<telegram_api::auth_resendCode> resend_code();
Result<telegram_api::auth_sendCode> send_code(Slice phone_number, bool allow_flash_call, bool is_current_phone_number,
int32 api_id, const string &api_hash);
Result<telegram_api::account_sendChangePhoneCode> send_change_phone_code(Slice phone_number, bool allow_flash_call,
bool is_current_phone_number);
Result<telegram_api::account_sendVerifyPhoneCode> send_verify_phone_code(const string &hash, Slice phone_number,
bool allow_flash_call,
bool is_current_phone_number);
Result<telegram_api::account_sendConfirmPhoneCode> send_confirm_phone_code(Slice phone_number, bool allow_flash_call,
bool is_current_phone_number);
Slice phone_number() const {
return phone_number_;
}
Slice phone_code_hash() const {
return phone_code_hash_;
}
bool phone_registered() const {
return phone_registered_;
}
template <class T>
void store(T &storer) const;
template <class T>
void parse(T &parser);
private:
static constexpr int32 AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL = 1 << 0;
static constexpr int32 SENT_CODE_FLAG_IS_USER_REGISTERED = 1 << 0;
static constexpr int32 SENT_CODE_FLAG_HAS_NEXT_TYPE = 1 << 1;
static constexpr int32 SENT_CODE_FLAG_HAS_TIMEOUT = 1 << 2;
struct AuthenticationCodeInfo {
enum class Type : int32 { None, Message, Sms, Call, FlashCall };
Type type = Type::None;
int32 length = 0;
string pattern;
AuthenticationCodeInfo() = default;
AuthenticationCodeInfo(Type type, int length, string pattern)
: type(type), length(length), pattern(std::move(pattern)) {
}
template <class T>
void store(T &storer) const;
template <class T>
void parse(T &parser);
};
string phone_number_;
bool phone_registered_;
string phone_code_hash_;
SendCodeHelper::AuthenticationCodeInfo sent_code_info_;
SendCodeHelper::AuthenticationCodeInfo next_code_info_;
Timestamp next_code_timestamp_;
static AuthenticationCodeInfo get_authentication_code_info(
tl_object_ptr<telegram_api::auth_CodeType> &&code_type_ptr);
static AuthenticationCodeInfo get_authentication_code_info(
tl_object_ptr<telegram_api::auth_SentCodeType> &&sent_code_type_ptr);
static tl_object_ptr<td_api::AuthenticationCodeType> get_authentication_code_type_object(
const AuthenticationCodeInfo &authentication_code_info);
};
class PhoneNumberManager : public NetActor {
public:
enum class Type : int32 { ChangePhone, VerifyPhone, ConfirmPhone };
@ -312,4 +235,5 @@ class AuthManager : public NetActor {
void start_up() override;
void tear_down() override;
};
} // namespace td

View File

@ -0,0 +1,154 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/telegram/SendCodeHelper.h"
namespace td {
void SendCodeHelper::on_sent_code(telegram_api::object_ptr<telegram_api::auth_sentCode> sent_code) {
phone_registered_ = (sent_code->flags_ & SENT_CODE_FLAG_IS_USER_REGISTERED) != 0;
phone_code_hash_ = sent_code->phone_code_hash_;
sent_code_info_ = get_authentication_code_info(std::move(sent_code->type_));
next_code_info_ = get_authentication_code_info(std::move(sent_code->next_type_));
next_code_timestamp_ = Timestamp::in((sent_code->flags_ & SENT_CODE_FLAG_HAS_TIMEOUT) != 0 ? sent_code->timeout_ : 0);
}
td_api::object_ptr<td_api::authorizationStateWaitCode> SendCodeHelper::get_authorization_state_wait_code(
const TermsOfService &terms_of_service) const {
return make_tl_object<td_api::authorizationStateWaitCode>(
phone_registered_, terms_of_service.get_terms_of_service_object(), get_authentication_code_info_object());
}
td_api::object_ptr<td_api::authenticationCodeInfo> SendCodeHelper::get_authentication_code_info_object() const {
return make_tl_object<td_api::authenticationCodeInfo>(
phone_number_, get_authentication_code_type_object(sent_code_info_),
get_authentication_code_type_object(next_code_info_),
max(static_cast<int32>(next_code_timestamp_.in() + 1 - 1e-9), 0));
}
Result<telegram_api::auth_resendCode> SendCodeHelper::resend_code() {
if (next_code_info_.type == AuthenticationCodeInfo::Type::None) {
return Status::Error(8, "Authentication code can't be resend");
}
sent_code_info_ = next_code_info_;
next_code_info_ = {};
next_code_timestamp_ = {};
return telegram_api::auth_resendCode(phone_number_, phone_code_hash_);
}
Result<telegram_api::auth_sendCode> SendCodeHelper::send_code(Slice phone_number, bool allow_flash_call,
bool is_current_phone_number, int32 api_id,
const string &api_hash) {
if (!phone_number_.empty()) {
return Status::Error(8, "Can't change phone");
}
phone_number_ = phone_number.str();
int32 flags = 0;
if (allow_flash_call) {
flags |= AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL;
}
return telegram_api::auth_sendCode(flags, false /*ignored*/, phone_number_, is_current_phone_number, api_id,
api_hash);
}
Result<telegram_api::account_sendChangePhoneCode> SendCodeHelper::send_change_phone_code(Slice phone_number,
bool allow_flash_call,
bool is_current_phone_number) {
phone_number_ = phone_number.str();
int32 flags = 0;
if (allow_flash_call) {
flags |= AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL;
}
return telegram_api::account_sendChangePhoneCode(flags, false /*ignored*/, phone_number_, is_current_phone_number);
}
Result<telegram_api::account_sendVerifyPhoneCode> SendCodeHelper::send_verify_phone_code(const string &hash,
Slice phone_number,
bool allow_flash_call,
bool is_current_phone_number) {
phone_number_ = phone_number.str();
int32 flags = 0;
if (allow_flash_call) {
flags |= AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL;
}
return telegram_api::account_sendVerifyPhoneCode(flags, false /*ignored*/, hash, is_current_phone_number);
}
Result<telegram_api::account_sendConfirmPhoneCode> SendCodeHelper::send_confirm_phone_code(
Slice phone_number, bool allow_flash_call, bool is_current_phone_number) {
phone_number_ = phone_number.str();
int32 flags = 0;
if (allow_flash_call) {
flags |= AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL;
}
return telegram_api::account_sendConfirmPhoneCode(flags, false /*ignored*/, phone_number_, is_current_phone_number);
}
SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_authentication_code_info(
tl_object_ptr<telegram_api::auth_CodeType> &&code_type_ptr) {
if (code_type_ptr == nullptr) {
return AuthenticationCodeInfo();
}
switch (code_type_ptr->get_id()) {
case telegram_api::auth_codeTypeSms::ID:
return {AuthenticationCodeInfo::Type::Sms, 0, ""};
case telegram_api::auth_codeTypeCall::ID:
return {AuthenticationCodeInfo::Type::Call, 0, ""};
case telegram_api::auth_codeTypeFlashCall::ID:
return {AuthenticationCodeInfo::Type::FlashCall, 0, ""};
default:
UNREACHABLE();
return AuthenticationCodeInfo();
}
}
SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_authentication_code_info(
tl_object_ptr<telegram_api::auth_SentCodeType> &&sent_code_type_ptr) {
CHECK(sent_code_type_ptr != nullptr);
switch (sent_code_type_ptr->get_id()) {
case telegram_api::auth_sentCodeTypeApp::ID: {
auto code_type = move_tl_object_as<telegram_api::auth_sentCodeTypeApp>(sent_code_type_ptr);
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::Message, code_type->length_, ""};
}
case telegram_api::auth_sentCodeTypeSms::ID: {
auto code_type = move_tl_object_as<telegram_api::auth_sentCodeTypeSms>(sent_code_type_ptr);
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::Sms, code_type->length_, ""};
}
case telegram_api::auth_sentCodeTypeCall::ID: {
auto code_type = move_tl_object_as<telegram_api::auth_sentCodeTypeCall>(sent_code_type_ptr);
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::Call, code_type->length_, ""};
}
case telegram_api::auth_sentCodeTypeFlashCall::ID: {
auto code_type = move_tl_object_as<telegram_api::auth_sentCodeTypeFlashCall>(sent_code_type_ptr);
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::FlashCall, 0, code_type->pattern_};
}
default:
UNREACHABLE();
return AuthenticationCodeInfo();
}
}
tl_object_ptr<td_api::AuthenticationCodeType> SendCodeHelper::get_authentication_code_type_object(
const AuthenticationCodeInfo &authentication_code_info) {
switch (authentication_code_info.type) {
case AuthenticationCodeInfo::Type::None:
return nullptr;
case AuthenticationCodeInfo::Type::Message:
return make_tl_object<td_api::authenticationCodeTypeTelegramMessage>(authentication_code_info.length);
case AuthenticationCodeInfo::Type::Sms:
return make_tl_object<td_api::authenticationCodeTypeSms>(authentication_code_info.length);
case AuthenticationCodeInfo::Type::Call:
return make_tl_object<td_api::authenticationCodeTypeCall>(authentication_code_info.length);
case AuthenticationCodeInfo::Type::FlashCall:
return make_tl_object<td_api::authenticationCodeTypeFlashCall>(authentication_code_info.pattern);
default:
UNREACHABLE();
return nullptr;
}
}
} // namespace td

View File

@ -0,0 +1,97 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/TermsOfService.h"
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/Time.h"
namespace td {
class SendCodeHelper {
public:
void on_sent_code(telegram_api::object_ptr<telegram_api::auth_sentCode> sent_code);
td_api::object_ptr<td_api::authorizationStateWaitCode> get_authorization_state_wait_code(
const TermsOfService &terms_of_service) const;
td_api::object_ptr<td_api::authenticationCodeInfo> get_authentication_code_info_object() const;
Result<telegram_api::auth_resendCode> resend_code();
Result<telegram_api::auth_sendCode> send_code(Slice phone_number, bool allow_flash_call, bool is_current_phone_number,
int32 api_id, const string &api_hash);
Result<telegram_api::account_sendChangePhoneCode> send_change_phone_code(Slice phone_number, bool allow_flash_call,
bool is_current_phone_number);
Result<telegram_api::account_sendVerifyPhoneCode> send_verify_phone_code(const string &hash, Slice phone_number,
bool allow_flash_call,
bool is_current_phone_number);
Result<telegram_api::account_sendConfirmPhoneCode> send_confirm_phone_code(Slice phone_number, bool allow_flash_call,
bool is_current_phone_number);
Slice phone_number() const {
return phone_number_;
}
Slice phone_code_hash() const {
return phone_code_hash_;
}
bool phone_registered() const {
return phone_registered_;
}
template <class T>
void store(T &storer) const;
template <class T>
void parse(T &parser);
private:
static constexpr int32 AUTH_SEND_CODE_FLAG_ALLOW_FLASH_CALL = 1 << 0;
static constexpr int32 SENT_CODE_FLAG_IS_USER_REGISTERED = 1 << 0;
static constexpr int32 SENT_CODE_FLAG_HAS_NEXT_TYPE = 1 << 1;
static constexpr int32 SENT_CODE_FLAG_HAS_TIMEOUT = 1 << 2;
struct AuthenticationCodeInfo {
enum class Type : int32 { None, Message, Sms, Call, FlashCall };
Type type = Type::None;
int32 length = 0;
string pattern;
AuthenticationCodeInfo() = default;
AuthenticationCodeInfo(Type type, int length, string pattern)
: type(type), length(length), pattern(std::move(pattern)) {
}
template <class T>
void store(T &storer) const;
template <class T>
void parse(T &parser);
};
string phone_number_;
bool phone_registered_;
string phone_code_hash_;
SendCodeHelper::AuthenticationCodeInfo sent_code_info_;
SendCodeHelper::AuthenticationCodeInfo next_code_info_;
Timestamp next_code_timestamp_;
static AuthenticationCodeInfo get_authentication_code_info(
tl_object_ptr<telegram_api::auth_CodeType> &&code_type_ptr);
static AuthenticationCodeInfo get_authentication_code_info(
tl_object_ptr<telegram_api::auth_SentCodeType> &&sent_code_type_ptr);
static tl_object_ptr<td_api::AuthenticationCodeType> get_authentication_code_type_object(
const AuthenticationCodeInfo &authentication_code_info);
};
} // namespace td

View File

@ -0,0 +1,53 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/telegram/SendCodeHelper.h"
#include "td/utils/tl_helpers.h"
namespace td {
template <class T>
void SendCodeHelper::AuthenticationCodeInfo::store(T &storer) const {
using td::store;
store(type, storer);
store(length, storer);
store(pattern, storer);
}
template <class T>
void SendCodeHelper::AuthenticationCodeInfo::parse(T &parser) {
using td::parse;
parse(type, parser);
parse(length, parser);
parse(pattern, parser);
}
template <class T>
void SendCodeHelper::store(T &storer) const {
using td::store;
store(phone_number_, storer);
store(phone_registered_, storer);
store(phone_code_hash_, storer);
store(sent_code_info_, storer);
store(next_code_info_, storer);
store(next_code_timestamp_, storer);
}
template <class T>
void SendCodeHelper::parse(T &parser) {
using td::parse;
parse(phone_number_, parser);
parse(phone_registered_, parser);
parse(phone_code_hash_, parser);
parse(sent_code_info_, parser);
parse(next_code_info_, parser);
parse(next_code_timestamp_, parser);
}
} // namespace td