From 2d05be04dd39a63c83070f6c401438714be41c01 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 17 Sep 2018 07:00:19 +0300 Subject: [PATCH] Follow new server-side limits on first/last name and title length. GitOrigin-RevId: 89fe4eb85c42859974142fd163ea9fd062fde459 --- td/generate/scheme/td_api.tl | 10 +++++----- td/telegram/AuthManager.h | 2 +- td/telegram/ContactsManager.cpp | 2 +- td/telegram/ContactsManager.h | 7 ++++--- td/telegram/MessagesManager.cpp | 8 ++++---- td/telegram/MessagesManager.h | 3 ++- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 1c33ceb86..066f56426 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2345,7 +2345,7 @@ setAuthenticationPhoneNumber phone_number:string allow_flash_call:Bool is_curren resendAuthenticationCode = Ok; //@description Checks the authentication code. Works only when the current authorization state is authorizationStateWaitCode @code The verification code received via SMS, Telegram message, phone call, or flash call -//@first_name If the user is not yet registered, the first name of the user; 1-255 characters @last_name If the user is not yet registered; the last name of the user; optional; 0-255 characters +//@first_name If the user is not yet registered, the first name of the user; 1-64 characters @last_name If the user is not yet registered; the last name of the user; optional; 0-64 characters checkAuthenticationCode code:string first_name:string last_name:string = Ok; //@description Checks the authentication password for correctness. Works only when the current authorization state is authorizationStateWaitPassword @password The password to check @@ -2734,10 +2734,10 @@ createSupergroupChat supergroup_id:int32 force:Bool = Chat; //@description Returns an existing chat corresponding to a known secret chat @secret_chat_id Secret chat identifier createSecretChat secret_chat_id:int32 = Chat; -//@description Creates a new basic group and sends a corresponding messageBasicGroupChatCreate. Returns the newly created chat @user_ids Identifiers of users to be added to the basic group @title Title of the new basic group; 1-255 characters +//@description Creates a new basic group and sends a corresponding messageBasicGroupChatCreate. Returns the newly created chat @user_ids Identifiers of users to be added to the basic group @title Title of the new basic group; 1-128 characters createNewBasicGroupChat user_ids:vector title:string = Chat; -//@description Creates a new supergroup or channel and sends a corresponding messageSupergroupChatCreate. Returns the newly created chat @title Title of the new chat; 1-255 characters @is_channel True, if a channel chat should be created @param_description Chat description; 0-255 characters +//@description Creates a new supergroup or channel and sends a corresponding messageSupergroupChatCreate. Returns the newly created chat @title Title of the new chat; 1-128 characters @is_channel True, if a channel chat should be created @param_description Chat description; 0-255 characters createNewSupergroupChat title:string is_channel:Bool description:string = Chat; //@description Creates a new secret chat. Returns the newly created chat @user_id Identifier of the target user @@ -2748,7 +2748,7 @@ upgradeBasicGroupChatToSupergroupChat chat_id:int53 = Chat; //@description Changes the chat title. Supported only for basic groups, supergroups and channels. Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels. The title will not be changed until the request to the server has been completed -//@chat_id Chat identifier @title New title of the chat; 1-255 characters +//@chat_id Chat identifier @title New title of the chat; 1-128 characters setChatTitle chat_id:int53 title:string = Ok; //@description Changes the photo of a chat. Supported only for basic groups, supergroups and channels. Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels. The photo will not be changed before request to the server has been completed @@ -3015,7 +3015,7 @@ setProfilePhoto photo:InputFile = Ok; //@description Deletes a profile photo. If something changes, updateUser will be sent @profile_photo_id Identifier of the profile photo to delete deleteProfilePhoto profile_photo_id:int64 = Ok; -//@description Changes the first and last name of the current user. If something changes, updateUser will be sent @first_name The new value of the first name for the user; 1-255 characters @last_name The new value of the optional last name for the user; 0-255 characters +//@description Changes the first and last name of the current user. If something changes, updateUser will be sent @first_name The new value of the first name for the user; 1-64 characters @last_name The new value of the optional last name for the user; 0-64 characters setName first_name:string last_name:string = Ok; //@description Changes the bio of the current user @bio The new value of the user bio; 0-70 characters without line feeds diff --git a/td/telegram/AuthManager.h b/td/telegram/AuthManager.h index 47f57575b..4193b8bcf 100644 --- a/td/telegram/AuthManager.h +++ b/td/telegram/AuthManager.h @@ -169,7 +169,7 @@ class AuthManager : public NetActor { void on_closing(); private: - static constexpr size_t MAX_NAME_LENGTH = 255; // server side limit + static constexpr size_t MAX_NAME_LENGTH = 64; // server side limit enum class State : int32 { None, diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 0ad112b37..50a00cbb2 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -4046,7 +4046,7 @@ void ContactsManager::toggle_channel_is_all_history_available(ChannelId channel_ void ContactsManager::set_channel_description(ChannelId channel_id, const string &description, Promise &&promise) { - auto new_description = strip_empty_characters(description, MAX_NAME_LENGTH); + auto new_description = strip_empty_characters(description, MAX_DESCRIPTION_LENGTH); auto c = get_channel(channel_id); if (c == nullptr) { return promise.set_error(Status::Error(6, "Supergroup not found")); diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 1a5c14729..e6598dbe1 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -680,9 +680,10 @@ class ContactsManager : public Actor { class ChannelLogEvent; class SecretChatLogEvent; - static constexpr int32 MAX_GET_PROFILE_PHOTOS = 100; // server side limit - static constexpr size_t MAX_NAME_LENGTH = 255; // server side limit for first/last name and title - static constexpr size_t MAX_BIO_LENGTH = 70; // server side limit + static constexpr int32 MAX_GET_PROFILE_PHOTOS = 100; // server side limit + static constexpr size_t MAX_NAME_LENGTH = 64; // server side limit for first/last name + static constexpr size_t MAX_DESCRIPTION_LENGTH = 255; // server side limit for channel description + static constexpr size_t MAX_BIO_LENGTH = 70; // server side limit static constexpr int32 USER_FLAG_HAS_ACCESS_HASH = 1 << 0; static constexpr int32 USER_FLAG_HAS_FIRST_NAME = 1 << 1; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 208110762..1bf5938b6 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -13207,7 +13207,7 @@ DialogId MessagesManager::create_new_group_chat(const vector &user_ids, return DialogId(); } - auto new_title = clean_name(title, MAX_NAME_LENGTH); + auto new_title = clean_name(title, MAX_TITLE_LENGTH); if (new_title.empty()) { promise.set_error(Status::Error(3, "Title can't be empty")); return DialogId(); @@ -13255,7 +13255,7 @@ DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_m return dialog_id; } - auto new_title = clean_name(title, MAX_NAME_LENGTH); + auto new_title = clean_name(title, MAX_TITLE_LENGTH); if (new_title.empty()) { promise.set_error(Status::Error(3, "Title can't be empty")); return DialogId(); @@ -13267,7 +13267,7 @@ DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_m created_dialogs_[random_id]; // reserve place for result td_->create_handler(std::move(promise)) - ->send(new_title, is_megagroup, strip_empty_characters(description, MAX_NAME_LENGTH), random_id); + ->send(new_title, is_megagroup, strip_empty_characters(description, MAX_DESCRIPTION_LENGTH), random_id); return DialogId(); } @@ -21438,7 +21438,7 @@ void MessagesManager::set_dialog_title(DialogId dialog_id, const string &title, return promise.set_error(Status::Error(3, "Chat not found")); } - auto new_title = clean_name(title, MAX_NAME_LENGTH); + auto new_title = clean_name(title, MAX_TITLE_LENGTH); if (new_title.empty()) { return promise.set_error(Status::Error(3, "Title can't be empty")); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index ddfceb87f..5fa6ee096 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1910,7 +1910,8 @@ class MessagesManager : public Actor { static constexpr int32 MAX_CHANNEL_DIFFERENCE = 100; static constexpr int32 MAX_BOT_CHANNEL_DIFFERENCE = 100000; // server side limit static constexpr int32 MAX_RECENT_FOUND_DIALOGS = 20; // some reasonable value - static constexpr size_t MAX_NAME_LENGTH = 255; // server side limit for title and description + static constexpr size_t MAX_TITLE_LENGTH = 128; // server side limit for chat title + static constexpr size_t MAX_DESCRIPTION_LENGTH = 255; // server side limit for chat description static constexpr int64 SPONSORED_DIALOG_ORDER = static_cast(2147483647) << 32; static constexpr int32 MIN_PINNED_DIALOG_DATE = 2147000000; // some big date static constexpr int32 MAX_PRIVATE_MESSAGE_TTL = 60; // server side limit