Add support for administrator custom titles.
GitOrigin-RevId: a580b4713daa4746f5cd15e96c438fe179aea893
This commit is contained in:
parent
ad051b5522
commit
fbbf6470f3
@ -335,10 +335,13 @@ chatPermissions can_send_messages:Bool can_send_media_messages:Bool can_send_pol
|
||||
|
||||
//@class ChatMemberStatus @description Provides information about the status of a member in a chat
|
||||
|
||||
//@description The user is the owner of a chat and has all the administrator privileges @is_member True, if the user is a member of the chat
|
||||
chatMemberStatusCreator is_member:Bool = ChatMemberStatus;
|
||||
//@description The user is the owner of a chat and has all the administrator privileges
|
||||
//@custom_title A custom title of the owner; 0-16 characters without emojis; applicable to supergroups only
|
||||
//@is_member True, if the user is a member of the chat
|
||||
chatMemberStatusCreator custom_title:string is_member:Bool = ChatMemberStatus;
|
||||
|
||||
//@description The user is a member of a chat and has some additional privileges. In basic groups, administrators can edit and delete messages sent by others, add new members, and ban unprivileged members. In supergroups and channels, there are more detailed options for administrator privileges
|
||||
//@custom_title A custom title of the administrator; 0-16 characters without emojis; applicable to supergroups only
|
||||
//@can_be_edited True, if the current user can edit the administrator privileges for the called user
|
||||
//@can_change_info True, if the administrator can change the chat title, photo, and other settings
|
||||
//@can_post_messages True, if the administrator can create channel posts; applicable to channels only
|
||||
@ -348,7 +351,7 @@ chatMemberStatusCreator is_member:Bool = ChatMemberStatus;
|
||||
//@can_restrict_members True, if the administrator can restrict, ban, or unban chat members
|
||||
//@can_pin_messages True, if the administrator can pin messages; applicable to groups only
|
||||
//@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
|
||||
chatMemberStatusAdministrator can_be_edited: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_promote_members:Bool = ChatMemberStatus;
|
||||
chatMemberStatusAdministrator custom_title:string can_be_edited: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_promote_members:Bool = ChatMemberStatus;
|
||||
|
||||
//@description The user is a member of a chat, without any additional privileges or restrictions
|
||||
chatMemberStatusMember = ChatMemberStatus;
|
||||
@ -436,7 +439,7 @@ basicGroupFullInfo description:string creator_user_id:int32 members:vector<chatM
|
||||
//@id Supergroup or channel identifier
|
||||
//@username Username of the supergroup or channel; empty for private supergroups or channels
|
||||
//@date Point in time (Unix timestamp) when the current user joined, or the point in time when the supergroup or channel was created, in case the user is not a member
|
||||
//@status Status of the current user in the supergroup or channel
|
||||
//@status Status of the current user in the supergroup or channel; custom title will be always empty
|
||||
//@member_count Member count; 0 if unknown. Currently it is guaranteed to be known only if the supergroup or channel was found through SearchPublicChats
|
||||
//@has_linked_chat True, if the channel has a discussion group, or the supergroup is a discussion group for a channel
|
||||
//@has_location True, if the supergroup has a chat location
|
||||
|
Binary file not shown.
@ -1767,7 +1767,7 @@ class EditChannelAdminQuery : public Td::ResultHandler {
|
||||
auto input_channel = td->contacts_manager_->get_input_channel(channel_id);
|
||||
CHECK(input_channel != nullptr);
|
||||
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_editAdmin(
|
||||
std::move(input_channel), std::move(input_user), status.get_chat_admin_rights(), string()))));
|
||||
std::move(input_channel), std::move(input_user), status.get_chat_admin_rights(), status.get_rank()))));
|
||||
}
|
||||
|
||||
void on_result(uint64 id, BufferSlice packet) override {
|
||||
@ -3027,7 +3027,7 @@ void ContactsManager::Chat::parse(ParserT &parser) {
|
||||
} else if (left) {
|
||||
status = DialogParticipantStatus::Left();
|
||||
} else if (is_creator) {
|
||||
status = DialogParticipantStatus::Creator(true);
|
||||
status = DialogParticipantStatus::Creator(true, string());
|
||||
} else if (is_administrator && !everyone_is_administrator) {
|
||||
status = DialogParticipantStatus::GroupAdministrator(false);
|
||||
} else {
|
||||
@ -3191,7 +3191,7 @@ void ContactsManager::Channel::parse(ParserT &parser) {
|
||||
} else if (left) {
|
||||
status = DialogParticipantStatus::Left();
|
||||
} else if (is_creator) {
|
||||
status = DialogParticipantStatus::Creator(true);
|
||||
status = DialogParticipantStatus::Creator(true, string());
|
||||
} else if (can_edit || can_moderate) {
|
||||
status = DialogParticipantStatus::ChannelAdministrator(false, is_megagroup);
|
||||
} else {
|
||||
@ -5313,7 +5313,7 @@ void ContactsManager::change_channel_participant_status_impl(ChannelId channel_i
|
||||
old_status.can_change_info_and_settings(), old_status.can_invite_users(), old_status.can_pin_messages());
|
||||
}
|
||||
}
|
||||
if (old_status == status) {
|
||||
if (old_status == status && !old_status.is_creator()) {
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
|
||||
@ -5323,23 +5323,33 @@ void ContactsManager::change_channel_participant_status_impl(ChannelId channel_i
|
||||
bool need_restrict = false;
|
||||
if (status.is_creator() || old_status.is_creator()) {
|
||||
if (!old_status.is_creator()) {
|
||||
return promise.set_error(Status::Error(3, "Can't add creator to the chat"));
|
||||
return promise.set_error(Status::Error(3, "Can't add another owner to the chat"));
|
||||
}
|
||||
if (!status.is_creator()) {
|
||||
return promise.set_error(Status::Error(3, "Can't remove chat owner"));
|
||||
}
|
||||
if (status.is_member() == old_status.is_member()) {
|
||||
// change rank
|
||||
if (user_id != get_my_id()) {
|
||||
return promise.set_error(Status::Error(3, "Not enough rights to change chat owner custom title"));
|
||||
}
|
||||
|
||||
auto input_user = get_input_user(user_id);
|
||||
if (input_user == nullptr) {
|
||||
return promise.set_error(Status::Error(3, "User not found"));
|
||||
}
|
||||
|
||||
td_->create_handler<EditChannelAdminQuery>(std::move(promise))->send(channel_id, std::move(input_user), status);
|
||||
return;
|
||||
}
|
||||
if (user_id != get_my_id()) {
|
||||
return promise.set_error(Status::Error(3, "Not enough rights to edit chat owner membership"));
|
||||
}
|
||||
if (status.is_member()) {
|
||||
// creator member -> not creator member
|
||||
// creator not member -> creator member
|
||||
// creator not member -> not creator member
|
||||
if (old_status.is_member()) {
|
||||
return promise.set_error(Status::Error(3, "Can't demote chat creator"));
|
||||
}
|
||||
need_add = true;
|
||||
} else {
|
||||
// creator member -> creator not member
|
||||
// creator member -> not creator not member
|
||||
// creator not member -> not creator not member
|
||||
if (!old_status.is_member()) {
|
||||
return promise.set_error(Status::Error(3, "Can't restrict chat creator"));
|
||||
}
|
||||
need_restrict = true;
|
||||
}
|
||||
} else if (status.is_administrator()) {
|
||||
@ -5399,6 +5409,9 @@ void ContactsManager::promote_channel_participant(ChannelId channel_id, UserId u
|
||||
if (!get_channel_permissions(c).can_promote_members()) {
|
||||
return promise.set_error(Status::Error(3, "Not enough rights"));
|
||||
}
|
||||
|
||||
CHECK(!old_status.is_creator());
|
||||
CHECK(!status.is_creator());
|
||||
}
|
||||
|
||||
auto input_user = get_input_user(user_id);
|
||||
@ -5422,7 +5435,7 @@ void ContactsManager::change_chat_participant_status(ChatId chat_id, UserId user
|
||||
}
|
||||
|
||||
if (!get_chat_permissions(c).can_promote_members()) {
|
||||
return promise.set_error(Status::Error(3, "Need creator rights in the group chat"));
|
||||
return promise.set_error(Status::Error(3, "Need owner rights in the group chat"));
|
||||
}
|
||||
|
||||
if (user_id == get_my_id()) {
|
||||
@ -5706,9 +5719,8 @@ void ContactsManager::restrict_channel_participant(ChannelId channel_id, UserId
|
||||
return;
|
||||
}
|
||||
|
||||
if (status.is_creator()) {
|
||||
return promise.set_error(Status::Error(3, "Not enough rights to restrict chat creator"));
|
||||
}
|
||||
CHECK(!old_status.is_creator());
|
||||
CHECK(!status.is_creator());
|
||||
|
||||
if (!get_channel_permissions(c).can_restrict_members()) {
|
||||
return promise.set_error(Status::Error(3, "Not enough rights to restrict/unrestrict chat member"));
|
||||
@ -8918,7 +8930,7 @@ void ContactsManager::on_get_chat_participants(tl_object_ptr<telegram_api::ChatP
|
||||
auto participant = move_tl_object_as<telegram_api::chatParticipantCreator>(participant_ptr);
|
||||
new_creator_user_id = UserId(participant->user_id_);
|
||||
dialog_participant = {new_creator_user_id, new_creator_user_id, c->date,
|
||||
DialogParticipantStatus::Creator(true)};
|
||||
DialogParticipantStatus::Creator(true, string())};
|
||||
break;
|
||||
}
|
||||
case telegram_api::chatParticipantAdmin::ID: {
|
||||
@ -8998,13 +9010,15 @@ DialogParticipant ContactsManager::get_dialog_participant(
|
||||
}
|
||||
case telegram_api::channelParticipantCreator::ID: {
|
||||
auto participant = move_tl_object_as<telegram_api::channelParticipantCreator>(participant_ptr);
|
||||
return {UserId(participant->user_id_), UserId(), 0, DialogParticipantStatus::Creator(true)};
|
||||
return {UserId(participant->user_id_), UserId(), 0,
|
||||
DialogParticipantStatus::Creator(true, std::move(participant->rank_))};
|
||||
}
|
||||
case telegram_api::channelParticipantAdmin::ID: {
|
||||
auto participant = move_tl_object_as<telegram_api::channelParticipantAdmin>(participant_ptr);
|
||||
bool can_be_edited = (participant->flags_ & telegram_api::channelParticipantAdmin::CAN_EDIT_MASK) != 0;
|
||||
return {UserId(participant->user_id_), UserId(participant->promoted_by_), participant->date_,
|
||||
get_dialog_participant_status(can_be_edited, std::move(participant->admin_rights_))};
|
||||
get_dialog_participant_status(can_be_edited, std::move(participant->admin_rights_),
|
||||
std::move(participant->rank_))};
|
||||
}
|
||||
case telegram_api::channelParticipantBanned::ID: {
|
||||
auto participant = move_tl_object_as<telegram_api::channelParticipantBanned>(participant_ptr);
|
||||
@ -9742,7 +9756,7 @@ void ContactsManager::on_update_chat_add_user(ChatId chat_id, UserId inviter_use
|
||||
}
|
||||
chat_full->participants.push_back(DialogParticipant{user_id, inviter_user_id, date,
|
||||
user_id == chat_full->creator_user_id
|
||||
? DialogParticipantStatus::Creator(true)
|
||||
? DialogParticipantStatus::Creator(true, string())
|
||||
: DialogParticipantStatus::Member()});
|
||||
update_chat_online_member_count(chat_full, chat_id, false);
|
||||
chat_full->is_changed = true;
|
||||
@ -10223,7 +10237,7 @@ void ContactsManager::on_update_channel_status(Channel *c, ChannelId channel_id,
|
||||
|
||||
auto input_channel = get_input_channel(channel_id);
|
||||
if (input_channel != nullptr) {
|
||||
send_get_channel_full_query(channel_id, std::move(input_channel), Auto(), "update channel creator");
|
||||
send_get_channel_full_query(channel_id, std::move(input_channel), Auto(), "update channel owner");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11737,9 +11751,9 @@ void ContactsManager::on_chat_update(telegram_api::chat &chat, const char *sourc
|
||||
}
|
||||
|
||||
if (is_creator) {
|
||||
return DialogParticipantStatus::Creator(!has_left);
|
||||
return DialogParticipantStatus::Creator(!has_left, string());
|
||||
} else if (chat.admin_rights_ != nullptr) {
|
||||
return get_dialog_participant_status(false, std::move(chat.admin_rights_));
|
||||
return get_dialog_participant_status(false, std::move(chat.admin_rights_), string());
|
||||
} else if (was_kicked) {
|
||||
return DialogParticipantStatus::Banned(0);
|
||||
} else if (has_left) {
|
||||
@ -11892,9 +11906,9 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel, const char
|
||||
bool is_creator = (channel.flags_ & CHANNEL_FLAG_USER_IS_CREATOR) != 0;
|
||||
|
||||
if (is_creator) {
|
||||
return DialogParticipantStatus::Creator(!has_left);
|
||||
return DialogParticipantStatus::Creator(!has_left, string());
|
||||
} else if (channel.admin_rights_ != nullptr) {
|
||||
return get_dialog_participant_status(false, std::move(channel.admin_rights_));
|
||||
return get_dialog_participant_status(false, std::move(channel.admin_rights_), string());
|
||||
} else if (channel.banned_rights_ != nullptr) {
|
||||
return get_dialog_participant_status(!has_left, std::move(channel.banned_rights_));
|
||||
} else if (has_left) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "td/telegram/DialogParticipant.h"
|
||||
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/misc.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -15,6 +16,10 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
DialogParticipantStatus::DialogParticipantStatus(Type type, uint32 flags, int32 until_date, string rank)
|
||||
: type_(type), flags_(flags), until_date_(until_date), rank_(strip_empty_characters(std::move(rank), 16)) {
|
||||
}
|
||||
|
||||
int32 DialogParticipantStatus::fix_until_date(int32 date) {
|
||||
if (date == std::numeric_limits<int32>::max() || date < 0) {
|
||||
return 0;
|
||||
@ -22,12 +27,13 @@ int32 DialogParticipantStatus::fix_until_date(int32 date) {
|
||||
return date;
|
||||
}
|
||||
|
||||
DialogParticipantStatus DialogParticipantStatus::Creator(bool is_member) {
|
||||
DialogParticipantStatus DialogParticipantStatus::Creator(bool is_member, string rank) {
|
||||
return DialogParticipantStatus(Type::Creator,
|
||||
ALL_ADMINISTRATOR_RIGHTS | ALL_PERMISSION_RIGHTS | (is_member ? IS_MEMBER : 0), 0);
|
||||
ALL_ADMINISTRATOR_RIGHTS | ALL_PERMISSION_RIGHTS | (is_member ? IS_MEMBER : 0), 0,
|
||||
std::move(rank));
|
||||
}
|
||||
|
||||
DialogParticipantStatus DialogParticipantStatus::Administrator(bool can_be_edited, bool can_change_info,
|
||||
DialogParticipantStatus DialogParticipantStatus::Administrator(string rank, bool can_be_edited, 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,
|
||||
@ -44,11 +50,11 @@ DialogParticipantStatus DialogParticipantStatus::Administrator(bool can_be_edite
|
||||
if (flags == 0 || flags == CAN_BE_EDITED) {
|
||||
return Member();
|
||||
}
|
||||
return DialogParticipantStatus(Type::Administrator, IS_MEMBER | ALL_RESTRICTED_RIGHTS | flags, 0);
|
||||
return DialogParticipantStatus(Type::Administrator, IS_MEMBER | ALL_RESTRICTED_RIGHTS | flags, 0, std::move(rank));
|
||||
}
|
||||
|
||||
DialogParticipantStatus DialogParticipantStatus::Member() {
|
||||
return DialogParticipantStatus(Type::Member, IS_MEMBER | ALL_PERMISSION_RIGHTS, 0);
|
||||
return DialogParticipantStatus(Type::Member, IS_MEMBER | ALL_PERMISSION_RIGHTS, 0, string());
|
||||
}
|
||||
|
||||
DialogParticipantStatus DialogParticipantStatus::Restricted(
|
||||
@ -70,26 +76,26 @@ DialogParticipantStatus DialogParticipantStatus::Restricted(
|
||||
if (flags == (IS_MEMBER | ALL_PERMISSION_RIGHTS)) {
|
||||
return Member();
|
||||
}
|
||||
return DialogParticipantStatus(Type::Restricted, flags, fix_until_date(restricted_until_date));
|
||||
return DialogParticipantStatus(Type::Restricted, flags, fix_until_date(restricted_until_date), string());
|
||||
}
|
||||
|
||||
DialogParticipantStatus DialogParticipantStatus::Left() {
|
||||
return DialogParticipantStatus(Type::Left, ALL_PERMISSION_RIGHTS, 0);
|
||||
return DialogParticipantStatus(Type::Left, ALL_PERMISSION_RIGHTS, 0, string());
|
||||
}
|
||||
|
||||
DialogParticipantStatus DialogParticipantStatus::Banned(int32 banned_until_date) {
|
||||
return DialogParticipantStatus(Type::Banned, 0, fix_until_date(banned_until_date));
|
||||
return DialogParticipantStatus(Type::Banned, 0, fix_until_date(banned_until_date), string());
|
||||
}
|
||||
|
||||
DialogParticipantStatus DialogParticipantStatus::GroupAdministrator(bool is_creator) {
|
||||
return DialogParticipantStatus::Administrator(is_creator, true, false, false, true, true, true, true, false);
|
||||
return Administrator(string(), is_creator, true, false, false, true, true, true, true, false);
|
||||
}
|
||||
|
||||
DialogParticipantStatus DialogParticipantStatus::ChannelAdministrator(bool is_creator, bool is_megagroup) {
|
||||
if (is_megagroup) {
|
||||
return DialogParticipantStatus::Administrator(is_creator, true, false, false, true, true, true, true, false);
|
||||
return Administrator(string(), is_creator, true, false, false, true, true, true, true, false);
|
||||
} else {
|
||||
return DialogParticipantStatus::Administrator(is_creator, false, true, true, true, false, true, false, false);
|
||||
return Administrator(string(), is_creator, false, true, true, true, false, true, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,20 +108,20 @@ RestrictedRights DialogParticipantStatus::get_restricted_rights() const {
|
||||
tl_object_ptr<td_api::ChatMemberStatus> DialogParticipantStatus::get_chat_member_status_object() const {
|
||||
switch (type_) {
|
||||
case Type::Creator:
|
||||
return make_tl_object<td_api::chatMemberStatusCreator>(is_member());
|
||||
return td_api::make_object<td_api::chatMemberStatusCreator>(rank_, is_member());
|
||||
case Type::Administrator:
|
||||
return make_tl_object<td_api::chatMemberStatusAdministrator>(
|
||||
can_be_edited(), can_change_info_and_settings(), can_post_messages(), can_edit_messages(),
|
||||
return td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
||||
rank_, can_be_edited(), can_change_info_and_settings(), can_post_messages(), can_edit_messages(),
|
||||
can_delete_messages(), can_invite_users(), can_restrict_members(), can_pin_messages(), can_promote_members());
|
||||
case Type::Member:
|
||||
return make_tl_object<td_api::chatMemberStatusMember>();
|
||||
return td_api::make_object<td_api::chatMemberStatusMember>();
|
||||
case Type::Restricted:
|
||||
return make_tl_object<td_api::chatMemberStatusRestricted>(is_member(), until_date_,
|
||||
get_restricted_rights().get_chat_permissions_object());
|
||||
return td_api::make_object<td_api::chatMemberStatusRestricted>(
|
||||
is_member(), until_date_, get_restricted_rights().get_chat_permissions_object());
|
||||
case Type::Left:
|
||||
return make_tl_object<td_api::chatMemberStatusLeft>();
|
||||
return td_api::make_object<td_api::chatMemberStatusLeft>();
|
||||
case Type::Banned:
|
||||
return make_tl_object<td_api::chatMemberStatusBanned>(until_date_);
|
||||
return td_api::make_object<td_api::chatMemberStatusBanned>(until_date_);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
@ -232,7 +238,7 @@ DialogParticipantStatus DialogParticipantStatus::apply_restrictions(RestrictedRi
|
||||
break;
|
||||
}
|
||||
|
||||
return DialogParticipantStatus(type_, flags, 0);
|
||||
return DialogParticipantStatus(type_, flags, 0, string());
|
||||
}
|
||||
|
||||
void DialogParticipantStatus::update_restrictions() const {
|
||||
@ -254,7 +260,8 @@ void DialogParticipantStatus::update_restrictions() const {
|
||||
}
|
||||
|
||||
bool operator==(const DialogParticipantStatus &lhs, const DialogParticipantStatus &rhs) {
|
||||
return lhs.type_ == rhs.type_ && lhs.flags_ == rhs.flags_ && lhs.until_date_ == rhs.until_date_;
|
||||
return lhs.type_ == rhs.type_ && lhs.flags_ == rhs.flags_ && lhs.until_date_ == rhs.until_date_ &&
|
||||
lhs.rank_ == rhs.rank_;
|
||||
}
|
||||
|
||||
bool operator!=(const DialogParticipantStatus &lhs, const DialogParticipantStatus &rhs) {
|
||||
@ -268,6 +275,9 @@ StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipant
|
||||
if (!status.is_member()) {
|
||||
string_builder << "-non-member";
|
||||
}
|
||||
if (!status.rank_.empty()) {
|
||||
string_builder << " [" << status.rank_ << "]";
|
||||
}
|
||||
return string_builder;
|
||||
case DialogParticipantStatus::Type::Administrator:
|
||||
string_builder << "Administrator: ";
|
||||
@ -295,6 +305,9 @@ StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipant
|
||||
if (status.can_promote_members()) {
|
||||
string_builder << "(promote)";
|
||||
}
|
||||
if (!status.rank_.empty()) {
|
||||
string_builder << " [" << status.rank_ << "]";
|
||||
}
|
||||
return string_builder;
|
||||
case DialogParticipantStatus::Type::Member:
|
||||
return string_builder << "Member";
|
||||
@ -364,14 +377,14 @@ DialogParticipantStatus get_dialog_participant_status(const tl_object_ptr<td_api
|
||||
switch (constructor_id) {
|
||||
case td_api::chatMemberStatusCreator::ID: {
|
||||
auto st = static_cast<const td_api::chatMemberStatusCreator *>(status.get());
|
||||
return DialogParticipantStatus::Creator(st->is_member_);
|
||||
return DialogParticipantStatus::Creator(st->is_member_, st->custom_title_);
|
||||
}
|
||||
case td_api::chatMemberStatusAdministrator::ID: {
|
||||
auto st = static_cast<const td_api::chatMemberStatusAdministrator *>(status.get());
|
||||
return DialogParticipantStatus::Administrator(st->can_be_edited_, st->can_change_info_, st->can_post_messages_,
|
||||
st->can_edit_messages_, st->can_delete_messages_,
|
||||
st->can_invite_users_, st->can_restrict_members_,
|
||||
st->can_pin_messages_, st->can_promote_members_);
|
||||
return DialogParticipantStatus::Administrator(
|
||||
st->custom_title_, st->can_be_edited_, st->can_change_info_, st->can_post_messages_, st->can_edit_messages_,
|
||||
st->can_delete_messages_, st->can_invite_users_, st->can_restrict_members_, st->can_pin_messages_,
|
||||
st->can_promote_members_);
|
||||
}
|
||||
case td_api::chatMemberStatusMember::ID:
|
||||
return DialogParticipantStatus::Member();
|
||||
@ -401,8 +414,9 @@ DialogParticipantStatus get_dialog_participant_status(const tl_object_ptr<td_api
|
||||
}
|
||||
}
|
||||
|
||||
DialogParticipantStatus get_dialog_participant_status(
|
||||
bool can_be_edited, const tl_object_ptr<telegram_api::chatAdminRights> &admin_rights) {
|
||||
DialogParticipantStatus get_dialog_participant_status(bool can_be_edited,
|
||||
const tl_object_ptr<telegram_api::chatAdminRights> &admin_rights,
|
||||
string rank) {
|
||||
bool can_change_info = (admin_rights->flags_ & telegram_api::chatAdminRights::CHANGE_INFO_MASK) != 0;
|
||||
bool can_post_messages = (admin_rights->flags_ & telegram_api::chatAdminRights::POST_MESSAGES_MASK) != 0;
|
||||
bool can_edit_messages = (admin_rights->flags_ & telegram_api::chatAdminRights::EDIT_MESSAGES_MASK) != 0;
|
||||
@ -411,9 +425,9 @@ DialogParticipantStatus get_dialog_participant_status(
|
||||
bool can_restrict_members = (admin_rights->flags_ & telegram_api::chatAdminRights::BAN_USERS_MASK) != 0;
|
||||
bool can_pin_messages = (admin_rights->flags_ & telegram_api::chatAdminRights::PIN_MESSAGES_MASK) != 0;
|
||||
bool can_promote_members = (admin_rights->flags_ & telegram_api::chatAdminRights::ADD_ADMINS_MASK) != 0;
|
||||
return DialogParticipantStatus::Administrator(can_be_edited, can_change_info, can_post_messages, can_edit_messages,
|
||||
can_delete_messages, can_invite_users, can_restrict_members,
|
||||
can_pin_messages, can_promote_members);
|
||||
return DialogParticipantStatus::Administrator(std::move(rank), can_be_edited, can_change_info, can_post_messages,
|
||||
can_edit_messages, can_delete_messages, can_invite_users,
|
||||
can_restrict_members, can_pin_messages, can_promote_members);
|
||||
}
|
||||
|
||||
DialogParticipantStatus get_dialog_participant_status(
|
||||
|
@ -135,7 +135,8 @@ class DialogParticipantStatus {
|
||||
|
||||
static constexpr uint32 IS_MEMBER = 1 << 27;
|
||||
|
||||
// bits 28-31 reserved for Type and until_date flag
|
||||
static constexpr uint32 HAS_RANK = 1u << 14;
|
||||
// bits 28-30 reserved for Type
|
||||
static constexpr int TYPE_SHIFT = 28;
|
||||
static constexpr uint32 HAS_UNTIL_DATE = 1u << 31;
|
||||
|
||||
@ -157,19 +158,18 @@ class DialogParticipantStatus {
|
||||
mutable Type type_;
|
||||
mutable uint32 flags_;
|
||||
mutable int32 until_date_; // restricted and banned only
|
||||
string rank_; // creator and administrator only
|
||||
|
||||
static int32 fix_until_date(int32 date);
|
||||
|
||||
DialogParticipantStatus(Type type, uint32 flags, int32 until_date)
|
||||
: type_(type), flags_(flags), until_date_(until_date) {
|
||||
}
|
||||
DialogParticipantStatus(Type type, uint32 flags, int32 until_date, string rank);
|
||||
|
||||
public:
|
||||
static DialogParticipantStatus Creator(bool is_member);
|
||||
static DialogParticipantStatus Creator(bool is_member, string rank);
|
||||
|
||||
static DialogParticipantStatus Administrator(bool can_be_edited, 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,
|
||||
static DialogParticipantStatus Administrator(string rank, bool can_be_edited, 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_promote_members);
|
||||
|
||||
static DialogParticipantStatus Member();
|
||||
@ -308,16 +308,26 @@ class DialogParticipantStatus {
|
||||
return until_date_;
|
||||
}
|
||||
|
||||
const string &get_rank() const {
|
||||
return rank_;
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
uint32 stored_flags = flags_ | (static_cast<uint32>(type_) << TYPE_SHIFT);
|
||||
if (until_date_ > 0) {
|
||||
stored_flags |= HAS_UNTIL_DATE;
|
||||
}
|
||||
if (!rank_.empty()) {
|
||||
stored_flags |= HAS_RANK;
|
||||
}
|
||||
td::store(stored_flags, storer);
|
||||
if (until_date_ > 0) {
|
||||
td::store(until_date_, storer);
|
||||
}
|
||||
if (!rank_.empty()) {
|
||||
td::store(rank_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
@ -328,6 +338,10 @@ class DialogParticipantStatus {
|
||||
td::parse(until_date_, parser);
|
||||
stored_flags &= ~HAS_UNTIL_DATE;
|
||||
}
|
||||
if ((stored_flags & HAS_RANK) != 0) {
|
||||
td::parse(rank_, parser);
|
||||
stored_flags &= ~HAS_RANK;
|
||||
}
|
||||
type_ = static_cast<Type>(stored_flags >> TYPE_SHIFT);
|
||||
flags_ = stored_flags & ((1 << TYPE_SHIFT) - 1);
|
||||
}
|
||||
@ -423,7 +437,8 @@ DialogParticipantsFilter get_dialog_participants_filter(const tl_object_ptr<td_a
|
||||
DialogParticipantStatus get_dialog_participant_status(const tl_object_ptr<td_api::ChatMemberStatus> &status);
|
||||
|
||||
DialogParticipantStatus get_dialog_participant_status(bool can_be_edited,
|
||||
const tl_object_ptr<telegram_api::chatAdminRights> &admin_rights);
|
||||
const tl_object_ptr<telegram_api::chatAdminRights> &admin_rights,
|
||||
string rank);
|
||||
|
||||
DialogParticipantStatus get_dialog_participant_status(
|
||||
bool is_member, const tl_object_ptr<telegram_api::chatBannedRights> &banned_rights);
|
||||
|
@ -3401,17 +3401,17 @@ class CliClient final : public Actor {
|
||||
} else if (status_str == "banned") {
|
||||
status = td_api::make_object<td_api::chatMemberStatusBanned>(std::numeric_limits<int32>::max());
|
||||
} else if (status_str == "creator") {
|
||||
status = td_api::make_object<td_api::chatMemberStatusCreator>(true);
|
||||
status = td_api::make_object<td_api::chatMemberStatusCreator>("", true);
|
||||
} else if (status_str == "uncreator") {
|
||||
status = td_api::make_object<td_api::chatMemberStatusCreator>(false);
|
||||
status = td_api::make_object<td_api::chatMemberStatusCreator>("", false);
|
||||
} else if (status_str == "admin") {
|
||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(true, true, true, true, true, true, true,
|
||||
true, true);
|
||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("", true, true, true, true, true, true,
|
||||
true, true, true);
|
||||
} else if (status_str == "minadmin") {
|
||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(true, true, false, false, false, false,
|
||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("", true, true, false, false, false, false,
|
||||
false, false, false);
|
||||
} else if (status_str == "unadmin") {
|
||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(true, false, false, false, false, false,
|
||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("", true, false, false, false, false, false,
|
||||
false, false, false);
|
||||
} else if (status_str == "rest") {
|
||||
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
||||
|
Reference in New Issue
Block a user