add --max-batch-operations parameter (default 10000)

This commit is contained in:
Giuseppe Marino 2020-11-11 19:45:15 +01:00
parent 8f05c65bdc
commit 25d1ee172b
No known key found for this signature in database
GPG Key ID: 2BC70C5463357449
4 changed files with 11 additions and 0 deletions

View File

@ -42,6 +42,9 @@ fi
if [ -n "$TELEGRAM_RELATIVE" ]; then if [ -n "$TELEGRAM_RELATIVE" ]; then
CUSTOM_ARGS="${CUSTOM_ARGS} --relative" CUSTOM_ARGS="${CUSTOM_ARGS} --relative"
fi fi
if [ -n "$TELEGRAM_MAX_BATCH" ]; then
CUSTOM_ARGS="${CUSTOM_ARGS} ---max-batch-operations=$TELEGRAM_MAX_BATCH"
fi
COMMAND="telegram-bot-api ${DEFAULT_ARGS}${CUSTOM_ARGS}" COMMAND="telegram-bot-api ${DEFAULT_ARGS}${CUSTOM_ARGS}"

View File

@ -7470,6 +7470,10 @@ td::Status Client::process_delete_messages_query(PromisedQueryPtr &query) {
return Status::Error(400, "Initial message identifier is not lower than last message identifier"); return Status::Error(400, "Initial message identifier is not lower than last message identifier");
} }
if (static_cast<td::uint32>(end-start) > parameters_->max_batch_operations) {
return Status::Error(400, PSLICE() << "Too many operations: maximum number of batch operation is " << parameters_->max_batch_operations);
}
check_chat(chat_id, AccessRights::Write, std::move(query), [this, start, end](int64 chat_id, PromisedQueryPtr query) { check_chat(chat_id, AccessRights::Write, std::move(query), [this, start, end](int64 chat_id, PromisedQueryPtr query) {
if (get_chat_type(chat_id) != ChatType::Supergroup) { if (get_chat_type(chat_id) != ChatType::Supergroup) {
return fail_query(400, "Bad Request: method is available only for supergroups", std::move(query)); return fail_query(400, "Bad Request: method is available only for supergroups", std::move(query));

View File

@ -64,6 +64,7 @@ struct ClientParameters {
td::int32 default_max_webhook_connections_ = 0; td::int32 default_max_webhook_connections_ = 0;
td::IPAddress webhook_proxy_ip_address_; td::IPAddress webhook_proxy_ip_address_;
td::uint32 max_batch_operations = 10000;
double start_timestamp_ = 0; double start_timestamp_ = 0;
td::ActorId<td::GetHostByNameActor> get_host_by_name_actor_id_; td::ActorId<td::GetHostByNameActor> get_host_by_name_actor_id_;

View File

@ -238,6 +238,9 @@ int main(int argc, char *argv[]) {
options.add_checked_option('c', "max-connections", "maximum number of open file descriptors", options.add_checked_option('c', "max-connections", "maximum number of open file descriptors",
td::OptionParser::parse_integer(max_connections)); td::OptionParser::parse_integer(max_connections));
options.add_checked_option('\0', "max-batch-operations", PSLICE() << "maximum number of batch operations (default: " << parameters->max_batch_operations << ")",
td::OptionParser::parse_integer(parameters->max_batch_operations));
options.add_checked_option( options.add_checked_option(
'\0', "proxy", PSLICE() << "HTTP proxy server for outgoing webhook requests in the format http://host:port", '\0', "proxy", PSLICE() << "HTTP proxy server for outgoing webhook requests in the format http://host:port",
[&](td::Slice address) { [&](td::Slice address) {