Update layer 78: venue_type, email code length.

GitOrigin-RevId: c10dc49dd0ecd467a78b17081239305035f6e642
This commit is contained in:
levlam 2018-04-09 21:06:37 +03:00
parent d7d91bbaf3
commit 184af85bfc
18 changed files with 92 additions and 49 deletions

View File

@ -59,8 +59,8 @@ authenticationCodeTypeFlashCall pattern:string = AuthenticationCodeType;
//@description Information about the authentication code that was sent @phone_number A phone number that is being authenticated @type Describes the way the code was sent to the user @next_type Describes the way the next code will be sent to the user; may be null @timeout Timeout before the code should be re-sent, in seconds
authenticationCodeInfo phone_number:string type:AuthenticationCodeType next_type:AuthenticationCodeType timeout:int32 = AuthenticationCodeInfo;
//@description Information about the email address authentication code that was sent @email_address_pattern Pattern of the email address to which an authentication code was sent
emailAddressAuthenticationCodeInfo email_address_pattern:string = EmailAddressAuthenticationCodeInfo;
//@description Information about the email address authentication code that was sent @email_address_pattern Pattern of the email address to which an authentication code was sent @length Length of the code; 0 if unknown
emailAddressAuthenticationCodeInfo email_address_pattern:string length:int32 = EmailAddressAuthenticationCodeInfo;
//@class AuthorizationState @description Represents the current authorization state of the client
@ -221,8 +221,8 @@ contact phone_number:string first_name:string last_name:string user_id:int32 = C
location latitude:double longitude:double = Location;
//@description Describes a venue @location Venue location; as defined by the sender @title Venue name; as defined by the sender @address Venue address; as defined by the sender @provider Provider of the venue database; as defined by the sender. Currently only "foursquare" needs to be supported
//@id Identifier of the venue in the provider database; as defined by the sender
venue location:location title:string address:string provider:string id:string = Venue;
//@id Identifier of the venue in the provider database; as defined by the sender @type Type of the venue in the provider database; as defined by the sender
venue location:location title:string address:string provider:string id:string type:string = Venue;
//@description Describes a game @id Game ID @short_name Game short name. To share a game use the URL https://t.me/{bot_username}?game={game_short_name} @title Game title @text Game text, usually containing scoreboards for a game
//@param_description Game description @photo Game photo @animation Game animation; may be null

Binary file not shown.

View File

@ -568,7 +568,7 @@ messages.savedGifs#2e0709a5 hash:int gifs:Vector<Document> = messages.SavedGifs;
inputBotInlineMessageMediaAuto#3380c786 flags:# message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageText#3dcd7a87 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageMediaGeo#c1b15d65 flags:# geo_point:InputGeoPoint period:int reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageMediaVenue#aaafadc8 flags:# geo_point:InputGeoPoint title:string address:string provider:string venue_id:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageMediaVenue#417bbf11 flags:# geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageMediaContact#2daf01a7 flags:# phone_number:string first_name:string last_name:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
inputBotInlineMessageGame#4b425864 flags:# reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
@ -580,7 +580,7 @@ inputBotInlineResultGame#4fa417f2 id:string short_name:string send_message:Input
botInlineMessageMediaAuto#764cf810 flags:# message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineMessageMediaGeo#b722de65 flags:# geo:GeoPoint period:int reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineMessageMediaVenue#4366232e flags:# geo:GeoPoint title:string address:string provider:string venue_id:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineMessageMediaVenue#8a86659c flags:# geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineMessageMediaContact#35edb4d4 flags:# phone_number:string first_name:string last_name:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
botInlineResult#11965f3a flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?WebDocument content:flags.5?WebDocument send_message:BotInlineMessage = BotInlineResult;
@ -865,7 +865,10 @@ secureCredentialsEncrypted#33f0ea47 data:bytes hash:bytes secret:bytes = SecureC
account.authorizationForm#b9d3d1f0 flags:# selfie_required:flags.1?true required_types:Vector<SecureValueType> values:Vector<SecureValue> users:Vector<User> privacy_policy_url:flags.0?string = account.AuthorizationForm;
account.sentEmailCode#28b1633b email_pattern:string = account.SentEmailCode;
account.sentEmailCode#811f854f email_pattern:string length:int = account.SentEmailCode;
help.deepLinkInfoEmpty#66afa166 = help.DeepLinkInfo;
help.deepLinkInfo#6a4ee832 flags:# update_app:flags.0?true message:string entities:flags.1?Vector<MessageEntity> = help.DeepLinkInfo;
---functions---
@ -1079,6 +1082,7 @@ help.getTermsOfService#350170f3 = help.TermsOfService;
help.setBotUpdatesStatus#ec22cfcd pending_updates_count:int message:string = Bool;
help.getCdnConfig#52029342 = CdnConfig;
help.getRecentMeUrls#3dc0f114 referer:string = help.RecentMeUrls;
help.getDeepLinkInfo#3fedc75f path:string = help.DeepLinkInfo;
channels.readHistory#cc104937 channel:InputChannel max_id:int = Bool;
channels.deleteMessages#84c1fd4e channel:InputChannel id:Vector<int> = messages.AffectedMessages;

