From c0734a9b47e1575a516097c0b6a21725f8316385 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 10 Jul 2026 00:24:04 +0300 Subject: Add td_api::communityAdministratorRights. --- td/generate/scheme/td_api.tl | 8 ++++++++ td/telegram/DialogParticipant.cpp | 17 +++++++++++++++++ td/telegram/DialogParticipant.h | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 9fd5b5415..66d143145 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2263,6 +2263,14 @@ profileAccentColor id:int32 light_theme_colors:profileAccentColors dark_theme_co //@can_edit_chat_list True, if the user can change the chats added to the community communityPermissions can_edit_chat_list:Bool = CommunityPermissions; +//@description Describes rights of the administrator in a community +//@can_manage_community True, if the user is an administrator. Implied by any other privilege +//@can_change_info True, if the administrator can change the community name, photo, and other settings +//@can_edit_chat_list True, if the user can change the chats added to the community +//@can_promote_members True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that were directly or indirectly promoted by them +//@can_ban_members True, if the administrator can ban, or unban community members +communityAdministratorRights can_manage_community:Bool can_change_info:Bool can_edit_chat_list:Bool can_promote_members:Bool can_ban_members:Bool = CommunityAdministratorRights; + //@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 diff --git a/td/telegram/DialogParticipant.cpp b/td/telegram/DialogParticipant.cpp index 2a257a901..70eb4b03b 100644 --- a/td/telegram/DialogParticipant.cpp +++ b/td/telegram/DialogParticipant.cpp @@ -50,6 +50,16 @@ AdministratorRights::AdministratorRights(const td_api::object_ptrcan_manage_direct_messages_, rights->can_manage_tags_, false, channel_type); } +AdministratorRights::AdministratorRights(const td_api::object_ptr &rights) { + if (rights == nullptr) { + flags_ = 0; + return; + } + *this = AdministratorRights(false, rights->can_manage_community_, rights->can_change_info_, false, false, false, + false, rights->can_ban_members_, false, false, rights->can_promote_members_, false, false, + false, false, false, false, rights->can_edit_chat_list_, ChannelType::Unknown); +} + AdministratorRights::AdministratorRights(bool is_anonymous, bool can_manage_dialog, bool can_change_info, bool can_post_messages, bool can_edit_messages, bool can_delete_messages, bool can_invite_users, bool can_restrict_members, bool can_pin_messages, @@ -112,6 +122,13 @@ td_api::object_ptr AdministratorRights::get_cha can_manage_direct_messages(), can_manage_ranks(), is_anonymous()); } +td_api::object_ptr +AdministratorRights::get_community_administrator_rights_object() const { + return td_api::make_object(can_manage_dialog(), can_change_info_and_settings(), + can_manage_linked_peers(), can_promote_members(), + can_restrict_members()); +} + bool operator==(const AdministratorRights &lhs, const AdministratorRights &rhs) { return lhs.flags_ == rhs.flags_; } diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h index 57e13990f..a568913b2 100644 --- a/td/telegram/DialogParticipant.h +++ b/td/telegram/DialogParticipant.h @@ -65,6 +65,8 @@ class AdministratorRights { AdministratorRights(const td_api::object_ptr &administrator_rights, ChannelType channel_type); + AdministratorRights(const td_api::object_ptr &administrator_rights); + AdministratorRights(bool is_anonymous, bool can_manage_dialog, bool can_change_info, bool can_post_messages, bool can_edit_messages, bool can_delete_messages, bool can_invite_users, bool can_restrict_members, bool can_pin_messages, bool can_manage_topics, @@ -76,6 +78,8 @@ class AdministratorRights { td_api::object_ptr get_chat_administrator_rights_object() const; + td_api::object_ptr get_community_administrator_rights_object() const; + bool can_manage_dialog() const { return (flags_ & CAN_MANAGE_DIALOG) != 0; } -- cgit v1.2.3