aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2026-07-10 00:11:39 +0300
committerlevlam <levlam@telegram.org>2026-07-10 00:11:39 +0300
commit575e5f8fb06010227c3ffe3bf1c69dfda1c739da (patch)
tree2018916b575b2aa064114fed8a871ce2a7226a23
parenta83a851fe42c393cd34ffd8fcb9ef9ebe3e7db0c (diff)
Add community.permissions.
-rw-r--r--td/generate/scheme/td_api.tl7
-rw-r--r--td/telegram/CommunityManager.cpp5
-rw-r--r--td/telegram/DialogParticipant.cpp12
-rw-r--r--td/telegram/DialogParticipant.h4
4 files changed, 25 insertions, 3 deletions
diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl
index 027650222..9fd5b5415 100644
--- a/td/generate/scheme/td_api.tl
+++ b/td/generate/scheme/td_api.tl
@@ -2259,13 +2259,18 @@ profileAccentColors palette_colors:vector<int32> background_colors:vector<int32>
profileAccentColor id:int32 light_theme_colors:profileAccentColors dark_theme_colors:profileAccentColors min_supergroup_chat_boost_level:int32 min_channel_chat_boost_level:int32 = ProfileAccentColor;
+//@description Describes actions that a user is allowed to take in a community
+//@can_edit_chat_list True, if the user can change the chats added to the community
+communityPermissions can_edit_chat_list:Bool = CommunityPermissions;
+
//@description Represents a community consisting of supergroup chats, channel chats and chats with bots
//@id Community identifier
//@have_access If false, the community is inaccessible, and the only information known about the community is inside this class. Identifier of the community can't be passed to any method
//@name Community name
//@photo Community photo; may be null
//@date Point in time (Unix timestamp) when the community was joined, or the point in time when the community was created, in case the user is not a member of any chat in the community
-community id:int53 have_access:Bool name:string photo:chatPhotoInfo date:int32 = Community;
+//@permissions Actions that non-administrator community members are allowed to take in the community
+community id:int53 have_access:Bool name:string photo:chatPhotoInfo date:int32 permissions:communityPermissions = Community;
//@description Contains description of user rating
diff --git a/td/telegram/CommunityManager.cpp b/td/telegram/CommunityManager.cpp
index ba601b9a1..1eaf09c4c 100644
--- a/td/telegram/CommunityManager.cpp
+++ b/td/telegram/CommunityManager.cpp
@@ -582,7 +582,7 @@ td_api::object_ptr<td_api::community> CommunityManager::get_community_object(Com
}
return td_api::make_object<td_api::community>(community_id.get(), c->access_hash != 0, c->title,
get_chat_photo_info_object(td_->file_manager_.get(), &c->photo),
- c->date);
+ c->date, c->default_permissions.get_community_permissions_object());
}
td_api::object_ptr<td_api::updateCommunity> CommunityManager::get_update_community_object(CommunityId community_id,
@@ -596,7 +596,8 @@ td_api::object_ptr<td_api::updateCommunity> CommunityManager::get_update_communi
td_api::object_ptr<td_api::updateCommunity> CommunityManager::get_update_unknown_community_object(
CommunityId community_id) const {
return td_api::make_object<td_api::updateCommunity>(
- td_api::make_object<td_api::community>(community_id.get(), false, string(), nullptr, 0));
+ td_api::make_object<td_api::community>(community_id.get(), false, string(), nullptr, 0,
+ RestrictedRights::restrict_all().get_community_permissions_object()));
}
void CommunityManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
diff --git a/td/telegram/DialogParticipant.cpp b/td/telegram/DialogParticipant.cpp
index 5a83c8841..2a257a901 100644
--- a/td/telegram/DialogParticipant.cpp
+++ b/td/telegram/DialogParticipant.cpp
@@ -215,6 +215,14 @@ RestrictedRights::RestrictedRights(const td_api::object_ptr<td_api::chatPermissi
rights->can_edit_tag_, rights->can_react_to_messages_, false, channel_type);
}
+RestrictedRights::RestrictedRights(const td_api::object_ptr<td_api::communityPermissions> &rights) {
+ if (rights == nullptr) {
+ flags_ = 0;
+ return;
+ }
+ flags_ = (static_cast<uint64>(rights->can_edit_chat_list_) * CAN_MANAGE_LINKED_PEERS);
+}
+
RestrictedRights::RestrictedRights(bool can_send_messages, bool can_send_audios, bool can_send_documents,
bool can_send_photos, bool can_send_videos, bool can_send_video_notes,
bool can_send_voice_notes, bool can_send_stickers, bool can_send_animations,
@@ -262,6 +270,10 @@ td_api::object_ptr<td_api::chatPermissions> RestrictedRights::get_chat_permissio
can_invite_users(), can_pin_messages(), can_manage_topics());
}
+td_api::object_ptr<td_api::communityPermissions> RestrictedRights::get_community_permissions_object() const {
+ return td_api::make_object<td_api::communityPermissions>(can_manage_linked_peers());
+}
+
telegram_api::object_ptr<telegram_api::chatBannedRights> RestrictedRights::get_chat_banned_rights() const {
return telegram_api::make_object<telegram_api::chatBannedRights>(
0, false /*view_messages*/, false /*send_messages*/, false /*send_media*/, !can_send_stickers(),
diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h
index 3249e904e..57e13990f 100644
--- a/td/telegram/DialogParticipant.h
+++ b/td/telegram/DialogParticipant.h
@@ -219,6 +219,8 @@ class RestrictedRights {
RestrictedRights(const td_api::object_ptr<td_api::chatPermissions> &rights, ChannelType channel_type);
+ RestrictedRights(const td_api::object_ptr<td_api::communityPermissions> &rights);
+
RestrictedRights(bool can_send_messages, bool can_send_audios, bool can_send_documents, bool can_send_photos,
bool can_send_videos, bool can_send_video_notes, bool can_send_voice_notes, bool can_send_stickers,
bool can_send_animations, bool can_send_games, bool can_use_inline_bots,
@@ -230,6 +232,8 @@ class RestrictedRights {
td_api::object_ptr<td_api::chatPermissions> get_chat_permissions_object() const;
+ td_api::object_ptr<td_api::communityPermissions> get_community_permissions_object() const;
+
tl_object_ptr<telegram_api::chatBannedRights> get_chat_banned_rights() const;
bool can_change_info_and_settings() const {