aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2026-07-10 13:54:04 +0300
committerlevlam <levlam@telegram.org>2026-07-10 13:54:04 +0300
commite620486b7f47030c5dffbbf43654fe797327f602 (patch)
tree2bbc69b8d70ff52a793984316e5e2d381daa32af
parentc0734a9b47e1575a516097c0b6a21725f8316385 (diff)
Add community.status.
-rw-r--r--td/generate/scheme/td_api.tl22
-rw-r--r--td/telegram/CommunityManager.cpp9
-rw-r--r--td/telegram/DialogParticipant.cpp22
-rw-r--r--td/telegram/DialogParticipant.h2
4 files changed, 50 insertions, 5 deletions
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<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->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<td_api::updateCommunity> CommunityManager::get_update_community_object(CommunityId community_id,
@@ -595,9 +596,9 @@ 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,
- RestrictedRights::restrict_all().get_community_permissions_object()));
+ 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::communityMemberStatusBanned>(),
+ 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 70eb4b03b..d7e04bcf7 100644
--- a/td/telegram/DialogParticipant.cpp
+++ b/td/telegram/DialogParticipant.cpp
@@ -508,6 +508,28 @@ td_api::object_ptr<td_api::ChatMemberStatus> DialogParticipantStatus::get_chat_m
}
}
+td_api::object_ptr<td_api::CommunityMemberStatus> DialogParticipantStatus::get_community_member_status_object() const {
+ switch (type_) {
+ case Type::Creator:
+ return td_api::make_object<td_api::communityMemberStatusCreator>();
+ case Type::Administrator:
+ return td_api::make_object<td_api::communityMemberStatusAdministrator>(
+ can_be_edited(), get_administrator_rights().get_community_administrator_rights_object());
+ case Type::Member:
+ return td_api::make_object<td_api::communityMemberStatusMember>();
+ case Type::Restricted:
+ LOG(ERROR) << "Have restricted user in a community";
+ return td_api::make_object<td_api::communityMemberStatusMember>();
+ case Type::Left:
+ return td_api::make_object<td_api::communityMemberStatusLeft>();
+ case Type::Banned:
+ return td_api::make_object<td_api::communityMemberStatusBanned>();
+ default:
+ UNREACHABLE();
+ return nullptr;
+ }
+}
+
tl_object_ptr<telegram_api::chatAdminRights> 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<td_api::ChatMemberStatus> get_chat_member_status_object(string *rank) const;
+ td_api::object_ptr<td_api::CommunityMemberStatus> get_community_member_status_object() const;
+
telegram_api::object_ptr<telegram_api::chatAdminRights> get_chat_admin_rights() const;
telegram_api::object_ptr<telegram_api::chatBannedRights> get_chat_banned_rights() const;