From 3e003fb0901f5ea345562fb06962e7d06440eb25 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 7 Jul 2026 10:44:33 +0400 Subject: [PATCH] Support user.linked_community_id from layer 229 --- Telegram/SourceFiles/data/data_community.cpp | 7 +++++++ Telegram/SourceFiles/data/data_session.cpp | 5 ++++- Telegram/SourceFiles/data/data_user.cpp | 8 ++++++++ Telegram/SourceFiles/data/data_user.h | 4 ++++ .../SourceFiles/history/view/history_view_fake_items.cpp | 3 ++- Telegram/SourceFiles/main/main_account.cpp | 3 ++- 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/data/data_community.cpp b/Telegram/SourceFiles/data/data_community.cpp index 5652f81718..049fb5078a 100644 --- a/Telegram/SourceFiles/data/data_community.cpp +++ b/Telegram/SourceFiles/data/data_community.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_channel.h" #include "data/data_peer.h" #include "data/data_session.h" +#include "data/data_user.h" #include "history/history.h" #include "history/history_item.h" #include "lang/lang_keys.h" @@ -148,6 +149,8 @@ void CommunityInfo::applyLinkedPeers(const QVector &list) { for (const auto &linked : _linkedPeers) { if (const auto channel = linked.peer->asChannel()) { channel->setLinkedCommunityId(communityId); + } else if (const auto user = linked.peer->asUser()) { + user->setLinkedCommunityId(communityId); } } const auto stillLinked = [&](not_null history) { @@ -161,9 +164,13 @@ void CommunityInfo::applyLinkedPeers(const QVector &list) { for (const auto &history : base::duplicate(set)) { if (!stillLinked(history)) { const auto channel = history->peer->asChannel(); + const auto user = history->peer->asUser(); if (channel && channel->linkedCommunityId() == communityId) { channel->setLinkedCommunityId(ChannelId()); + } else if (user + && user->linkedCommunityId() == communityId) { + user->setLinkedCommunityId(ChannelId()); } } } diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index e2f6d94034..d10ad72aef 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -686,6 +686,8 @@ not_null Session::processUser(const MTPUser &data) { result->setFlags((result->flags() & ~flagsMask) | flagsSet); result->setBotVerifyDetailsIcon( data.vbot_verification_icon().value_or_empty()); + result->setLinkedCommunityId( + data.vlinked_community_id().value_or_empty()); if (!minimal) { if (storiesState) { result->setStoriesState(storiesState->hasVideoStream @@ -5516,7 +5518,8 @@ void Session::serviceNotification( MTPPeerColor(), // profile_color MTPint(), // bot_active_users MTPlong(), // bot_verification_icon - MTPlong())); // send_paid_messages_stars + MTPlong(), // send_paid_messages_stars + MTPlong())); // linked_community_id } const auto history = this->history(PeerData::kServiceNotificationsId); const auto insert = [=] { diff --git a/Telegram/SourceFiles/data/data_user.cpp b/Telegram/SourceFiles/data/data_user.cpp index 2a5c93abdb..2f588630a1 100644 --- a/Telegram/SourceFiles/data/data_user.cpp +++ b/Telegram/SourceFiles/data/data_user.cpp @@ -318,6 +318,14 @@ void UserData::setPersonalChannel(ChannelId channelId, MsgId messageId) { } } +ChannelId UserData::linkedCommunityId() const { + return _linkedCommunityId; +} + +void UserData::setLinkedCommunityId(ChannelId id) { + _linkedCommunityId = id; +} + UserId UserData::botManagerId() const { return _botManagerId; } diff --git a/Telegram/SourceFiles/data/data_user.h b/Telegram/SourceFiles/data/data_user.h index 3b6f00df47..549fae0172 100644 --- a/Telegram/SourceFiles/data/data_user.h +++ b/Telegram/SourceFiles/data/data_user.h @@ -302,6 +302,9 @@ public: [[nodiscard]] MsgId personalChannelMessageId() const; void setPersonalChannel(ChannelId channelId, MsgId messageId); + [[nodiscard]] ChannelId linkedCommunityId() const; + void setLinkedCommunityId(ChannelId id); + [[nodiscard]] UserId botManagerId() const; void setBotManagerId(UserId managerId); @@ -352,6 +355,7 @@ private: ChannelId _personalChannelId = 0; MsgId _personalChannelMessageId = 0; + ChannelId _linkedCommunityId = 0; UserId _botManagerId = 0; uint64 _accessHash = 0; diff --git a/Telegram/SourceFiles/history/view/history_view_fake_items.cpp b/Telegram/SourceFiles/history/view/history_view_fake_items.cpp index 5c41eee59e..b9d9a2dae7 100644 --- a/Telegram/SourceFiles/history/view/history_view_fake_items.cpp +++ b/Telegram/SourceFiles/history/view/history_view_fake_items.cpp @@ -62,7 +62,8 @@ PeerId GenerateUser(not_null history, const QString &name) { MTPPeerColor(), // profile_color MTPint(), // bot_active_users MTPlong(), // bot_verification_icon - MTPlong())); // send_paid_messages_stars + MTPlong(), // send_paid_messages_stars + MTPlong())); // linked_community_id return peerId; } diff --git a/Telegram/SourceFiles/main/main_account.cpp b/Telegram/SourceFiles/main/main_account.cpp index 2db2533187..900a928160 100644 --- a/Telegram/SourceFiles/main/main_account.cpp +++ b/Telegram/SourceFiles/main/main_account.cpp @@ -175,7 +175,8 @@ void Account::createSession( MTPPeerColor(), // profile_color MTPint(), // bot_active_users MTPlong(), // bot_verification_icon - MTPlong()), // send_paid_messages_stars + MTPlong(), // send_paid_messages_stars + MTPlong()), // linked_community_id serialized, streamVersion, std::move(settings));