Binary file not shown.

View File

@ -205,6 +205,9 @@ void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number,
return c(send_code_helper_.send_verify_phone_code(phone_number, allow_flash_call, is_current_phone_number));
case Type::ConfirmPhone:
return c(send_code_helper_.send_confirm_phone_code(phone_number, allow_flash_call, is_current_phone_number));
default:
UNREACHABLE();
return c(send_code_helper_.send_change_phone_code(phone_number, allow_flash_call, is_current_phone_number));
}
};
@ -253,6 +256,10 @@ void PhoneNumberManager::check_code(uint64 query_id, string code) {
case Type::VerifyPhone:
return c(telegram_api::account_verifyPhone(send_code_helper_.phone_number().str(),
send_code_helper_.phone_code_hash().str(), code));
default:
UNREACHABLE();
return c(telegram_api::account_changePhone(send_code_helper_.phone_number().str(),
send_code_helper_.phone_code_hash().str(), code));
}
};
@ -312,6 +319,9 @@ void PhoneNumberManager::on_check_code_result(NetQueryPtr &result) {
return c(fetch_result<telegram_api::account_verifyPhone>(result->ok()));
case Type::ConfirmPhone:
return c(fetch_result<telegram_api::account_confirmPhone>(result->ok()));
default:
UNREACHABLE();
return c(fetch_result<telegram_api::account_changePhone>(result->ok()));
}
};
@ -335,6 +345,9 @@ void PhoneNumberManager::on_send_code_result(NetQueryPtr &result) {
return fetch_result<telegram_api::account_sendVerifyPhoneCode>(result->ok());
case Type::ConfirmPhone:
return fetch_result<telegram_api::account_sendConfirmPhoneCode>(result->ok());
default:
UNREACHABLE();
return fetch_result<telegram_api::account_sendChangePhoneCode>(result->ok());
}
}();
if (r_sent_code.is_error()) {

View File

@ -31,6 +31,7 @@
#include "td/telegram/Td.h"
#include "td/telegram/TopDialogManager.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/Version.h"
#include "td/utils/buffer.h"
#include "td/utils/format.h"

View File

@ -12,7 +12,6 @@
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/net/TempAuthKeyWatchdog.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/Version.h"
#include "td/actor/MultiPromise.h"
#include "td/actor/PromiseFuture.h"

View File

@ -371,7 +371,7 @@ bool InlineQueriesManager::register_inline_message_content(
message_content = make_unique<MessageVenue>(
Venue(inline_message_venue->geo_, std::move(inline_message_venue->title_),
std::move(inline_message_venue->address_), std::move(inline_message_venue->provider_),
std::move(inline_message_venue->venue_id_)));
std::move(inline_message_venue->venue_id_), std::move(inline_message_venue->venue_type_)));
reply_markup = std::move(inline_message_venue->reply_markup_);
break;
}
@ -1074,7 +1074,8 @@ tl_object_ptr<td_api::location> copy(const td_api::location &obj) {
template <>
tl_object_ptr<td_api::venue> copy(const td_api::venue &obj) {
return make_tl_object<td_api::venue>(copy(obj.location_), obj.title_, obj.address_, obj.provider_, obj.id_);
return make_tl_object<td_api::venue>(copy(obj.location_), obj.title_, obj.address_, obj.provider_, obj.id_,
obj.type_);
}
template <>
@ -1492,16 +1493,17 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
auto inline_message_venue =
static_cast<const telegram_api::botInlineMessageMediaVenue *>(result->send_message_.get());
Venue v(inline_message_venue->geo_, inline_message_venue->title_, inline_message_venue->address_,
inline_message_venue->provider_, inline_message_venue->venue_id_);
inline_message_venue->provider_, inline_message_venue->venue_id_,
inline_message_venue->venue_type_);
venue->venue_ = v.get_venue_object();
} else if (result->send_message_->get_id() == telegram_api::botInlineMessageMediaGeo::ID) {
auto inline_message_geo =
static_cast<const telegram_api::botInlineMessageMediaGeo *>(result->send_message_.get());
Venue v(inline_message_geo->geo_, std::move(result->title_), std::move(result->description_), string(),
string());
string(), string());
venue->venue_ = v.get_venue_object();
} else {
Venue v(nullptr, std::move(result->title_), std::move(result->description_), string(), string());
Venue v(nullptr, std::move(result->title_), std::move(result->description_), string(), string(), string());
venue->venue_ = v.get_venue_object();
}
venue->thumbnail_ = register_thumbnail(std::move(result->thumb_));

