Update TDLib to 1.8.12.

This commit is contained in:
levlam 2023-02-13 17:25:33 +03:00
parent 09c9db306a
commit 0cf13d3bf4
5 changed files with 52 additions and 42 deletions

2
td

@ -1 +1 @@
Subproject commit 3179d35694a28267a0b6273fc9b5bdce3b6b1235 Subproject commit 6c53a61162e6ea4a753869ee248b8a9e926ffd5d

View File

@ -735,9 +735,9 @@ class Client::JsonChat final : public Jsonable {
object("permissions", JsonChatPermissions(permissions)); object("permissions", JsonChatPermissions(permissions));
} }
auto everyone_is_administrator = auto everyone_is_administrator =
permissions->can_send_messages_ && permissions->can_send_audios_ && permissions->can_send_documents_ && permissions->can_send_basic_messages_ && permissions->can_send_audios_ &&
permissions->can_send_photos_ && permissions->can_send_videos_ && permissions->can_send_video_notes_ && permissions->can_send_documents_ && permissions->can_send_photos_ && permissions->can_send_videos_ &&
permissions->can_send_voice_notes_ && permissions->can_send_polls_ && permissions->can_send_video_notes_ && permissions->can_send_voice_notes_ && permissions->can_send_polls_ &&
permissions->can_send_other_messages_ && permissions->can_add_web_page_previews_ && permissions->can_send_other_messages_ && permissions->can_add_web_page_previews_ &&
permissions->can_change_info_ && permissions->can_invite_users_ && permissions->can_pin_messages_; permissions->can_change_info_ && permissions->can_invite_users_ && permissions->can_pin_messages_;
object("all_members_are_administrators", td::JsonBool(everyone_is_administrator)); object("all_members_are_administrators", td::JsonBool(everyone_is_administrator));
@ -4190,7 +4190,7 @@ void Client::send(PromisedQueryPtr query) {
if (!query->is_internal()) { if (!query->is_internal()) {
query->set_stat_actor(stat_actor_); query->set_stat_actor(stat_actor_);
if (!parameters_->local_mode_ && !is_local_method(query->method()) && if (!parameters_->local_mode_ && !is_local_method(query->method()) &&
td::Time::now() > parameters_->start_time_ + 10 * 60) { td::Time::now() > parameters_->start_time_ + 60) {
BotStatActor *stat = stat_actor_.get_actor_unsafe(); BotStatActor *stat = stat_actor_.get_actor_unsafe();
auto update_per_minute = static_cast<int64>(stat->get_minute_update_count(td::Time::now()) * 60); auto update_per_minute = static_cast<int64>(stat->get_minute_update_count(td::Time::now()) * 60);
if (stat->get_active_request_count() > 500 + update_per_minute) { if (stat->get_active_request_count() > 500 + update_per_minute) {
@ -5999,7 +5999,7 @@ td::Result<td_api::object_ptr<td_api::InputMessageContent>> Client::get_input_me
td_api::object_ptr<td_api::messageSendOptions> Client::get_message_send_options(bool disable_notification, td_api::object_ptr<td_api::messageSendOptions> Client::get_message_send_options(bool disable_notification,
bool protect_content) { bool protect_content) {
return make_object<td_api::messageSendOptions>(disable_notification, false, protect_content, false, nullptr); return make_object<td_api::messageSendOptions>(disable_notification, false, protect_content, false, nullptr, 0);
} }
td::Result<td::vector<td_api::object_ptr<td_api::InputInlineQueryResult>>> Client::get_inline_query_results( td::Result<td::vector<td_api::object_ptr<td_api::InputInlineQueryResult>>> Client::get_inline_query_results(
@ -6615,23 +6615,29 @@ td::Result<td_api::object_ptr<td_api::maskPosition>> Client::get_mask_position(c
return r_mask_position.move_as_ok(); return r_mask_position.move_as_ok();
} }
td::Result<td::vector<td_api::object_ptr<td_api::inputSticker>>> Client::get_input_stickers(const Query *query) const { td::Result<td::vector<td_api::object_ptr<td_api::inputSticker>>> Client::get_input_stickers(
const Query *query, object_ptr<td_api::StickerFormat> *sticker_format) const {
auto emojis = query->arg("emojis"); auto emojis = query->arg("emojis");
auto sticker = get_input_file(query, "png_sticker"); auto sticker = get_input_file(query, "png_sticker");
object_ptr<td_api::StickerFormat> sticker_format;
object_ptr<td_api::maskPosition> mask_position; object_ptr<td_api::maskPosition> mask_position;
if (sticker != nullptr) { if (sticker != nullptr) {
sticker_format = make_object<td_api::stickerFormatWebp>(); if (sticker_format != nullptr) {
*sticker_format = make_object<td_api::stickerFormatWebp>();
}
TRY_RESULT_ASSIGN(mask_position, get_mask_position(query, "mask_position")); TRY_RESULT_ASSIGN(mask_position, get_mask_position(query, "mask_position"));
} else { } else {
sticker = get_input_file(query, "tgs_sticker", true); sticker = get_input_file(query, "tgs_sticker", true);
if (sticker != nullptr) { if (sticker != nullptr) {
sticker_format = make_object<td_api::stickerFormatTgs>(); if (sticker_format != nullptr) {
*sticker_format = make_object<td_api::stickerFormatTgs>();
}
} else { } else {
sticker = get_input_file(query, "webm_sticker", true); sticker = get_input_file(query, "webm_sticker", true);
if (sticker != nullptr) { if (sticker != nullptr) {
sticker_format = make_object<td_api::stickerFormatWebm>(); if (sticker_format != nullptr) {
*sticker_format = make_object<td_api::stickerFormatWebm>();
}
} else { } else {
if (!query->arg("tgs_sticker").empty()) { if (!query->arg("tgs_sticker").empty()) {
return Status::Error(400, "Bad Request: animated sticker must be uploaded as an InputFile"); return Status::Error(400, "Bad Request: animated sticker must be uploaded as an InputFile");
@ -6645,8 +6651,8 @@ td::Result<td::vector<td_api::object_ptr<td_api::inputSticker>>> Client::get_inp
} }
td::vector<object_ptr<td_api::inputSticker>> stickers; td::vector<object_ptr<td_api::inputSticker>> stickers;
stickers.push_back(make_object<td_api::inputSticker>(std::move(sticker), emojis.str(), std::move(sticker_format), stickers.push_back(make_object<td_api::inputSticker>(std::move(sticker), emojis.str(), std::move(mask_position),
std::move(mask_position))); td::vector<td::string>()));
return std::move(stickers); return std::move(stickers);
} }
@ -8207,18 +8213,21 @@ td::Status Client::process_answer_inline_query_query(PromisedQueryPtr &query) {
int32 cache_time = get_integer_arg(query.get(), "cache_time", 300, 0, 24 * 60 * 60); int32 cache_time = get_integer_arg(query.get(), "cache_time", 300, 0, 24 * 60 * 60);
auto next_offset = query->arg("next_offset"); auto next_offset = query->arg("next_offset");
auto switch_pm_text = query->arg("switch_pm_text"); auto switch_pm_text = query->arg("switch_pm_text");
auto switch_pm_parameter = query->arg("switch_pm_parameter"); object_ptr<td_api::inlineQueryResultsButton> button;
if (!switch_pm_text.empty()) {
button = make_object<td_api::inlineQueryResultsButton>(
switch_pm_text.str(),
make_object<td_api::inlineQueryResultsButtonTypeStartBot>(query->arg("switch_pm_parameter").str()));
}
TRY_RESULT(results, get_inline_query_results(query.get())); TRY_RESULT(results, get_inline_query_results(query.get()));
resolve_inline_query_results_bot_usernames( resolve_inline_query_results_bot_usernames(
std::move(results), std::move(query), std::move(results), std::move(query),
[this, inline_query_id, is_personal, cache_time, next_offset = next_offset.str(), [this, inline_query_id, is_personal, cache_time, next_offset = next_offset.str(), button = std::move(button)](
switch_pm_text = switch_pm_text.str(), switch_pm_parameter = switch_pm_parameter.str()]( td::vector<object_ptr<td_api::InputInlineQueryResult>> results, PromisedQueryPtr query) mutable {
td::vector<object_ptr<td_api::InputInlineQueryResult>> results, PromisedQueryPtr query) { send_request(make_object<td_api::answerInlineQuery>(inline_query_id, is_personal, std::move(button),
send_request( std::move(results), cache_time, next_offset),
make_object<td_api::answerInlineQuery>(inline_query_id, is_personal, std::move(results), cache_time,
next_offset, switch_pm_text, switch_pm_parameter),
td::make_unique<TdOnOkQueryCallback>(std::move(query))); td::make_unique<TdOnOkQueryCallback>(std::move(query)));
}); });
return Status::OK(); return Status::OK();
@ -8995,11 +9004,10 @@ td::Status Client::process_upload_sticker_file_query(PromisedQueryPtr &query) {
TRY_RESULT(user_id, get_user_id(query.get())); TRY_RESULT(user_id, get_user_id(query.get()));
auto png_sticker = get_input_file(query.get(), "png_sticker"); auto png_sticker = get_input_file(query.get(), "png_sticker");
check_user( check_user(user_id, std::move(query),
user_id, std::move(query), [this, user_id, png_sticker = std::move(png_sticker)](PromisedQueryPtr query) mutable { [this, user_id, png_sticker = std::move(png_sticker)](PromisedQueryPtr query) mutable {
send_request(make_object<td_api::uploadStickerFile>( send_request(make_object<td_api::uploadStickerFile>(user_id, make_object<td_api::stickerFormatWebp>(),
user_id, make_object<td_api::inputSticker>(std::move(png_sticker), "", std::move(png_sticker)),
make_object<td_api::stickerFormatWebp>(), nullptr)),
td::make_unique<TdOnReturnFileCallback>(this, std::move(query))); td::make_unique<TdOnReturnFileCallback>(this, std::move(query)));
}); });
return Status::OK(); return Status::OK();
@ -9009,7 +9017,8 @@ td::Status Client::process_create_new_sticker_set_query(PromisedQueryPtr &query)
TRY_RESULT(user_id, get_user_id(query.get())); TRY_RESULT(user_id, get_user_id(query.get()));
auto name = query->arg("name"); auto name = query->arg("name");
auto title = query->arg("title"); auto title = query->arg("title");
TRY_RESULT(stickers, get_input_stickers(query.get())); object_ptr<td_api::StickerFormat> sticker_format;
TRY_RESULT(stickers, get_input_stickers(query.get(), &sticker_format));
TRY_RESULT(sticker_type, get_sticker_type(query->arg("sticker_type"))); TRY_RESULT(sticker_type, get_sticker_type(query->arg("sticker_type")));
if (to_bool(query->arg("contains_masks"))) { if (to_bool(query->arg("contains_masks"))) {
@ -9017,11 +9026,11 @@ td::Status Client::process_create_new_sticker_set_query(PromisedQueryPtr &query)
} }
check_user(user_id, std::move(query), check_user(user_id, std::move(query),
[this, user_id, title, name, sticker_type = std::move(sticker_type), [this, user_id, title, name, sticker_format = std::move(sticker_format),
stickers = std::move(stickers)](PromisedQueryPtr query) mutable { sticker_type = std::move(sticker_type), stickers = std::move(stickers)](PromisedQueryPtr query) mutable {
send_request( send_request(make_object<td_api::createNewStickerSet>(
make_object<td_api::createNewStickerSet>(user_id, title.str(), name.str(), std::move(sticker_type), user_id, title.str(), name.str(), std::move(sticker_format), std::move(sticker_type),
std::move(stickers), PSTRING() << "bot" << my_id_), false, std::move(stickers), PSTRING() << "bot" << my_id_),
td::make_unique<TdOnReturnStickerSetCallback>(this, false, std::move(query))); td::make_unique<TdOnReturnStickerSetCallback>(this, false, std::move(query)));
}); });
return Status::OK(); return Status::OK();
@ -9030,13 +9039,13 @@ td::Status Client::process_create_new_sticker_set_query(PromisedQueryPtr &query)
td::Status Client::process_add_sticker_to_set_query(PromisedQueryPtr &query) { td::Status Client::process_add_sticker_to_set_query(PromisedQueryPtr &query) {
TRY_RESULT(user_id, get_user_id(query.get())); TRY_RESULT(user_id, get_user_id(query.get()));
auto name = query->arg("name"); auto name = query->arg("name");
TRY_RESULT(stickers, get_input_stickers(query.get())); TRY_RESULT(stickers, get_input_stickers(query.get(), nullptr));
CHECK(!stickers.empty()); CHECK(!stickers.empty());
check_user(user_id, std::move(query), check_user(user_id, std::move(query),
[this, user_id, name, sticker = std::move(stickers[0])](PromisedQueryPtr query) mutable { [this, user_id, name, sticker = std::move(stickers[0])](PromisedQueryPtr query) mutable {
send_request(make_object<td_api::addStickerToSet>(user_id, name.str(), std::move(sticker)), send_request(make_object<td_api::addStickerToSet>(user_id, name.str(), std::move(sticker)),
td::make_unique<TdOnReturnStickerSetCallback>(this, false, std::move(query))); td::make_unique<TdOnOkQueryCallback>(std::move(query)));
}); });
return Status::OK(); return Status::OK();
} }
@ -9048,7 +9057,7 @@ td::Status Client::process_set_sticker_set_thumb_query(PromisedQueryPtr &query)
check_user(user_id, std::move(query), check_user(user_id, std::move(query),
[this, user_id, name, thumbnail = std::move(thumbnail)](PromisedQueryPtr query) mutable { [this, user_id, name, thumbnail = std::move(thumbnail)](PromisedQueryPtr query) mutable {
send_request(make_object<td_api::setStickerSetThumbnail>(user_id, name.str(), std::move(thumbnail)), send_request(make_object<td_api::setStickerSetThumbnail>(user_id, name.str(), std::move(thumbnail)),
td::make_unique<TdOnReturnStickerSetCallback>(this, false, std::move(query))); td::make_unique<TdOnOkQueryCallback>(std::move(query)));
}); });
return Status::OK(); return Status::OK();
} }
@ -10119,7 +10128,7 @@ void Client::json_store_permissions(td::JsonObjectScope &object, const td_api::c
bool can_send_media_messages = permissions->can_send_audios_ || permissions->can_send_documents_ || bool can_send_media_messages = permissions->can_send_audios_ || permissions->can_send_documents_ ||
permissions->can_send_photos_ || permissions->can_send_videos_ || permissions->can_send_photos_ || permissions->can_send_videos_ ||
permissions->can_send_video_notes_ || permissions->can_send_voice_notes_; permissions->can_send_video_notes_ || permissions->can_send_voice_notes_;
object("can_send_messages", td::JsonBool(permissions->can_send_messages_)); object("can_send_messages", td::JsonBool(permissions->can_send_basic_messages_));
object("can_send_media_messages", td::JsonBool(can_send_media_messages)); object("can_send_media_messages", td::JsonBool(can_send_media_messages));
object("can_send_audios", td::JsonBool(permissions->can_send_audios_)); object("can_send_audios", td::JsonBool(permissions->can_send_audios_));
object("can_send_documents", td::JsonBool(permissions->can_send_documents_)); object("can_send_documents", td::JsonBool(permissions->can_send_documents_));

View File

@ -401,7 +401,8 @@ class Client final : public WebhookActor::Callback {
static object_ptr<td_api::MaskPoint> mask_index_to_point(int32 index); static object_ptr<td_api::MaskPoint> mask_index_to_point(int32 index);
td::Result<td::vector<object_ptr<td_api::inputSticker>>> get_input_stickers(const Query *query) const; td::Result<td::vector<object_ptr<td_api::inputSticker>>> get_input_stickers(
const Query *query, object_ptr<td_api::StickerFormat> *sticker_format) const;
static td::Result<td::string> get_passport_element_hash(Slice encoded_hash); static td::Result<td::string> get_passport_element_hash(Slice encoded_hash);

View File

@ -66,7 +66,7 @@ class HttpServer final : public td::TcpListener::Callback {
scheduler_id--; scheduler_id--;
} }
td::create_actor<td::HttpInboundConnection>("HttpInboundConnection", td::BufferedFd<td::SocketFd>(std::move(fd)), 0, td::create_actor<td::HttpInboundConnection>("HttpInboundConnection", td::BufferedFd<td::SocketFd>(std::move(fd)), 0,
20, 500, creator_(), scheduler_id) 50, 500, creator_(), scheduler_id)
.release(); .release();
} }

View File

@ -229,7 +229,7 @@ td::Status WebhookActor::create_connection(td::BufferedFd<td::SocketFd> fd) {
auto id = connections_.create(Connection()); auto id = connections_.create(Connection());
auto *conn = connections_.get(id); auto *conn = connections_.get(id);
conn->actor_id_ = td::create_actor<td::HttpOutboundConnection>( conn->actor_id_ = td::create_actor<td::HttpOutboundConnection>(
PSLICE() << "Connect:" << id, std::move(fd), std::move(ssl_stream), 0, 20, 60, PSLICE() << "Connect:" << id, std::move(fd), std::move(ssl_stream), 0, 50, 60,
td::ActorShared<td::HttpOutboundConnection::Callback>(actor_id(this), id), slow_scheduler_id_); td::ActorShared<td::HttpOutboundConnection::Callback>(actor_id(this), id), slow_scheduler_id_);
conn->ip_generation_ = ip_generation_; conn->ip_generation_ = ip_generation_;
conn->event_id_ = {}; conn->event_id_ = {};