Add userFullInfo.personal_chat_id.

This commit is contained in:
levlam 2024-03-28 18:38:52 +03:00
parent 15c3bbdef8
commit 877e3329fe
3 changed files with 34 additions and 4 deletions

View File

@ -926,11 +926,12 @@ botInfo short_description:string description:string photo:photo animation:animat
//@set_chat_background True, if the user set chat background for both chat users and it wasn't reverted yet
//@bio A short user bio; may be null for bots
//@birthdate Birthdate of the user; may be null if unknown
//@personal_chat_id Identifier of the personal chat of the user; 0 if none
//@premium_gift_options The list of available options for gifting Telegram Premium to the user
//@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
//@business_info Information about business settings for Telegram Business accounts; may be null if none
//@bot_info For bots, information about the bot; may be null if the user isn't a bot
userFullInfo personal_photo:chatPhoto photo:chatPhoto public_photo:chatPhoto block_list:BlockList can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool has_restricted_voice_and_video_note_messages:Bool has_pinned_stories:Bool need_phone_number_privacy_exception:Bool set_chat_background:Bool bio:formattedText birthdate:birthdate premium_gift_options:vector<premiumPaymentOption> group_in_common_count:int32 business_info:businessInfo bot_info:botInfo = UserFullInfo;
userFullInfo personal_photo:chatPhoto photo:chatPhoto public_photo:chatPhoto block_list:BlockList can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool has_restricted_voice_and_video_note_messages:Bool has_pinned_stories:Bool need_phone_number_privacy_exception:Bool set_chat_background:Bool bio:formattedText birthdate:birthdate personal_chat_id:int53 premium_gift_options:vector<premiumPaymentOption> group_in_common_count:int32 business_info:businessInfo bot_info:botInfo = UserFullInfo;
//@description Represents a list of users @total_count Approximate total number of users found @user_ids A list of user identifiers
users total_count:int32 user_ids:vector<int53> = Users;

View File

@ -3279,6 +3279,7 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
bool has_fallback_photo = !fallback_photo.is_empty();
bool has_business_info = business_info != nullptr && !business_info->is_empty();
bool has_birthdate = !birthdate.is_empty();
bool has_personal_channel_id = personal_channel_id.is_valid();
BEGIN_STORE_FLAGS();
STORE_FLAG(has_about);
STORE_FLAG(is_blocked);
@ -3307,6 +3308,7 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
STORE_FLAG(contact_require_premium);
STORE_FLAG(has_business_info); // 25
STORE_FLAG(has_birthdate);
STORE_FLAG(has_personal_channel_id);
END_STORE_FLAGS();
if (has_about) {
store(about, storer);
@ -3356,6 +3358,9 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
if (has_birthdate) {
store(birthdate, storer);
}
if (has_personal_channel_id) {
store(personal_channel_id, storer);
}
}
template <class ParserT>
@ -3376,6 +3381,7 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
bool has_fallback_photo;
bool has_business_info;
bool has_birthdate;
bool has_personal_channel_id;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_about);
PARSE_FLAG(is_blocked);
@ -3404,6 +3410,7 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
PARSE_FLAG(contact_require_premium);
PARSE_FLAG(has_business_info);
PARSE_FLAG(has_birthdate);
PARSE_FLAG(has_personal_channel_id);
END_PARSE_FLAGS();
if (has_about) {
parse(about, parser);
@ -3453,6 +3460,9 @@ void ContactsManager::UserFull::parse(ParserT &parser) {
if (has_birthdate) {
parse(birthdate, parser);
}
if (has_personal_channel_id) {
parse(personal_channel_id, parser);
}
}
template <class StorerT>
@ -9266,7 +9276,7 @@ void ContactsManager::on_load_user_full_from_database(UserId user_id, string val
if (user_full->business_info != nullptr) {
user_full->business_info->add_dependencies(dependencies);
}
dependencies.add(user_id);
dependencies.add(user_full->personal_channel_id);
if (!dependencies.resolve_force(td_, "on_load_user_full_from_database")) {
users_full_.erase(user_id);
G()->td_db()->get_sqlite_pmc()->erase(get_user_full_database_key(user_id), Auto());
@ -10410,6 +10420,7 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
AdministratorRights broadcast_administrator_rights(user->bot_broadcast_admin_rights_, ChannelType::Broadcast);
bool has_pinned_stories = user->stories_pinned_available_;
auto birthdate = Birthdate(std::move(user->birthday_));
auto personal_channel_id = ChannelId(user->personal_channel_id_);
if (user_full->can_be_called != can_be_called || user_full->supports_video_calls != supports_video_calls ||
user_full->has_private_calls != has_private_calls ||
user_full->group_administrator_rights != group_administrator_rights ||
@ -10482,6 +10493,14 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
user_full->description_animation_file_id = description_animation_file_id;
user_full->is_changed = true;
}
if (personal_channel_id != ChannelId() && !personal_channel_id.is_valid()) {
LOG(ERROR) << "Receive personal " << personal_channel_id;
personal_channel_id = ChannelId();
}
if (user_full->personal_channel_id != personal_channel_id) {
user_full->personal_channel_id = personal_channel_id;
user_full->is_changed = true;
}
auto photo = get_photo(td_, std::move(user->profile_photo_), DialogId(user_id));
auto personal_photo = get_photo(td_, std::move(user->personal_photo_), DialogId(user_id));
@ -12265,6 +12284,7 @@ void ContactsManager::drop_user_full(UserId user_id) {
user_full->menu_button = nullptr;
user_full->commands.clear();
user_full->common_chat_count = 0;
user_full->personal_channel_id = ChannelId();
user_full->business_info = nullptr;
user_full->private_forward_name.clear();
user_full->group_administrator_rights = {};
@ -16244,6 +16264,12 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
auto business_info = is_premium && user_full->business_info != nullptr
? user_full->business_info->get_business_info_object(td_)
: nullptr;
int64 personal_chat_id = 0;
if (user_full->personal_channel_id.is_valid()) {
DialogId dialog_id(user_full->personal_channel_id);
td_->dialog_manager_->force_create_dialog(dialog_id, "get_user_full_info_object", true);
personal_chat_id = td_->dialog_manager_->get_chat_id_object(dialog_id, "get_user_full_info_object");
}
return td_api::make_object<td_api::userFullInfo>(
get_chat_photo_object(td_->file_manager_.get(), user_full->personal_photo),
get_chat_photo_object(td_->file_manager_.get(), user_full->photo),
@ -16251,8 +16277,9 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
user_full->can_be_called, user_full->supports_video_calls, user_full->has_private_calls,
!user_full->private_forward_name.empty(), voice_messages_forbidden, user_full->has_pinned_stories,
user_full->need_phone_number_privacy_exception, user_full->wallpaper_overridden, std::move(bio_object),
user_full->birthdate.get_birthdate_object(), get_premium_payment_options_object(user_full->premium_gift_options),
user_full->common_chat_count, std::move(business_info), std::move(bot_info));
user_full->birthdate.get_birthdate_object(), personal_chat_id,
get_premium_payment_options_object(user_full->premium_gift_options), user_full->common_chat_count,
std::move(business_info), std::move(bot_info));
}
td_api::object_ptr<td_api::updateBasicGroup> ContactsManager::get_update_basic_group_object(ChatId chat_id,

View File

@ -821,6 +821,8 @@ class ContactsManager final : public Actor {
int32 common_chat_count = 0;
Birthdate birthdate;
ChannelId personal_channel_id;
unique_ptr<BusinessInfo> business_info;
bool is_blocked = false;