View File

@ -108,20 +108,22 @@ StringBuilder &operator<<(StringBuilder &string_builder, const Location &locatio
}
Venue::Venue(const tl_object_ptr<telegram_api::GeoPoint> &geo_point_ptr, string title, string address, string provider,
string id)
string id, string type)
: location_(geo_point_ptr)
, title_(std::move(title))
, address_(std::move(address))
, provider_(std::move(provider))
, id_(std::move(id)) {
, id_(std::move(id))
, type_(std::move(type)) {
}
Venue::Venue(Location location, string title, string address, string provider, string id)
Venue::Venue(Location location, string title, string address, string provider, string id, string type)
: location_(location)
, title_(std::move(title))
, address_(std::move(address))
, provider_(std::move(provider))
, id_(std::move(id)) {
, id_(std::move(id))
, type_(std::move(type)) {
}
Venue::Venue(const tl_object_ptr<td_api::venue> &venue)
@ -129,7 +131,8 @@ Venue::Venue(const tl_object_ptr<td_api::venue> &venue)
, title_(venue->title_)
, address_(venue->address_)
, provider_(venue->provider_)
, id_(venue->id_) {
, id_(venue->id_)
, type_(venue->type_) {
}
bool Venue::empty() const {
@ -137,12 +140,12 @@ bool Venue::empty() const {
}
tl_object_ptr<td_api::venue> Venue::get_venue_object() const {
return make_tl_object<td_api::venue>(location_.get_location_object(), title_, address_, provider_, id_);
return make_tl_object<td_api::venue>(location_.get_location_object(), title_, address_, provider_, id_, type_);
}
tl_object_ptr<telegram_api::inputMediaVenue> Venue::get_input_media_venue() const {
return make_tl_object<telegram_api::inputMediaVenue>(location_.get_input_geo_point(), title_, address_, provider_,
id_, "");
id_, type_);
}
SecretInputMedia Venue::get_secret_input_media_venue() const {
@ -154,12 +157,12 @@ SecretInputMedia Venue::get_secret_input_media_venue() const {
tl_object_ptr<telegram_api::inputBotInlineMessageMediaVenue> Venue::get_input_bot_inline_message_media_venue(
int32 flags, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const {
return make_tl_object<telegram_api::inputBotInlineMessageMediaVenue>(
flags, location_.get_input_geo_point(), title_, address_, provider_, id_, std::move(reply_markup));
flags, location_.get_input_geo_point(), title_, address_, provider_, id_, type_, std::move(reply_markup));
}
bool operator==(const Venue &lhs, const Venue &rhs) {
return lhs.location_ == rhs.location_ && lhs.title_ == rhs.title_ && lhs.address_ == rhs.address_ &&
lhs.provider_ == rhs.provider_ && lhs.id_ == rhs.id_;
lhs.provider_ == rhs.provider_ && lhs.id_ == rhs.id_ && lhs.type_ == rhs.type_;
}
bool operator!=(const Venue &lhs, const Venue &rhs) {
@ -169,7 +172,7 @@ bool operator!=(const Venue &lhs, const Venue &rhs) {
StringBuilder &operator<<(StringBuilder &string_builder, const Venue &venue) {
return string_builder << "Venue[location = " << venue.location_ << ", title = " << venue.title_
<< ", address = " << venue.address_ << ", provider = " << venue.provider_
<< ", id = " << venue.id_ << "]";
<< ", id = " << venue.id_ << ", type = " << venue.type_ << "]";
}
} // namespace td

View File

@ -15,6 +15,7 @@
#include "td/telegram/telegram_api.h"
#include "td/telegram/SecretInputMedia.h"
#include "td/telegram/Version.h"
namespace td {
@ -89,6 +90,7 @@ class Venue {
string address_;
string provider_;
string id_;
string type_;
friend bool operator==(const Venue &lhs, const Venue &rhs);
friend bool operator!=(const Venue &lhs, const Venue &rhs);
@ -99,9 +101,9 @@ class Venue {
Venue() = default;
Venue(const tl_object_ptr<telegram_api::GeoPoint> &geo_point_ptr, string title, string address, string provider,
string id);
string id, string type);
Venue(Location location, string title, string address, string provider, string id);
Venue(Location location, string title, string address, string provider, string id, string type);
explicit Venue(const tl_object_ptr<td_api::venue> &venue);
@ -125,6 +127,7 @@ class Venue {
store(address_, storer);
store(provider_, storer);
store(id_, storer);
store(type_, storer);
}
template <class ParserT>
@ -135,6 +138,9 @@ class Venue {
parse(address_, parser);
parse(provider_, parser);
parse(id_, parser);
if (parser.version() >= static_cast<int32>(Version::AddVenueType)) {
parse(type_, parser);
}
}
};

View File

@ -49,6 +49,7 @@
#include "td/telegram/Td.h"
#include "td/telegram/TopDialogManager.h"
#include "td/telegram/UpdatesManager.h"
#include "td/telegram/Version.h"
#include "td/telegram/VideoNotesManager.h"
#include "td/telegram/VideoNotesManager.hpp"
#include "td/telegram/VideosManager.h"
@ -14684,6 +14685,9 @@ Result<Venue> MessagesManager::process_input_message_venue(
if (!clean_input_string(venue->id_)) {
return Status::Error(400, "Venue identifier must be encoded in UTF-8");
}
if (!clean_input_string(venue->type_)) {
return Status::Error(400, "Venue type must be encoded in UTF-8");
}
Venue result(venue);
if (result.empty()) {
@ -21209,10 +21213,10 @@ unique_ptr<MessageContent> MessagesManager::get_secret_message_content(
message_venue->venue_id_.clear();
}
auto m =
make_unique<MessageVenue>(Venue(Location(message_venue->lat_, message_venue->long_),
std::move(message_venue->title_), std::move(message_venue->address_),
std::move(message_venue->provider_), std::move(message_venue->venue_id_)));
auto m = make_unique<MessageVenue>(Venue(Location(message_venue->lat_, message_venue->long_),
std::move(message_venue->title_), std::move(message_venue->address_),
std::move(message_venue->provider_), std::move(message_venue->venue_id_),
string()));
if (m->venue.empty()) {
is_media_empty = true;
break;
@ -21373,9 +21377,10 @@ unique_ptr<MessageContent> MessagesManager::get_message_content(FormattedText me
case telegram_api::messageMediaVenue::ID: {
auto message_venue = move_tl_object_as<telegram_api::messageMediaVenue>(media);
auto m = make_unique<MessageVenue>(Venue(message_venue->geo_, std::move(message_venue->title_),
std::move(message_venue->address_), std::move(message_venue->provider_),
std::move(message_venue->venue_id_)));
auto m =
make_unique<MessageVenue>(Venue(message_venue->geo_, std::move(message_venue->title_),
std::move(message_venue->address_), std::move(message_venue->provider_),
std::move(message_venue->venue_id_), std::move(message_venue->venue_type_)));
if (m->venue.empty()) {
break;
}

View File

@ -237,22 +237,26 @@ void PasswordManager::send_email_address_verification_code(
last_verified_email_address_ = email;
auto query =
G()->net_query_creator().create(create_storer(telegram_api::account_sendVerifyEmailCode(std::move(email))));
send_with_promise(
std::move(query), PromiseCreator::lambda([actor_id = actor_id(this),
promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::account_sendVerifyEmailCode>(std::move(r_query));
if (r_result.is_error()) {
return promise.set_error(r_result.move_as_error());
}
auto result = r_result.move_as_ok();
return promise.set_value(make_tl_object<td_api::emailAddressAuthenticationCodeInfo>(result->email_pattern_));
}));
send_with_promise(std::move(query), PromiseCreator::lambda([actor_id = actor_id(this), promise = std::move(promise)](
Result<NetQueryPtr> r_query) mutable {
auto r_result = fetch_result<telegram_api::account_sendVerifyEmailCode>(std::move(r_query));
if (r_result.is_error()) {
return promise.set_error(r_result.move_as_error());
}
auto result = r_result.move_as_ok();
if (result->length_ < 0 || result->length_ >= 100) {
LOG(ERROR) << "Receive wrong code length " << result->length_;
result->length_ = 0;
}
return promise.set_value(make_tl_object<td_api::emailAddressAuthenticationCodeInfo>(
result->email_pattern_, result->length_));
}));
}
void PasswordManager::resend_email_address_verification_code(
Promise<td_api::object_ptr<td_api::emailAddressAuthenticationCodeInfo>> promise) {
if (last_verified_email_address_.empty()) {
return promise.set_error(Status::Error(400, "No verification phone was sent"));
return promise.set_error(Status::Error(400, "No email address verification was sent"));
}
send_email_address_verification_code(last_verified_email_address_, std::move(promise));
}
@ -260,7 +264,7 @@ void PasswordManager::resend_email_address_verification_code(
void PasswordManager::check_email_address_verification_code(string code,
Promise<td_api::object_ptr<td_api::ok>> promise) {
if (last_verified_email_address_.empty()) {
return promise.set_error(Status::Error(400, "No verification phone was sent"));
return promise.set_error(Status::Error(400, "No email address verification was sent"));
}
auto query = G()->net_query_creator().create(
create_storer(telegram_api::account_verifyEmail(last_verified_email_address_, std::move(code))));
@ -275,7 +279,7 @@ void PasswordManager::check_email_address_verification_code(string code,
}
void PasswordManager::request_password_recovery(
Promise<tl_object_ptr<td_api::emailAddressAuthenticationCodeInfo>> promise) {
Promise<td_api::object_ptr<td_api::emailAddressAuthenticationCodeInfo>> promise) {
send_with_promise(
G()->net_query_creator().create(create_storer(telegram_api::auth_requestPasswordRecovery())),
PromiseCreator::lambda([promise = std::move(promise)](Result<NetQueryPtr> r_query) mutable {
@ -284,7 +288,7 @@ void PasswordManager::request_password_recovery(
return promise.set_error(r_result.move_as_error());
}
auto result = r_result.move_as_ok();
return promise.set_value(make_tl_object<td_api::emailAddressAuthenticationCodeInfo>(result->email_pattern_));
return promise.set_value(make_tl_object<td_api::emailAddressAuthenticationCodeInfo>(result->email_pattern_, 0));
}));
}

View File

@ -63,7 +63,7 @@ class PasswordManager : public NetQueryCallback {
Promise<td_api::object_ptr<td_api::emailAddressAuthenticationCodeInfo>> promise);
void check_email_address_verification_code(string code, Promise<td_api::object_ptr<td_api::ok>> promise);
void request_password_recovery(Promise<tl_object_ptr<td_api::emailAddressAuthenticationCodeInfo>> promise);
void request_password_recovery(Promise<td_api::object_ptr<td_api::emailAddressAuthenticationCodeInfo>> promise);
void recover_password(string code, Promise<State> promise);
void get_secure_secret(string password, optional<int64> hash, Promise<secure_storage::Secret> promise);

View File

@ -11,6 +11,7 @@
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/MessagesDb.h"
#include "td/telegram/TdParameters.h"
#include "td/telegram/Version.h"
#include "td/actor/actor.h"
#include "td/actor/MultiPromise.h"

View File

@ -23,6 +23,7 @@ enum class Version : int32 {
FixPageBlockAudioEmptyFile,
AddMessageInvoiceProviderData,
AddCaptionEntities,
AddVenueType,
Next
};

View File

@ -32,6 +32,7 @@
#include "td/telegram/StickersManager.h"
#include "td/telegram/StickersManager.hpp"
#include "td/telegram/Td.h"
#include "td/telegram/Version.h"
#include "td/telegram/VideoNotesManager.h"
#include "td/telegram/VideoNotesManager.hpp"
#include "td/telegram/VideosManager.h"

View File

@ -2577,15 +2577,17 @@ class CliClient final : public Actor {
string address;
string provider;
string venue_id;
string venue_type;
std::tie(chat_id, args) = split(args);
std::tie(latitude, args) = split(args);
std::tie(longitude, args) = split(args);
std::tie(title, args) = split(args);
std::tie(address, args) = split(args);
std::tie(provider, venue_id) = split(args);
std::tie(provider, args) = split(args);
std::tie(venue_id, venue_type) = split(args);
send_message(chat_id, make_tl_object<td_api::inputMessageVenue>(make_tl_object<td_api::venue>(
as_location(latitude, longitude), title, address, provider, venue_id)));
as_location(latitude, longitude), title, address, provider, venue_id, venue_type)));
} else if (op == "test") {
send_request(make_tl_object<td_api::testNetwork>());
} else if (op == "alarm") {

View File

@ -12,6 +12,7 @@
#include "td/telegram/Global.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/StateManager.h"
#include "td/telegram/Version.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"