diff --git a/benchmark/bench_misc.cpp b/benchmark/bench_misc.cpp index 2c5113dab..5260d24fc 100644 --- a/benchmark/bench_misc.cpp +++ b/benchmark/bench_misc.cpp @@ -47,7 +47,7 @@ class F { }; BENCH(Call, "TL Call") { - tl_object_ptr x = make_tl_object(); + tl_object_ptr x = make_tl_object(0); uint32 res = 0; F f(res); for (int i = 0; i < n; i++) { diff --git a/td/generate/tl_writer_td.cpp b/td/generate/tl_writer_td.cpp index c3d9ac95d..93f16749e 100644 --- a/td/generate/tl_writer_td.cpp +++ b/td/generate/tl_writer_td.cpp @@ -49,6 +49,10 @@ bool TD_TL_writer::is_combinator_supported(const tl::tl_combinator *constructor) return true; } +bool TD_TL_writer::is_default_constructor_generated(const tl::tl_combinator *t) const { + return tl_name == "td_api" || t->var_count > 0 || t->args.empty(); +} + int TD_TL_writer::get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const { return storer_name == "TlStorerToString"; } diff --git a/td/generate/tl_writer_td.h b/td/generate/tl_writer_td.h index e630a3b05..c8d59517a 100644 --- a/td/generate/tl_writer_td.h +++ b/td/generate/tl_writer_td.h @@ -35,6 +35,7 @@ class TD_TL_writer : public tl::TL_writer { bool is_built_in_complex_type(const std::string &name) const override; bool is_type_bare(const tl::tl_type *t) const override; bool is_combinator_supported(const tl::tl_combinator *constructor) const override; + bool is_default_constructor_generated(const tl::tl_combinator *t) const override; int get_storer_type(const tl::tl_combinator *t, const std::string &storer_name) const override; Mode get_parser_mode(int type) const override; diff --git a/td/mtproto/crypto.cpp b/td/mtproto/crypto.cpp index 2263477e5..fc21d1900 100644 --- a/td/mtproto/crypto.cpp +++ b/td/mtproto/crypto.cpp @@ -77,12 +77,10 @@ Result RSA::from_pem(Slice pem) { } int64 RSA::get_fingerprint() const { - mtproto_api::rsa_public_key public_key; // string objects are necessary, because mtproto_api::rsa_public_key contains Slice inside string n_str = n_.to_binary(); string e_str = e_.to_binary(); - public_key.n_ = n_str; - public_key.e_ = e_str; + mtproto_api::rsa_public_key public_key(n_str, e_str); size_t size = tl_calc_length(public_key); std::vector tmp(size); size = tl_store_unsafe(public_key, tmp.data()); diff --git a/td/telegram/PasswordManager.cpp b/td/telegram/PasswordManager.cpp index 94c86f238..872cc616f 100644 --- a/td/telegram/PasswordManager.cpp +++ b/td/telegram/PasswordManager.cpp @@ -744,7 +744,7 @@ void PasswordManager::get_ton_wallet_password_salt(Promisenet_query_creator().create(create_storer(telegram_api::wallet_getKeySecretSalt())), + send_with_promise(G()->net_query_creator().create(create_storer(telegram_api::wallet_getKeySecretSalt(false))), PromiseCreator::lambda([actor_id = actor_id(this)](Result r_query) mutable { auto r_result = fetch_result(std::move(r_query)); send_closure(actor_id, &PasswordManager::on_get_ton_wallet_password_salt, std::move(r_result)); diff --git a/td/telegram/SecretChatActor.cpp b/td/telegram/SecretChatActor.cpp index f116bc881..7428cb47a 100644 --- a/td/telegram/SecretChatActor.cpp +++ b/td/telegram/SecretChatActor.cpp @@ -470,7 +470,7 @@ void SecretChatActor::notify_screenshot_taken(Promise<> promise) { promise.set_error(Status::Error(400, "Can't access the chat")); return; } - send_action(make_tl_object(), SendFlag::Push, + send_action(make_tl_object(vector()), SendFlag::Push, std::move(promise)); } @@ -565,10 +565,8 @@ Status SecretChatActor::run_auth() { return Status::OK(); } // messages.requestEncryption#f64daf43 user_id:InputUser random_id:int g_a:bytes = EncryptedChat; - telegram_api::messages_requestEncryption tl_query; - tl_query.user_id_ = get_input_user(); - tl_query.random_id_ = auth_state_.random_id; - tl_query.g_a_ = BufferSlice(auth_state_.handshake.get_g_b()); + telegram_api::messages_requestEncryption tl_query(get_input_user(), auth_state_.random_id, + BufferSlice(auth_state_.handshake.get_g_b())); auto query = context_->net_query_creator().create( UniqueId::next(UniqueId::Type::Default, static_cast(QueryType::EncryptedChat)), create_storer(tl_query)); @@ -584,12 +582,9 @@ Status SecretChatActor::run_auth() { auto id_and_key = auth_state_.handshake.gen_key(); pfs_state_.auth_key = mtproto::AuthKey(id_and_key.first, std::move(id_and_key.second)); calc_key_hash(); - // messages.acceptEncryption#3dbc0415 peer:InputEncryptedChat g_b:bytes key_fingerprint:long = - // EncryptedChat; - telegram_api::messages_acceptEncryption tl_query; - tl_query.peer_ = get_input_chat(); - tl_query.g_b_ = BufferSlice(auth_state_.handshake.get_g_b()); - tl_query.key_fingerprint_ = pfs_state_.auth_key.id(); + // messages.acceptEncryption#3dbc0415 peer:InputEncryptedChat g_b:bytes key_fingerprint:long = EncryptedChat; + telegram_api::messages_acceptEncryption tl_query(get_input_chat(), BufferSlice(auth_state_.handshake.get_g_b()), + pfs_state_.auth_key.id()); auto query = context_->net_query_creator().create( UniqueId::next(UniqueId::Type::Default, static_cast(QueryType::EncryptedChat)), create_storer(tl_query)); diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index e2d27dd6c..fbee4de4a 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1695,7 +1695,7 @@ SecretInputMedia StickersManager::get_secret_input_media(FileId sticker_file_id, return SecretInputMedia{nullptr, make_tl_object( remote_location.get_id(), remote_location.get_access_hash(), 0 /*date*/, get_sticker_mime_type(sticker), narrow_cast(file_view.size()), - make_tl_object(), + make_tl_object("t"), remote_location.get_dc_id().get_raw_id(), std::move(attributes))}; } } diff --git a/tdtl/td/tl/tl_generate.cpp b/tdtl/td/tl/tl_generate.cpp index aa107f1f2..e3072ceaa 100644 --- a/tdtl/td/tl/tl_generate.cpp +++ b/tdtl/td/tl/tl_generate.cpp @@ -252,7 +252,9 @@ static void write_function(tl_outputer &out, const tl_combinator *t, const std:: std::vector vars(t->var_count); out.append(w.gen_function_vars(t, vars)); - write_class_constructor(out, t, class_name, true, w); + if (w.is_default_constructor_generated(t)) { + write_class_constructor(out, t, class_name, true, w); + } if (required_args) { write_class_constructor(out, t, class_name, false, w); } @@ -303,7 +305,9 @@ static void write_constructor(tl_outputer &out, const tl_combinator *t, const st int required_args = gen_field_definitions(out, t, class_name, w); out.append(w.gen_flags_definitions(t)); - write_class_constructor(out, t, class_name, true, w); + if (w.is_default_constructor_generated(t)) { + write_class_constructor(out, t, class_name, true, w); + } if (required_args) { write_class_constructor(out, t, class_name, false, w); } diff --git a/tdtl/td/tl/tl_writer.cpp b/tdtl/td/tl/tl_writer.cpp index 5e80315aa..0a9131ecb 100644 --- a/tdtl/td/tl/tl_writer.cpp +++ b/tdtl/td/tl/tl_writer.cpp @@ -135,6 +135,10 @@ bool TL_writer::is_documentation_generated() const { return false; } +bool TL_writer::is_default_constructor_generated(const tl_combinator *t) const { + return true; +} + std::string TL_writer::gen_main_class_name(const tl_type *t) const { if (t->simple_constructors == 1) { for (std::size_t i = 0; i < t->constructors_num; i++) { diff --git a/tdtl/td/tl/tl_writer.h b/tdtl/td/tl/tl_writer.h index 8c243dfa0..b6abbc2f2 100644 --- a/tdtl/td/tl/tl_writer.h +++ b/tdtl/td/tl/tl_writer.h @@ -56,6 +56,7 @@ class TL_writer { virtual bool is_type_bare(const tl_type *t) const = 0; virtual bool is_combinator_supported(const tl_combinator *constructor) const; virtual bool is_documentation_generated() const; + virtual bool is_default_constructor_generated(const tl_combinator *t) const; virtual int get_parser_type(const tl_combinator *t, const std::string &parser_name) const; virtual int get_storer_type(const tl_combinator *t, const std::string &storer_name) const;