From e620486b7f47030c5dffbbf43654fe797327f602 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 10 Jul 2026 13:54:04 +0300 Subject: Add community.status. --- td/generate/scheme/td_api.tl | 22 +++++++++++++++++++++- td/telegram/CommunityManager.cpp | 9 +++++---- td/telegram/DialogParticipant.cpp | 22 ++++++++++++++++++++++ td/telegram/DialogParticipant.h | 2 ++ 4 files changed, 50 insertions(+), 5 deletions(-) (limited to 'td') diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 66d143145..886196af6 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2271,14 +2271,34 @@ communityPermissions can_edit_chat_list:Bool = CommunityPermissions; //@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; +//@class CommunityMemberStatus @description Provides information about the status of a member in a community + +//@description The user is the owner of the community and has all the administrator privileges +communityMemberStatusCreator = CommunityMemberStatus; + +//@description The user is a member of the community and has some additional privileges +//@can_be_edited True, if the current user can edit the administrator privileges for the called user +//@rights Rights of the administrator +communityMemberStatusAdministrator can_be_edited:Bool rights:communityAdministratorRights = CommunityMemberStatus; + +//@description The user is a member of the community, without any additional privileges or restrictions +communityMemberStatusMember = CommunityMemberStatus; + +//@description The user or the chat is not a community member +communityMemberStatusLeft = CommunityMemberStatus; + +//@description The user or the chat was banned in the community; implies ban in all chats in the community +communityMemberStatusBanned = CommunityMemberStatus; + //@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 +//@status Status of the current user in the 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; +community id:int53 have_access:Bool name:string photo:chatPhotoInfo date:int32 status:CommunityMemberStatus permissions:communityPermissions = Community; //@description Contains description of user rating diff --git a/td/telegram/CommunityManager.cpp b/td/telegram/CommunityManager.cpp index 1eaf09c4c..682757ca2 100644 --- a/td/telegram/CommunityManager.cpp +++ b/td/telegram/CommunityManager.cpp @@ -582,7 +582,8 @@ 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->default_permissions.get_community_permissions_object()); + c->date, c->status.get_community_member_status_object(), + c->default_permissions.get_community_permissions_object()); } td_api::object_ptr CommunityManager::get_update_community_object(CommunityId community_id, @@ -595,9 +596,9 @@ 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, - RestrictedRights::restrict_all().get_community_permissions_object())); + return td_api::make_object(td_api::make_object( + community_id.get(), false, string(), nullptr, 0, td_api::make_object(), + 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 70eb4b03b..d7e04bcf7 100644 --- a/td/telegram/DialogParticipant.cpp +++ b/td/telegram/DialogParticipant.cpp @@ -508,6 +508,28 @@ td_api::object_ptr DialogParticipantStatus::get_chat_m } } +td_api::object_ptr DialogParticipantStatus::get_community_member_status_object() const { + switch (type_) { + case Type::Creator: + return td_api::make_object(); + case Type::Administrator: + return td_api::make_object( + can_be_edited(), get_administrator_rights().get_community_administrator_rights_object()); + case Type::Member: + return td_api::make_object(); + case Type::Restricted: + LOG(ERROR) << "Have restricted user in a community"; + return td_api::make_object(); + case Type::Left: + return td_api::make_object(); + case Type::Banned: + return td_api::make_object(); + default: + UNREACHABLE(); + return nullptr; + } +} + tl_object_ptr DialogParticipantStatus::get_chat_admin_rights() const { return get_administrator_rights().get_chat_admin_rights(); } diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h index a568913b2..fe457a164 100644 --- a/td/telegram/DialogParticipant.h +++ b/td/telegram/DialogParticipant.h @@ -422,6 +422,8 @@ class DialogParticipantStatus { td_api::object_ptr get_chat_member_status_object(string *rank) const; + td_api::object_ptr get_community_member_status_object() const; + telegram_api::object_ptr get_chat_admin_rights() const; telegram_api::object_ptr get_chat_banned_rights() const; -- cgit v1.2.3