Add botInfo.has_media_previews.

This commit is contained in:
levlam 2024-07-19 18:03:07 +03:00
parent 6d3c92c779
commit bd9f33f0c1
3 changed files with 39 additions and 2 deletions

View File

@ -1032,11 +1032,12 @@ user id:int53 first_name:string last_name:string usernames:usernames phone_numbe
//@commands List of the bot commands
//@default_group_administrator_rights Default administrator rights for adding the bot to basic group and supergroup chats; may be null
//@default_channel_administrator_rights Default administrator rights for adding the bot to channels; may be null
//@has_media_previews True, if the bot has media previews
//@edit_commands_link The internal link, which can be used to edit bot commands; may be null
//@edit_description_link The internal link, which can be used to edit bot description; may be null
//@edit_description_media_link The internal link, which can be used to edit the photo or animation shown in the chat with the bot if the chat is empty; may be null
//@edit_settings_link The internal link, which can be used to edit bot settings; may be null
botInfo short_description:string description:string photo:photo animation:animation menu_button:botMenuButton commands:vector<botCommand> default_group_administrator_rights:chatAdministratorRights default_channel_administrator_rights:chatAdministratorRights edit_commands_link:InternalLinkType edit_description_link:InternalLinkType edit_description_media_link:InternalLinkType edit_settings_link:InternalLinkType = BotInfo;
botInfo short_description:string description:string photo:photo animation:animation menu_button:botMenuButton commands:vector<botCommand> default_group_administrator_rights:chatAdministratorRights default_channel_administrator_rights:chatAdministratorRights has_media_previews:Bool edit_commands_link:InternalLinkType edit_description_link:InternalLinkType edit_description_media_link:InternalLinkType edit_settings_link:InternalLinkType = BotInfo;
//@description Contains full information about a user
//@personal_photo User profile photo set by the current user for the contact; may be null. If null and user.profile_photo is null, then the photo is empty; otherwise, it is unknown.

View File

@ -1712,6 +1712,7 @@ void UserManager::UserFull::store(StorerT &storer) const {
END_STORE_FLAGS();
if (has_flags2) {
BEGIN_STORE_FLAGS();
STORE_FLAG(has_preview_medias);
END_STORE_FLAGS();
}
if (has_about) {
@ -1821,6 +1822,7 @@ void UserManager::UserFull::parse(ParserT &parser) {
END_PARSE_FLAGS();
if (has_flags2) {
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_preview_medias);
END_PARSE_FLAGS();
}
if (has_about) {
@ -3503,6 +3505,33 @@ void UserManager::on_update_user_full_menu_button(
}
}
void UserManager::on_update_bot_has_preview_medias(UserId bot_user_id, bool has_preview_medias) {
if (!bot_user_id.is_valid()) {
LOG(ERROR) << "Receive updateBotHasPreviewMedias about invalid " << bot_user_id;
return;
}
if (!have_user_force(bot_user_id, "on_update_bot_has_preview_medias") || !is_user_bot(bot_user_id)) {
return;
}
if (td_->auth_manager_->is_bot()) {
return;
}
auto user_full = get_user_full_force(bot_user_id, "on_update_bot_has_preview_medias");
if (user_full != nullptr) {
on_update_user_full_has_preview_medias(user_full, bot_user_id, has_preview_medias);
update_user_full(user_full, bot_user_id, "on_update_bot_has_preview_medias");
}
}
void UserManager::on_update_user_full_has_preview_medias(UserFull *user_full, UserId user_id, bool has_preview_medias) {
CHECK(user_full != nullptr);
if (user_full->has_preview_medias != has_preview_medias) {
user_full->has_preview_medias = has_preview_medias;
user_full->is_changed = true;
}
}
void UserManager::on_update_secret_chat(SecretChatId secret_chat_id, int64 access_hash, UserId user_id,
SecretChatState state, bool is_outbound, int32 ttl, int32 date, string key_hash,
int32 layer, FolderId initial_folder_id) {
@ -6934,6 +6963,7 @@ void UserManager::on_get_user_full(telegram_api::object_ptr<telegram_api::userFu
on_update_user_full_commands(user_full, user_id, std::move(user->bot_info_->commands_));
on_update_user_full_menu_button(user_full, user_id, std::move(user->bot_info_->menu_button_));
on_update_user_full_has_preview_medias(user_full, user_id, std::move(user->bot_info_->has_preview_medias_));
}
if (user_full->description != description) {
user_full->description = std::move(description);
@ -7211,6 +7241,7 @@ void UserManager::drop_user_full(UserId user_id) {
user_full->contact_require_premium = false;
user_full->birthdate = {};
user_full->sponsored_enabled = false;
user_full->has_preview_medias = false;
user_full->is_changed = true;
update_user_full(user_full, user_id, "drop_user_full");
@ -7950,7 +7981,7 @@ td_api::object_ptr<td_api::userFullInfo> UserManager::get_user_full_info_object(
user_full->broadcast_administrator_rights == AdministratorRights()
? nullptr
: user_full->broadcast_administrator_rights.get_chat_administrator_rights_object(),
nullptr, nullptr, nullptr, nullptr);
user_full->has_preview_medias, nullptr, nullptr, nullptr, nullptr);
if (u != nullptr && u->can_be_edited_bot && u->usernames.has_editable_username()) {
auto bot_username = u->usernames.get_editable_username();
bot_info->edit_commands_link_ = td_api::make_object<td_api::internalLinkTypeBotStart>(

View File

@ -158,6 +158,8 @@ class UserManager final : public Actor {
void on_update_bot_menu_button(UserId bot_user_id,
telegram_api::object_ptr<telegram_api::BotMenuButton> &&bot_menu_button);
void on_update_bot_has_preview_medias(UserId bot_user_id, bool has_preview_medias);
void on_update_secret_chat(SecretChatId secret_chat_id, int64 access_hash, UserId user_id, SecretChatState state,
bool is_outbound, int32 ttl, int32 date, string key_hash, int32 layer,
FolderId initial_folder_id);
@ -608,6 +610,7 @@ class UserManager final : public Actor {
bool read_dates_private = false;
bool contact_require_premium = false;
bool sponsored_enabled = false;
bool has_preview_medias = false;
bool is_common_chat_count_changed = true;
bool is_being_updated = false;
@ -842,6 +845,8 @@ class UserManager final : public Actor {
static void on_update_user_full_menu_button(UserFull *user_full, UserId user_id,
telegram_api::object_ptr<telegram_api::BotMenuButton> &&bot_menu_button);
static void on_update_user_full_has_preview_medias(UserFull *user_full, UserId user_id, bool has_preview_medias);
bool have_input_peer_user(const User *u, UserId user_id, AccessRights access_rights) const;
static bool have_input_encrypted_peer(const SecretChat *secret_chat, AccessRights access_rights);