Add "story_caption_length_max" option.

This commit is contained in:
levlam 2023-06-29 15:20:30 +03:00
parent cec0ab47b5
commit eb78cf1883
4 changed files with 12 additions and 2 deletions

View File

@ -7258,7 +7258,7 @@ getStory story_sender_chat_id:int53 story_id:int32 = Story;
//@description Sends a new story. Returns a temporary story with identifier 0
//@content Content of the story
//@caption Story caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters
//@caption Story caption; pass null to use an empty caption; 0-getOption("story_caption_length_max") characters
//@privacy_rules The privacy rules for the story
//@active_period Period after which the story is moved to archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, 2 * 86400, 3 * 86400, or 7 * 86400 for Telegram Premium users, and 86400 otherwise
//@is_pinned Pass true to keep the story accessible after expiration

View File

@ -1563,6 +1563,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
bool archive_all_stories = false;
int32 story_viewers_expire_period = 86400;
int64 stories_changelog_user_id = ContactsManager::get_service_notifications_user_id().get();
int32 story_caption_length_limit = 1024;
if (config->get_id() == telegram_api::jsonObject::ID) {
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
Slice key = key_value->key_;
@ -1971,6 +1972,10 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
stories_changelog_user_id = get_json_value_long(std::move(key_value->value_), key);
continue;
}
if (key == "story_caption_length_limit") {
story_caption_length_limit = get_json_value_int(std::move(key_value->value_), key);
continue;
}
new_values.push_back(std::move(key_value));
}
@ -2101,6 +2106,8 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
options.get_option_integer("chatlist_invites_limit_default", 2));
}
options.set_option_integer("story_caption_length_max", clamp(story_caption_length_limit, 1024, 1000000));
if (!is_premium_available) {
premium_bot_username.clear(); // just in case
premium_invoice_slug.clear(); // just in case

View File

@ -106,7 +106,7 @@ class ConfigManager final : public NetQueryCallback {
private:
struct AppConfig {
static constexpr int32 CURRENT_VERSION = 6;
static constexpr int32 CURRENT_VERSION = 7;
int32 version_ = 0;
int32 hash_ = 0;
telegram_api::object_ptr<telegram_api::JSONValue> config_;

View File

@ -77,6 +77,9 @@ OptionManager::OptionManager(Td *td)
if (!have_option("message_caption_length_max")) {
set_option_integer("message_caption_length_max", 1024);
}
if (!have_option("story_caption_length_max")) {
set_option_integer("story_caption_length_max", 1024);
}
if (!have_option("bio_length_max")) {
set_option_integer("bio_length_max", 70);
}