Move bot description from BotInfo to UserFull.

This commit is contained in:
levlam 2021-06-21 01:12:34 +03:00
parent f9a5eae94c
commit d9dc6f875d
3 changed files with 32 additions and 7 deletions

View File

@ -353,8 +353,8 @@ botCommand command:string description:string = BotCommand;
//@description Contains a list of bot commands @commands List of bot commands
botCommands commands:vector<botCommand> = BotCommands;
//@description Provides information about a bot and its supported commands @param_description Long description shown on the user info page @commands A list of commands supported by the bot
botInfo description:string commands:vector<botCommand> = BotInfo;
//@description Provides information about a bot and its supported commands @commands A list of commands supported by the bot
botInfo commands:vector<botCommand> = BotInfo;
//@description Represents a location to which a chat is connected @location The location @address Location address; 1-64 characters, as defined by the chat owner
@ -421,10 +421,12 @@ user id:int32 first_name:string last_name:string username:string phone_number:st
//@supports_video_calls True, if a video call can be created with the user
//@has_private_calls True, if the user can't be called due to their privacy settings
//@need_phone_number_privacy_exception True, if the current user needs to explicitly allow to share their phone number with the user when the method addContact is used
//@bio A short user bio @share_text For bots, the text that is included with the link when users share the bot
//@bio A short user bio
//@share_text For bots, the text that is included with the link when users share the bot
//@param_description For bots, description shown on the bot info page
//@group_in_common_count Number of group chats where both the other user and the current user are a member; 0 for the current user
//@bot_info If the user is a bot, information about the bot; may be null
userFullInfo photo:chatPhoto is_blocked:Bool can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool need_phone_number_privacy_exception:Bool bio:string share_text:string group_in_common_count:int32 bot_info:botInfo = UserFullInfo;
userFullInfo photo:chatPhoto is_blocked:Bool can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool need_phone_number_privacy_exception:Bool bio:string share_text:string description:string group_in_common_count:int32 bot_info:botInfo = UserFullInfo;
//@description Represents a list of users @total_count Approximate total count of users found @user_ids A list of user identifiers
users total_count:int32 user_ids:vector<int32> = Users;

View File

@ -3906,6 +3906,7 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
using td::store;
bool has_about = !about.empty();
bool has_photo = !photo.is_empty();
bool has_description = !description.empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_about);
STORE_FLAG(is_blocked);
@ -3915,6 +3916,7 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
STORE_FLAG(need_phone_number_privacy_exception);
STORE_FLAG(has_photo);
STORE_FLAG(supports_video_calls);
STORE_FLAG(has_description);
END_STORE_FLAGS();
if (has_about) {
store(about, storer);
@ -3924,6 +3926,9 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
if (has_photo) {
store(photo, storer);
}
if (has_description) {
store(description, storer);
}
}
template <class ParserT>
@ -3931,6 +3936,7 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
using td::parse;
bool has_about;
bool has_photo;
bool has_description;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_about);
PARSE_FLAG(is_blocked);
@ -3940,6 +3946,7 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
PARSE_FLAG(need_phone_number_privacy_exception);
PARSE_FLAG(has_photo);
PARSE_FLAG(supports_video_calls);
PARSE_FLAG(has_description);
END_PARSE_FLAGS();
if (has_about) {
parse(about, parser);
@ -3949,6 +3956,9 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
if (has_photo) {
parse(photo, parser);
}
if (has_description) {
parse(description, parser);
}
}
template <class StorerT>
@ -9377,7 +9387,10 @@ void ContactsManager::on_load_user_full_from_database(UserId user_id, string val
if (user_full->need_phone_number_privacy_exception && is_user_contact(user_id)) {
user_full->need_phone_number_privacy_exception = false;
}
get_bot_info_force(user_id, false);
auto *bot_info = get_bot_info_force(user_id, false);
if (bot_info != nullptr) {
user_full->description = bot_info->description;
}
User *u = get_user(user_id);
CHECK(u != nullptr);
@ -10278,6 +10291,14 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
user_full->is_changed = true;
td_->group_call_manager_->on_update_dialog_about(DialogId(user_id), user_full->about, true);
}
string description;
if (user->bot_info_ != nullptr) {
description = std::move(user->bot_info_->description_);
}
if (user_full->description != description) {
user_full->description = std::move(description);
user_full->is_changed = true;
}
auto photo = get_photo(td_->file_manager_.get(), std::move(user->profile_photo_), DialogId(user_id));
if (photo != user_full->photo) {
@ -11464,6 +11485,7 @@ void ContactsManager::drop_user_full(UserId user_id) {
user_full->has_private_calls = false;
user_full->need_phone_number_privacy_exception = false;
user_full->about = string();
user_full->description = string();
user_full->common_chat_count = 0;
user_full->is_changed = true;
@ -15990,7 +16012,7 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
get_chat_photo_object(td_->file_manager_.get(), user_full->photo), user_full->is_blocked,
user_full->can_be_called, user_full->supports_video_calls, user_full->has_private_calls,
user_full->need_phone_number_privacy_exception, is_bot ? string() : user_full->about,
is_bot ? user_full->about : string(), user_full->common_chat_count,
is_bot ? user_full->about : string(), is_bot ? user_full->description : string(), user_full->common_chat_count,
is_bot ? get_bot_info_object(user_id) : nullptr);
}
@ -16158,7 +16180,7 @@ td_api::object_ptr<td_api::botInfo> ContactsManager::get_bot_info_object(UserId
auto commands = transform(bot_info->commands, [](auto &command) {
return td_api::make_object<td_api::botCommand>(command.first, command.second);
});
return td_api::make_object<td_api::botInfo>(bot_info->description, std::move(commands));
return td_api::make_object<td_api::botInfo>(std::move(commands));
}
tl_object_ptr<td_api::chatInviteLinkInfo> ContactsManager::get_chat_invite_link_info_object(

View File

@ -675,6 +675,7 @@ class ContactsManager : public Actor {
Photo photo;
string about;
string description;
int32 common_chat_count = 0;