From 575e5f8fb06010227c3ffe3bf1c69dfda1c739da Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 10 Jul 2026 00:11:39 +0300 Subject: Add community.permissions. --- td/generate/scheme/td_api.tl | 7 ++++++- td/telegram/CommunityManager.cpp | 5 +++-- td/telegram/DialogParticipant.cpp | 12 ++++++++++++ td/telegram/DialogParticipant.h | 4 ++++ 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 background_colors:vector 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 CommunityManager::get_community_object(Com } return td_api::make_object(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 CommunityManager::get_update_community_object(CommunityId community_id, @@ -596,7 +596,8 @@ td_api::object_ptr CommunityManager::get_update_communi td_api::object_ptr CommunityManager::get_update_unknown_community_object( CommunityId community_id) const { return td_api::make_object( - td_api::make_object(community_id.get(), false, string(), nullptr, 0)); + td_api::make_object(community_id.get(), false, string(), nullptr, 0, + RestrictedRights::restrict_all().get_community_permissions_object())); } void CommunityManager::get_current_state(vector> &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_ptrcan_edit_tag_, rights->can_react_to_messages_, false, channel_type); } +RestrictedRights::RestrictedRights(const td_api::object_ptr &rights) { + if (rights == nullptr) { + flags_ = 0; + return; + } + flags_ = (static_cast(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 RestrictedRights::get_chat_permissio can_invite_users(), can_pin_messages(), can_manage_topics()); } +td_api::object_ptr RestrictedRights::get_community_permissions_object() const { + return td_api::make_object(can_manage_linked_peers()); +} + telegram_api::object_ptr RestrictedRights::get_chat_banned_rights() const { return telegram_api::make_object( 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 &rights, ChannelType channel_type); + RestrictedRights(const td_api::object_ptr &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 get_chat_permissions_object() const; + td_api::object_ptr get_community_permissions_object() const; + tl_object_ptr get_chat_banned_rights() const; bool can_change_info_and_settings() const { -- cgit v1.2.3