aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2026-07-10 16:35:49 +0300
committerlevlam <levlam@telegram.org>2026-07-10 16:35:49 +0300
commit1add3c9bfb4bd19e4fb2986bb03e52ba93f21c14 (patch)
tree422e4e8924325bc82aa5371def2ed359cc129d33
parentec1b948090520d1b8ac377c22a1545ddc674b179 (diff)
Add userFullInfo.community_id.
-rw-r--r--td/generate/scheme/td_api.tl3
-rw-r--r--td/telegram/UserManager.cpp42
-rw-r--r--td/telegram/UserManager.h4
3 files changed, 41 insertions, 8 deletions
diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl
index 208a6dc3e..187703126 100644
--- a/td/generate/scheme/td_api.tl
+++ b/td/generate/scheme/td_api.tl
@@ -2418,6 +2418,7 @@ botInfo short_description:string description:string photo:photo animation:animat
//-If non-null and personal_photo is null, then it is the same photo as in user.profile_photo and chat.photo
//@public_photo User profile photo visible if the main photo is hidden by privacy settings; may be null. If null and user.profile_photo is null, then the photo is empty; otherwise, it is unknown.
//-If non-null and both photo and personal_photo are null, then it is the same photo as in user.profile_photo and chat.photo. This photo isn't returned in the list of user photos
+//@community_id Identifier of the community to which chat with the bot was added; for bots only
//@block_list Block list to which the user is added; may be null if none
//@can_be_called True, if the user can be called
//@supports_video_calls True, if a video call can be created with the user
@@ -2446,7 +2447,7 @@ botInfo short_description:string description:string photo:photo animation:animat
//@note Note added to the user's contact; may be null if none
//@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_posted_to_profile_stories:Bool has_sponsored_messages_enabled:Bool need_phone_number_privacy_exception:Bool set_chat_background:Bool uses_unofficial_app:Bool bio:formattedText birthdate:birthdate personal_chat_id:int53 gift_count:int32 group_in_common_count:int32 incoming_paid_message_star_count:int53 outgoing_paid_message_star_count:int53 gift_settings:giftSettings bot_verification:botVerification main_profile_tab:ProfileTab first_profile_audio:audio rating:userRating pending_rating:userRating pending_rating_date:int32 note:formattedText business_info:businessInfo bot_info:botInfo = UserFullInfo;
+userFullInfo personal_photo:chatPhoto photo:chatPhoto public_photo:chatPhoto community_id:int53 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_posted_to_profile_stories:Bool has_sponsored_messages_enabled:Bool need_phone_number_privacy_exception:Bool set_chat_background:Bool uses_unofficial_app:Bool bio:formattedText birthdate:birthdate personal_chat_id:int53 gift_count:int32 group_in_common_count:int32 incoming_paid_message_star_count:int53 outgoing_paid_message_star_count:int53 gift_settings:giftSettings bot_verification:botVerification main_profile_tab:ProfileTab first_profile_audio:audio rating:userRating pending_rating:userRating pending_rating_date:int32 note:formattedText 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;
diff --git a/td/telegram/UserManager.cpp b/td/telegram/UserManager.cpp
index 4b973e4bb..29dff4cc7 100644
--- a/td/telegram/UserManager.cpp
+++ b/td/telegram/UserManager.cpp
@@ -27,6 +27,7 @@
#include "td/telegram/ChatManager.h"
#include "td/telegram/ChatTheme.h"
#include "td/telegram/CommonDialogManager.h"
+#include "td/telegram/CommunityManager.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogLocation.h"
@@ -1828,6 +1829,7 @@ void UserManager::User::store(StorerT &storer) const {
bool has_bot_verification_icon = bot_verification_icon.is_valid();
bool has_paid_message_star_count = paid_message_star_count != 0;
bool has_peer_color_collectible = peer_color_collectible != nullptr;
+ bool has_linked_community_id = linked_community_id.is_valid();
BEGIN_STORE_FLAGS();
STORE_FLAG(is_received);
STORE_FLAG(is_verified);
@@ -1885,6 +1887,7 @@ void UserManager::User::store(StorerT &storer) const {
STORE_FLAG(can_manage_bots); // 20
STORE_FLAG(is_guestchat_bot);
STORE_FLAG(is_guard_bot);
+ STORE_FLAG(has_linked_community_id);
END_STORE_FLAGS();
}
store(first_name, storer);
@@ -1953,6 +1956,9 @@ void UserManager::User::store(StorerT &storer) const {
if (has_peer_color_collectible) {
store(peer_color_collectible, storer);
}
+ if (has_linked_community_id) {
+ store(linked_community_id, storer);
+ }
}
template <class ParserT>
@@ -1982,6 +1988,7 @@ void UserManager::User::parse(ParserT &parser) {
bool has_bot_verification_icon = false;
bool has_paid_message_star_count = false;
bool has_peer_color_collectible = false;
+ bool has_linked_community_id = false;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_received);
PARSE_FLAG(is_verified);
@@ -2039,6 +2046,7 @@ void UserManager::User::parse(ParserT &parser) {
PARSE_FLAG(can_manage_bots);
PARSE_FLAG(is_guestchat_bot);
PARSE_FLAG(is_guard_bot);
+ PARSE_FLAG(has_linked_community_id);
END_PARSE_FLAGS();
}
parse(first_name, parser);
@@ -2135,6 +2143,9 @@ void UserManager::User::parse(ParserT &parser) {
if (has_peer_color_collectible) {
parse(peer_color_collectible, parser);
}
+ if (has_linked_community_id) {
+ parse(linked_community_id, parser);
+ }
if (!check_utf8(first_name)) {
LOG(ERROR) << "Have invalid first name \"" << first_name << '"';
@@ -3404,6 +3415,7 @@ UserId UserManager::on_get_user(telegram_api::object_ptr<telegram_api::User> &&u
PeerColor profile_peer_color(user->profile_color_);
on_update_user_profile_colors(u, user_id, profile_peer_color.accent_color_id_,
profile_peer_color.background_custom_emoji_id_);
+ on_update_user_linked_community_id(u, user_id, CommunityId(user->linked_community_id_));
if (is_me_regular_user) {
if (is_received) {
on_update_user_stories_hidden(u, user_id, stories_hidden);
@@ -3744,6 +3756,17 @@ void UserManager::on_update_user_profile_colors(User *u, UserId user_id, AccentC
}
}
+void UserManager::on_update_user_linked_community_id(User *u, UserId user_id, CommunityId linked_community_id) {
+ if (!linked_community_id.is_valid() || !is_user_bot(u)) {
+ linked_community_id = CommunityId();
+ }
+ if (u->linked_community_id != linked_community_id) {
+ u->linked_community_id = linked_community_id;
+ u->is_full_info_changed = true;
+ u->need_save_to_database = true;
+ }
+}
+
void UserManager::on_update_user_emoji_status(UserId user_id,
telegram_api::object_ptr<telegram_api::EmojiStatus> &&emoji_status) {
if (!user_id.is_valid()) {
@@ -9326,8 +9349,14 @@ void UserManager::on_load_user_full_from_database(UserId user_id, string value)
return;
}
+ User *u = get_user_force(user_id, "on_load_user_full_from_database 5");
+ if (u == nullptr) {
+ G()->td_db()->get_sqlite_pmc()->erase(get_user_full_database_key(user_id), Auto());
+ return;
+ }
+
Dependencies dependencies;
- dependencies.add(user_id);
+ dependencies.add(u->linked_community_id);
if (user_full->business_info != nullptr) {
user_full->business_info->add_dependencies(dependencies);
}
@@ -9353,8 +9382,6 @@ void UserManager::on_load_user_full_from_database(UserId user_id, string value)
user_full->need_phone_number_privacy_exception = false;
}
- User *u = get_user(user_id);
- CHECK(u != nullptr);
drop_user_full_photos(user_full, user_id, u->photo.id, "on_load_user_full_from_database 2");
if (!user_full->photo.is_empty()) {
register_user_photo(u, user_id, user_full->photo);
@@ -10389,10 +10416,11 @@ td_api::object_ptr<td_api::userFullInfo> UserManager::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),
- get_chat_photo_object(td_->file_manager_.get(), user_full->fallback_photo), block_list_id.get_block_list_object(),
- 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->sponsored_enabled, user_full->need_phone_number_privacy_exception, user_full->wallpaper_overridden,
+ get_chat_photo_object(td_->file_manager_.get(), user_full->fallback_photo),
+ is_bot ? u->linked_community_id.get() : 0, block_list_id.get_block_list_object(), 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->sponsored_enabled,
+ user_full->need_phone_number_privacy_exception, user_full->wallpaper_overridden,
user_full->unofficial_security_risk, std::move(bio_object), user_full->birthdate.get_birthdate_object(),
personal_chat_id, user_full->gift_count, user_full->common_chat_count, user_full->charge_paid_message_stars,
user_full->send_paid_message_stars, user_full->gift_settings.get_gift_settings_object(),
diff --git a/td/telegram/UserManager.h b/td/telegram/UserManager.h
index f7d048dc4..47ee5388d 100644
--- a/td/telegram/UserManager.h
+++ b/td/telegram/UserManager.h
@@ -15,6 +15,7 @@
#include "td/telegram/BotVerifierSettings.h"
#include "td/telegram/BusinessConnectionId.h"
#include "td/telegram/ChannelId.h"
+#include "td/telegram/CommunityId.h"
#include "td/telegram/Contact.h"
#include "td/telegram/CustomEmojiId.h"
#include "td/telegram/DialogId.h"
@@ -612,6 +613,7 @@ class UserManager final : public Actor {
unique_ptr<PeerColorCollectible> peer_color_collectible;
AccentColorId profile_accent_color_id;
CustomEmojiId profile_background_custom_emoji_id;
+ CommunityId linked_community_id;
int32 was_online = 0;
int32 local_was_online = 0;
@@ -964,6 +966,8 @@ class UserManager final : public Actor {
void on_update_user_profile_colors(User *u, UserId user_id, AccentColorId accent_color_id,
CustomEmojiId background_custom_emoji_id);
+ void on_update_user_linked_community_id(User *u, UserId user_id, CommunityId linked_community_id);
+
void on_update_user_emoji_status(User *u, UserId user_id, unique_ptr<EmojiStatus> emoji_status);
void on_update_user_story_ids_impl(User *u, UserId user_id,