Support can_manage_topics administrator right and chat permission.
This commit is contained in:
parent
62bcac0198
commit
6a16492266
@ -452,7 +452,8 @@ inputChatPhotoAnimation animation:InputFile main_frame_timestamp:double = InputC
|
|||||||
//@can_change_info True, if the user can change the chat title, photo, and other settings
|
//@can_change_info True, if the user can change the chat title, photo, and other settings
|
||||||
//@can_invite_users True, if the user can invite new users to the chat
|
//@can_invite_users True, if the user can invite new users to the chat
|
||||||
//@can_pin_messages True, if the user can pin messages
|
//@can_pin_messages True, if the user can pin messages
|
||||||
chatPermissions can_send_messages:Bool can_send_media_messages:Bool can_send_polls:Bool can_send_other_messages:Bool can_add_web_page_previews:Bool can_change_info:Bool can_invite_users:Bool can_pin_messages:Bool = ChatPermissions;
|
//@can_manage_topics True, if the user can manage topics
|
||||||
|
chatPermissions can_send_messages:Bool can_send_media_messages:Bool can_send_polls:Bool can_send_other_messages:Bool can_add_web_page_previews:Bool can_change_info:Bool can_invite_users:Bool can_pin_messages:Bool can_manage_topics:Bool = ChatPermissions;
|
||||||
|
|
||||||
//@description Describes rights of the administrator
|
//@description Describes rights of the administrator
|
||||||
//@can_manage_chat True, if the administrator can get chat event log, get chat statistics, get message statistics in channels, get channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other privilege; applicable to supergroups and channels only
|
//@can_manage_chat True, if the administrator can get chat event log, get chat statistics, get message statistics in channels, get channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other privilege; applicable to supergroups and channels only
|
||||||
@ -463,10 +464,11 @@ chatPermissions can_send_messages:Bool can_send_media_messages:Bool can_send_pol
|
|||||||
//@can_invite_users True, if the administrator can invite new users to the chat
|
//@can_invite_users True, if the administrator can invite new users to the chat
|
||||||
//@can_restrict_members True, if the administrator can restrict, ban, or unban chat members; always true for channels
|
//@can_restrict_members True, if the administrator can restrict, ban, or unban chat members; always true for channels
|
||||||
//@can_pin_messages True, if the administrator can pin messages; applicable to basic groups and supergroups only
|
//@can_pin_messages True, if the administrator can pin messages; applicable to basic groups and supergroups only
|
||||||
|
//@can_manage_topics True, if the administrator can manage topics; applicable to forum supergroups 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
|
//@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_manage_video_chats True, if the administrator can manage video chats
|
//@can_manage_video_chats True, if the administrator can manage video chats
|
||||||
//@is_anonymous True, if the administrator isn't shown in the chat member list and sends messages anonymously; applicable to supergroups only
|
//@is_anonymous True, if the administrator isn't shown in the chat member list and sends messages anonymously; applicable to supergroups only
|
||||||
chatAdministratorRights can_manage_chat: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 can_manage_video_chats:Bool is_anonymous:Bool = ChatAdministratorRights;
|
chatAdministratorRights can_manage_chat: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:Bool can_promote_members:Bool can_manage_video_chats:Bool is_anonymous:Bool = ChatAdministratorRights;
|
||||||
|
|
||||||
|
|
||||||
//@description Describes an option for buying Telegram Premium to a user
|
//@description Describes an option for buying Telegram Premium to a user
|
||||||
|
@ -4322,7 +4322,7 @@ void ContactsManager::Chat::parse(ParserT &parser) {
|
|||||||
status = DialogParticipantStatus::Member();
|
status = DialogParticipantStatus::Member();
|
||||||
}
|
}
|
||||||
default_permissions = RestrictedRights(true, true, true, true, true, true, true, true, everyone_is_administrator,
|
default_permissions = RestrictedRights(true, true, true, true, true, true, true, true, everyone_is_administrator,
|
||||||
everyone_is_administrator, everyone_is_administrator);
|
everyone_is_administrator, everyone_is_administrator, false);
|
||||||
}
|
}
|
||||||
if (has_default_permissions_version) {
|
if (has_default_permissions_version) {
|
||||||
parse(default_permissions_version, parser);
|
parse(default_permissions_version, parser);
|
||||||
@ -4590,7 +4590,7 @@ void ContactsManager::Channel::parse(ParserT &parser) {
|
|||||||
parse(default_permissions, parser);
|
parse(default_permissions, parser);
|
||||||
} else {
|
} else {
|
||||||
default_permissions =
|
default_permissions =
|
||||||
RestrictedRights(true, true, true, true, true, true, true, true, false, anyone_can_invite, false);
|
RestrictedRights(true, true, true, true, true, true, true, true, false, anyone_can_invite, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (has_cache_version) {
|
if (has_cache_version) {
|
||||||
@ -5196,15 +5196,15 @@ string ContactsManager::get_secret_chat_title(SecretChatId secret_chat_id) const
|
|||||||
RestrictedRights ContactsManager::get_user_default_permissions(UserId user_id) const {
|
RestrictedRights ContactsManager::get_user_default_permissions(UserId user_id) const {
|
||||||
auto u = get_user(user_id);
|
auto u = get_user(user_id);
|
||||||
if (u == nullptr || user_id == get_replies_bot_user_id()) {
|
if (u == nullptr || user_id == get_replies_bot_user_id()) {
|
||||||
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, u != nullptr);
|
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, u != nullptr, false);
|
||||||
}
|
}
|
||||||
return RestrictedRights(true, true, true, true, true, true, true, true, false, false, true);
|
return RestrictedRights(true, true, true, true, true, true, true, true, false, false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
RestrictedRights ContactsManager::get_chat_default_permissions(ChatId chat_id) const {
|
RestrictedRights ContactsManager::get_chat_default_permissions(ChatId chat_id) const {
|
||||||
auto c = get_chat(chat_id);
|
auto c = get_chat(chat_id);
|
||||||
if (c == nullptr) {
|
if (c == nullptr) {
|
||||||
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false);
|
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false);
|
||||||
}
|
}
|
||||||
return c->default_permissions;
|
return c->default_permissions;
|
||||||
}
|
}
|
||||||
@ -5212,7 +5212,7 @@ RestrictedRights ContactsManager::get_chat_default_permissions(ChatId chat_id) c
|
|||||||
RestrictedRights ContactsManager::get_channel_default_permissions(ChannelId channel_id) const {
|
RestrictedRights ContactsManager::get_channel_default_permissions(ChannelId channel_id) const {
|
||||||
auto c = get_channel(channel_id);
|
auto c = get_channel(channel_id);
|
||||||
if (c == nullptr) {
|
if (c == nullptr) {
|
||||||
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false);
|
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false);
|
||||||
}
|
}
|
||||||
return c->default_permissions;
|
return c->default_permissions;
|
||||||
}
|
}
|
||||||
@ -5220,9 +5220,9 @@ RestrictedRights ContactsManager::get_channel_default_permissions(ChannelId chan
|
|||||||
RestrictedRights ContactsManager::get_secret_chat_default_permissions(SecretChatId secret_chat_id) const {
|
RestrictedRights ContactsManager::get_secret_chat_default_permissions(SecretChatId secret_chat_id) const {
|
||||||
auto c = get_secret_chat(secret_chat_id);
|
auto c = get_secret_chat(secret_chat_id);
|
||||||
if (c == nullptr) {
|
if (c == nullptr) {
|
||||||
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false);
|
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false);
|
||||||
}
|
}
|
||||||
return RestrictedRights(true, true, true, true, true, true, true, true, false, false, false);
|
return RestrictedRights(true, true, true, true, true, true, true, true, false, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContactsManager::get_chat_has_protected_content(ChatId chat_id) const {
|
bool ContactsManager::get_chat_has_protected_content(ChatId chat_id) const {
|
||||||
@ -10988,7 +10988,7 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from
|
|||||||
if (c->is_default_permissions_changed) {
|
if (c->is_default_permissions_changed) {
|
||||||
td_->messages_manager_->on_dialog_default_permissions_updated(DialogId(channel_id));
|
td_->messages_manager_->on_dialog_default_permissions_updated(DialogId(channel_id));
|
||||||
if (c->default_permissions !=
|
if (c->default_permissions !=
|
||||||
RestrictedRights(false, false, false, false, false, false, false, false, false, false, false)) {
|
RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false)) {
|
||||||
remove_dialog_suggested_action(SuggestedAction{SuggestedAction::Type::ConvertToGigagroup, DialogId(channel_id)});
|
remove_dialog_suggested_action(SuggestedAction{SuggestedAction::Type::ConvertToGigagroup, DialogId(channel_id)});
|
||||||
}
|
}
|
||||||
c->is_default_permissions_changed = false;
|
c->is_default_permissions_changed = false;
|
||||||
@ -11991,8 +11991,9 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
|
|||||||
SuggestedAction suggested_action(action_str, DialogId(channel_id));
|
SuggestedAction suggested_action(action_str, DialogId(channel_id));
|
||||||
if (!suggested_action.is_empty()) {
|
if (!suggested_action.is_empty()) {
|
||||||
if (suggested_action == SuggestedAction{SuggestedAction::Type::ConvertToGigagroup, DialogId(channel_id)} &&
|
if (suggested_action == SuggestedAction{SuggestedAction::Type::ConvertToGigagroup, DialogId(channel_id)} &&
|
||||||
(c->is_gigagroup || c->default_permissions != RestrictedRights(false, false, false, false, false, false,
|
(c->is_gigagroup ||
|
||||||
false, false, false, false, false))) {
|
c->default_permissions != RestrictedRights(false, false, false, false, false, false, false, false,
|
||||||
|
false, false, false, false))) {
|
||||||
LOG(INFO) << "Skip ConvertToGigagroup suggested action";
|
LOG(INFO) << "Skip ConvertToGigagroup suggested action";
|
||||||
} else {
|
} else {
|
||||||
suggested_actions.push_back(suggested_action);
|
suggested_actions.push_back(suggested_action);
|
||||||
|
@ -802,7 +802,8 @@ class ContactsManager final : public Actor {
|
|||||||
ChannelId migrated_to_channel_id;
|
ChannelId migrated_to_channel_id;
|
||||||
|
|
||||||
DialogParticipantStatus status = DialogParticipantStatus::Banned(0);
|
DialogParticipantStatus status = DialogParticipantStatus::Banned(0);
|
||||||
RestrictedRights default_permissions{false, false, false, false, false, false, false, false, false, false, false};
|
RestrictedRights default_permissions{false, false, false, false, false, false,
|
||||||
|
false, false, false, false, false, false};
|
||||||
|
|
||||||
static constexpr uint32 CACHE_VERSION = 4;
|
static constexpr uint32 CACHE_VERSION = 4;
|
||||||
uint32 cache_version = 0;
|
uint32 cache_version = 0;
|
||||||
@ -873,7 +874,8 @@ class ContactsManager final : public Actor {
|
|||||||
Usernames usernames;
|
Usernames usernames;
|
||||||
vector<RestrictionReason> restriction_reasons;
|
vector<RestrictionReason> restriction_reasons;
|
||||||
DialogParticipantStatus status = DialogParticipantStatus::Banned(0);
|
DialogParticipantStatus status = DialogParticipantStatus::Banned(0);
|
||||||
RestrictedRights default_permissions{false, false, false, false, false, false, false, false, false, false, false};
|
RestrictedRights default_permissions{false, false, false, false, false, false,
|
||||||
|
false, false, false, false, false, false};
|
||||||
int32 date = 0;
|
int32 date = 0;
|
||||||
int32 participant_count = 0;
|
int32 participant_count = 0;
|
||||||
|
|
||||||
|
@ -28,10 +28,10 @@ AdministratorRights::AdministratorRights(const tl_object_ptr<telegram_api::chatA
|
|||||||
if (!rights->other_) {
|
if (!rights->other_) {
|
||||||
LOG(ERROR) << "Receive wrong other flag in " << to_string(rights);
|
LOG(ERROR) << "Receive wrong other flag in " << to_string(rights);
|
||||||
}
|
}
|
||||||
*this =
|
*this = AdministratorRights(rights->anonymous_, rights->other_, rights->change_info_, rights->post_messages_,
|
||||||
AdministratorRights(rights->anonymous_, rights->other_, rights->change_info_, rights->post_messages_,
|
rights->edit_messages_, rights->delete_messages_, rights->invite_users_,
|
||||||
rights->edit_messages_, rights->delete_messages_, rights->invite_users_, rights->ban_users_,
|
rights->ban_users_, rights->pin_messages_, rights->manage_topics_, rights->add_admins_,
|
||||||
rights->pin_messages_, rights->add_admins_, rights->manage_call_, channel_type);
|
rights->manage_call_, channel_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
AdministratorRights::AdministratorRights(const td_api::object_ptr<td_api::chatAdministratorRights> &rights,
|
AdministratorRights::AdministratorRights(const td_api::object_ptr<td_api::chatAdministratorRights> &rights,
|
||||||
@ -43,16 +43,19 @@ AdministratorRights::AdministratorRights(const td_api::object_ptr<td_api::chatAd
|
|||||||
*this = AdministratorRights(rights->is_anonymous_, rights->can_manage_chat_, rights->can_change_info_,
|
*this = AdministratorRights(rights->is_anonymous_, rights->can_manage_chat_, rights->can_change_info_,
|
||||||
rights->can_post_messages_, rights->can_edit_messages_, rights->can_delete_messages_,
|
rights->can_post_messages_, rights->can_edit_messages_, rights->can_delete_messages_,
|
||||||
rights->can_invite_users_, rights->can_restrict_members_, rights->can_pin_messages_,
|
rights->can_invite_users_, rights->can_restrict_members_, rights->can_pin_messages_,
|
||||||
rights->can_promote_members_, rights->can_manage_video_chats_, channel_type);
|
rights->can_manage_topics_, rights->can_promote_members_, rights->can_manage_video_chats_,
|
||||||
|
channel_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
AdministratorRights::AdministratorRights(bool is_anonymous, bool can_manage_dialog, bool can_change_info,
|
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_post_messages, bool can_edit_messages, bool can_delete_messages,
|
||||||
bool can_invite_users, bool can_restrict_members, bool can_pin_messages,
|
bool can_invite_users, bool can_restrict_members, bool can_pin_messages,
|
||||||
bool can_promote_members, bool can_manage_calls, ChannelType channel_type) {
|
bool can_manage_topics, bool can_promote_members, bool can_manage_calls,
|
||||||
|
ChannelType channel_type) {
|
||||||
switch (channel_type) {
|
switch (channel_type) {
|
||||||
case ChannelType::Broadcast:
|
case ChannelType::Broadcast:
|
||||||
can_pin_messages = false;
|
can_pin_messages = false;
|
||||||
|
can_manage_topics = false;
|
||||||
is_anonymous = false;
|
is_anonymous = false;
|
||||||
break;
|
break;
|
||||||
case ChannelType::Megagroup:
|
case ChannelType::Megagroup:
|
||||||
@ -70,6 +73,7 @@ AdministratorRights::AdministratorRights(bool is_anonymous, bool can_manage_dial
|
|||||||
(static_cast<uint32>(can_invite_users) * CAN_INVITE_USERS) |
|
(static_cast<uint32>(can_invite_users) * CAN_INVITE_USERS) |
|
||||||
(static_cast<uint32>(can_restrict_members) * CAN_RESTRICT_MEMBERS) |
|
(static_cast<uint32>(can_restrict_members) * CAN_RESTRICT_MEMBERS) |
|
||||||
(static_cast<uint32>(can_pin_messages) * CAN_PIN_MESSAGES) |
|
(static_cast<uint32>(can_pin_messages) * CAN_PIN_MESSAGES) |
|
||||||
|
(static_cast<uint32>(can_manage_topics) * CAN_MANAGE_TOPICS) |
|
||||||
(static_cast<uint32>(can_promote_members) * CAN_PROMOTE_MEMBERS) |
|
(static_cast<uint32>(can_promote_members) * CAN_PROMOTE_MEMBERS) |
|
||||||
(static_cast<uint32>(can_manage_calls) * CAN_MANAGE_CALLS) |
|
(static_cast<uint32>(can_manage_calls) * CAN_MANAGE_CALLS) |
|
||||||
(static_cast<uint32>(is_anonymous) * IS_ANONYMOUS);
|
(static_cast<uint32>(is_anonymous) * IS_ANONYMOUS);
|
||||||
@ -104,6 +108,9 @@ telegram_api::object_ptr<telegram_api::chatAdminRights> AdministratorRights::get
|
|||||||
if (can_pin_messages()) {
|
if (can_pin_messages()) {
|
||||||
flags |= telegram_api::chatAdminRights::PIN_MESSAGES_MASK;
|
flags |= telegram_api::chatAdminRights::PIN_MESSAGES_MASK;
|
||||||
}
|
}
|
||||||
|
if (can_manage_topics()) {
|
||||||
|
flags |= telegram_api::chatAdminRights::MANAGE_TOPICS_MASK;
|
||||||
|
}
|
||||||
if (can_promote_members()) {
|
if (can_promote_members()) {
|
||||||
flags |= telegram_api::chatAdminRights::ADD_ADMINS_MASK;
|
flags |= telegram_api::chatAdminRights::ADD_ADMINS_MASK;
|
||||||
}
|
}
|
||||||
@ -126,8 +133,8 @@ telegram_api::object_ptr<telegram_api::chatAdminRights> AdministratorRights::get
|
|||||||
td_api::object_ptr<td_api::chatAdministratorRights> AdministratorRights::get_chat_administrator_rights_object() const {
|
td_api::object_ptr<td_api::chatAdministratorRights> AdministratorRights::get_chat_administrator_rights_object() const {
|
||||||
return td_api::make_object<td_api::chatAdministratorRights>(
|
return td_api::make_object<td_api::chatAdministratorRights>(
|
||||||
can_manage_dialog(), can_change_info_and_settings(), can_post_messages(), can_edit_messages(),
|
can_manage_dialog(), 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(),
|
can_delete_messages(), can_invite_users(), can_restrict_members(), can_pin_messages(), can_manage_topics(),
|
||||||
can_manage_calls(), is_anonymous());
|
can_promote_members(), can_manage_calls(), is_anonymous());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const AdministratorRights &lhs, const AdministratorRights &rhs) {
|
bool operator==(const AdministratorRights &lhs, const AdministratorRights &rhs) {
|
||||||
@ -164,6 +171,9 @@ StringBuilder &operator<<(StringBuilder &string_builder, const AdministratorRigh
|
|||||||
if (status.can_pin_messages()) {
|
if (status.can_pin_messages()) {
|
||||||
string_builder << "(pin)";
|
string_builder << "(pin)";
|
||||||
}
|
}
|
||||||
|
if (status.can_manage_topics()) {
|
||||||
|
string_builder << "(manage_topics)";
|
||||||
|
}
|
||||||
if (status.can_promote_members()) {
|
if (status.can_promote_members()) {
|
||||||
string_builder << "(promote)";
|
string_builder << "(promote)";
|
||||||
}
|
}
|
||||||
@ -187,9 +197,10 @@ RestrictedRights::RestrictedRights(const tl_object_ptr<telegram_api::chatBannedR
|
|||||||
LOG_IF(ERROR, rights->until_date_ != std::numeric_limits<int32>::max())
|
LOG_IF(ERROR, rights->until_date_ != std::numeric_limits<int32>::max())
|
||||||
<< "Have until date " << rights->until_date_ << " in restricted rights";
|
<< "Have until date " << rights->until_date_ << " in restricted rights";
|
||||||
|
|
||||||
*this = RestrictedRights(!rights->send_messages_, !rights->send_media_, !rights->send_stickers_, !rights->send_gifs_,
|
*this =
|
||||||
|
RestrictedRights(!rights->send_messages_, !rights->send_media_, !rights->send_stickers_, !rights->send_gifs_,
|
||||||
!rights->send_games_, !rights->send_inline_, !rights->embed_links_, !rights->send_polls_,
|
!rights->send_games_, !rights->send_inline_, !rights->embed_links_, !rights->send_polls_,
|
||||||
!rights->change_info_, !rights->invite_users_, !rights->pin_messages_);
|
!rights->change_info_, !rights->invite_users_, !rights->pin_messages_, !rights->manage_topics_);
|
||||||
}
|
}
|
||||||
|
|
||||||
RestrictedRights::RestrictedRights(const td_api::object_ptr<td_api::chatPermissions> &rights) {
|
RestrictedRights::RestrictedRights(const td_api::object_ptr<td_api::chatPermissions> &rights) {
|
||||||
@ -205,13 +216,15 @@ RestrictedRights::RestrictedRights(const td_api::object_ptr<td_api::chatPermissi
|
|||||||
*this = RestrictedRights(can_send_messages, can_send_media, rights->can_send_other_messages_,
|
*this = RestrictedRights(can_send_messages, can_send_media, rights->can_send_other_messages_,
|
||||||
rights->can_send_other_messages_, rights->can_send_other_messages_,
|
rights->can_send_other_messages_, rights->can_send_other_messages_,
|
||||||
rights->can_send_other_messages_, rights->can_add_web_page_previews_, can_send_polls,
|
rights->can_send_other_messages_, rights->can_add_web_page_previews_, can_send_polls,
|
||||||
rights->can_change_info_, rights->can_invite_users_, rights->can_pin_messages_);
|
rights->can_change_info_, rights->can_invite_users_, rights->can_pin_messages_,
|
||||||
|
rights->can_manage_topics_);
|
||||||
}
|
}
|
||||||
|
|
||||||
RestrictedRights::RestrictedRights(bool can_send_messages, bool can_send_media, bool can_send_stickers,
|
RestrictedRights::RestrictedRights(bool can_send_messages, bool can_send_media, bool can_send_stickers,
|
||||||
bool can_send_animations, bool can_send_games, bool can_use_inline_bots,
|
bool can_send_animations, bool can_send_games, bool can_use_inline_bots,
|
||||||
bool can_add_web_page_previews, bool can_send_polls,
|
bool can_add_web_page_previews, bool can_send_polls,
|
||||||
bool can_change_info_and_settings, bool can_invite_users, bool can_pin_messages) {
|
bool can_change_info_and_settings, bool can_invite_users, bool can_pin_messages,
|
||||||
|
bool can_manage_topics) {
|
||||||
flags_ = (static_cast<uint32>(can_send_messages) * CAN_SEND_MESSAGES) |
|
flags_ = (static_cast<uint32>(can_send_messages) * CAN_SEND_MESSAGES) |
|
||||||
(static_cast<uint32>(can_send_media) * CAN_SEND_MEDIA) |
|
(static_cast<uint32>(can_send_media) * CAN_SEND_MEDIA) |
|
||||||
(static_cast<uint32>(can_send_stickers) * CAN_SEND_STICKERS) |
|
(static_cast<uint32>(can_send_stickers) * CAN_SEND_STICKERS) |
|
||||||
@ -222,14 +235,16 @@ RestrictedRights::RestrictedRights(bool can_send_messages, bool can_send_media,
|
|||||||
(static_cast<uint32>(can_send_polls) * CAN_SEND_POLLS) |
|
(static_cast<uint32>(can_send_polls) * CAN_SEND_POLLS) |
|
||||||
(static_cast<uint32>(can_change_info_and_settings) * CAN_CHANGE_INFO_AND_SETTINGS) |
|
(static_cast<uint32>(can_change_info_and_settings) * CAN_CHANGE_INFO_AND_SETTINGS) |
|
||||||
(static_cast<uint32>(can_invite_users) * CAN_INVITE_USERS) |
|
(static_cast<uint32>(can_invite_users) * CAN_INVITE_USERS) |
|
||||||
(static_cast<uint32>(can_pin_messages) * CAN_PIN_MESSAGES);
|
(static_cast<uint32>(can_pin_messages) * CAN_PIN_MESSAGES) |
|
||||||
|
(static_cast<uint32>(can_manage_topics) * CAN_MANAGE_TOPICS);
|
||||||
}
|
}
|
||||||
|
|
||||||
td_api::object_ptr<td_api::chatPermissions> RestrictedRights::get_chat_permissions_object() const {
|
td_api::object_ptr<td_api::chatPermissions> RestrictedRights::get_chat_permissions_object() const {
|
||||||
return td_api::make_object<td_api::chatPermissions>(
|
return td_api::make_object<td_api::chatPermissions>(
|
||||||
can_send_messages(), can_send_media(), can_send_polls(),
|
can_send_messages(), can_send_media(), can_send_polls(),
|
||||||
can_send_stickers() || can_send_animations() || can_send_games() || can_use_inline_bots(),
|
can_send_stickers() || can_send_animations() || can_send_games() || can_use_inline_bots(),
|
||||||
can_add_web_page_previews(), can_change_info_and_settings(), can_invite_users(), can_pin_messages());
|
can_add_web_page_previews(), can_change_info_and_settings(), can_invite_users(), can_pin_messages(),
|
||||||
|
can_manage_topics());
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::chatBannedRights> RestrictedRights::get_chat_banned_rights() const {
|
tl_object_ptr<telegram_api::chatBannedRights> RestrictedRights::get_chat_banned_rights() const {
|
||||||
@ -267,6 +282,9 @@ tl_object_ptr<telegram_api::chatBannedRights> RestrictedRights::get_chat_banned_
|
|||||||
if (!can_pin_messages()) {
|
if (!can_pin_messages()) {
|
||||||
flags |= telegram_api::chatBannedRights::PIN_MESSAGES_MASK;
|
flags |= telegram_api::chatBannedRights::PIN_MESSAGES_MASK;
|
||||||
}
|
}
|
||||||
|
if (!can_manage_topics()) {
|
||||||
|
flags |= telegram_api::chatBannedRights::MANAGE_TOPICS_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
LOG(INFO) << "Create chat banned rights " << flags;
|
LOG(INFO) << "Create chat banned rights " << flags;
|
||||||
return make_tl_object<telegram_api::chatBannedRights>(
|
return make_tl_object<telegram_api::chatBannedRights>(
|
||||||
@ -318,6 +336,9 @@ StringBuilder &operator<<(StringBuilder &string_builder, const RestrictedRights
|
|||||||
if (!status.can_pin_messages()) {
|
if (!status.can_pin_messages()) {
|
||||||
string_builder << "(pin)";
|
string_builder << "(pin)";
|
||||||
}
|
}
|
||||||
|
if (!status.can_manage_topics()) {
|
||||||
|
string_builder << "(topics)";
|
||||||
|
}
|
||||||
return string_builder;
|
return string_builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,16 +397,16 @@ DialogParticipantStatus DialogParticipantStatus::Banned(int32 banned_until_date)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DialogParticipantStatus DialogParticipantStatus::GroupAdministrator(bool is_creator) {
|
DialogParticipantStatus DialogParticipantStatus::GroupAdministrator(bool is_creator) {
|
||||||
return Administrator(
|
return Administrator(AdministratorRights(false, true, true, false, false, true, true, true, true, false, false, true,
|
||||||
AdministratorRights(false, true, true, false, false, true, true, true, true, false, true, ChannelType::Unknown),
|
ChannelType::Unknown),
|
||||||
string(), is_creator);
|
string(), is_creator);
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogParticipantStatus DialogParticipantStatus::ChannelAdministrator(bool is_creator, bool is_megagroup) {
|
DialogParticipantStatus DialogParticipantStatus::ChannelAdministrator(bool is_creator, bool is_megagroup) {
|
||||||
auto rights = is_megagroup ? AdministratorRights(false, true, true, false, false, true, true, true, true, false,
|
auto rights = is_megagroup ? AdministratorRights(false, true, true, false, false, true, true, true, true, true, false,
|
||||||
false, ChannelType::Megagroup)
|
false, ChannelType::Megagroup)
|
||||||
: AdministratorRights(false, true, false, true, true, true, false, true, false, false,
|
: AdministratorRights(false, true, false, true, true, true, false, true, false, false,
|
||||||
false, ChannelType::Broadcast);
|
false, false, ChannelType::Broadcast);
|
||||||
return Administrator(rights, string(), is_creator);
|
return Administrator(rights, string(), is_creator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +439,7 @@ DialogParticipantStatus::DialogParticipantStatus(bool is_member,
|
|||||||
RestrictedRights DialogParticipantStatus::get_effective_restricted_rights() const {
|
RestrictedRights DialogParticipantStatus::get_effective_restricted_rights() const {
|
||||||
return RestrictedRights(can_send_messages(), can_send_media(), can_send_stickers(), can_send_animations(),
|
return RestrictedRights(can_send_messages(), can_send_media(), can_send_stickers(), can_send_animations(),
|
||||||
can_send_games(), can_use_inline_bots(), can_add_web_page_previews(), can_send_polls(),
|
can_send_games(), can_use_inline_bots(), can_add_web_page_previews(), can_send_polls(),
|
||||||
can_change_info_and_settings(), can_invite_users(), can_pin_messages());
|
can_change_info_and_settings(), can_invite_users(), can_pin_messages(), can_create_topics());
|
||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::ChatMemberStatus> DialogParticipantStatus::get_chat_member_status_object() const {
|
tl_object_ptr<td_api::ChatMemberStatus> DialogParticipantStatus::get_chat_member_status_object() const {
|
||||||
|
@ -33,11 +33,13 @@ class AdministratorRights {
|
|||||||
static constexpr uint32 CAN_PROMOTE_MEMBERS = 1 << 8;
|
static constexpr uint32 CAN_PROMOTE_MEMBERS = 1 << 8;
|
||||||
static constexpr uint32 CAN_MANAGE_CALLS = 1 << 9;
|
static constexpr uint32 CAN_MANAGE_CALLS = 1 << 9;
|
||||||
static constexpr uint32 CAN_MANAGE_DIALOG = 1 << 10;
|
static constexpr uint32 CAN_MANAGE_DIALOG = 1 << 10;
|
||||||
|
static constexpr uint32 CAN_MANAGE_TOPICS = 1 << 11;
|
||||||
static constexpr uint32 IS_ANONYMOUS = 1 << 13;
|
static constexpr uint32 IS_ANONYMOUS = 1 << 13;
|
||||||
|
|
||||||
static constexpr uint32 ALL_ADMINISTRATOR_RIGHTS =
|
static constexpr uint32 ALL_ADMINISTRATOR_RIGHTS = CAN_CHANGE_INFO_AND_SETTINGS | CAN_POST_MESSAGES |
|
||||||
CAN_CHANGE_INFO_AND_SETTINGS | CAN_POST_MESSAGES | CAN_EDIT_MESSAGES | CAN_DELETE_MESSAGES | CAN_INVITE_USERS |
|
CAN_EDIT_MESSAGES | CAN_DELETE_MESSAGES | CAN_INVITE_USERS |
|
||||||
CAN_RESTRICT_MEMBERS | CAN_PIN_MESSAGES | CAN_PROMOTE_MEMBERS | CAN_MANAGE_CALLS | CAN_MANAGE_DIALOG;
|
CAN_RESTRICT_MEMBERS | CAN_PIN_MESSAGES | CAN_MANAGE_TOPICS |
|
||||||
|
CAN_PROMOTE_MEMBERS | CAN_MANAGE_CALLS | CAN_MANAGE_DIALOG;
|
||||||
|
|
||||||
uint32 flags_;
|
uint32 flags_;
|
||||||
|
|
||||||
@ -57,8 +59,8 @@ class AdministratorRights {
|
|||||||
|
|
||||||
AdministratorRights(bool is_anonymous, bool can_manage_dialog, bool can_change_info, bool can_post_messages,
|
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_edit_messages, bool can_delete_messages, bool can_invite_users,
|
||||||
bool can_restrict_members, bool can_pin_messages, bool can_promote_members, bool can_manage_calls,
|
bool can_restrict_members, bool can_pin_messages, bool can_manage_topics,
|
||||||
ChannelType channel_type);
|
bool can_promote_members, bool can_manage_calls, ChannelType channel_type);
|
||||||
|
|
||||||
telegram_api::object_ptr<telegram_api::chatAdminRights> get_chat_admin_rights() const;
|
telegram_api::object_ptr<telegram_api::chatAdminRights> get_chat_admin_rights() const;
|
||||||
|
|
||||||
@ -96,6 +98,10 @@ class AdministratorRights {
|
|||||||
return (flags_ & CAN_PIN_MESSAGES) != 0;
|
return (flags_ & CAN_PIN_MESSAGES) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool can_manage_topics() const {
|
||||||
|
return (flags_ & CAN_MANAGE_TOPICS) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool can_promote_members() const {
|
bool can_promote_members() const {
|
||||||
return (flags_ & CAN_PROMOTE_MEMBERS) != 0;
|
return (flags_ & CAN_PROMOTE_MEMBERS) != 0;
|
||||||
}
|
}
|
||||||
@ -141,9 +147,10 @@ class RestrictedRights {
|
|||||||
static constexpr uint32 CAN_CHANGE_INFO_AND_SETTINGS = 1 << 24;
|
static constexpr uint32 CAN_CHANGE_INFO_AND_SETTINGS = 1 << 24;
|
||||||
static constexpr uint32 CAN_INVITE_USERS = 1 << 25;
|
static constexpr uint32 CAN_INVITE_USERS = 1 << 25;
|
||||||
static constexpr uint32 CAN_PIN_MESSAGES = 1 << 26;
|
static constexpr uint32 CAN_PIN_MESSAGES = 1 << 26;
|
||||||
|
static constexpr uint32 CAN_MANAGE_TOPICS = 1 << 12;
|
||||||
|
|
||||||
static constexpr uint32 ALL_ADMIN_PERMISSION_RIGHTS =
|
static constexpr uint32 ALL_ADMIN_PERMISSION_RIGHTS =
|
||||||
CAN_CHANGE_INFO_AND_SETTINGS | CAN_INVITE_USERS | CAN_PIN_MESSAGES;
|
CAN_CHANGE_INFO_AND_SETTINGS | CAN_INVITE_USERS | CAN_PIN_MESSAGES | CAN_MANAGE_TOPICS;
|
||||||
|
|
||||||
static constexpr uint32 ALL_RESTRICTED_RIGHTS =
|
static constexpr uint32 ALL_RESTRICTED_RIGHTS =
|
||||||
CAN_SEND_MESSAGES | CAN_SEND_MEDIA | CAN_SEND_STICKERS | CAN_SEND_ANIMATIONS | CAN_SEND_GAMES |
|
CAN_SEND_MESSAGES | CAN_SEND_MEDIA | CAN_SEND_STICKERS | CAN_SEND_ANIMATIONS | CAN_SEND_GAMES |
|
||||||
@ -163,7 +170,8 @@ class RestrictedRights {
|
|||||||
|
|
||||||
RestrictedRights(bool can_send_messages, bool can_send_media, bool can_send_stickers, bool can_send_animations,
|
RestrictedRights(bool can_send_messages, bool can_send_media, bool can_send_stickers, bool can_send_animations,
|
||||||
bool can_send_games, bool can_use_inline_bots, bool can_add_web_page_previews, bool can_send_polls,
|
bool can_send_games, bool can_use_inline_bots, bool can_add_web_page_previews, bool can_send_polls,
|
||||||
bool can_change_info_and_settings, bool can_invite_users, bool can_pin_messages);
|
bool can_change_info_and_settings, bool can_invite_users, bool can_pin_messages,
|
||||||
|
bool can_manage_topics);
|
||||||
|
|
||||||
td_api::object_ptr<td_api::chatPermissions> get_chat_permissions_object() const;
|
td_api::object_ptr<td_api::chatPermissions> get_chat_permissions_object() const;
|
||||||
|
|
||||||
@ -181,6 +189,10 @@ class RestrictedRights {
|
|||||||
return (flags_ & CAN_PIN_MESSAGES) != 0;
|
return (flags_ & CAN_PIN_MESSAGES) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool can_manage_topics() const {
|
||||||
|
return (flags_ & CAN_MANAGE_TOPICS) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool can_send_messages() const {
|
bool can_send_messages() const {
|
||||||
return (flags_ & CAN_SEND_MESSAGES) != 0;
|
return (flags_ & CAN_SEND_MESSAGES) != 0;
|
||||||
}
|
}
|
||||||
@ -235,7 +247,7 @@ bool operator!=(const RestrictedRights &lhs, const RestrictedRights &rhs);
|
|||||||
StringBuilder &operator<<(StringBuilder &string_builder, const RestrictedRights &status);
|
StringBuilder &operator<<(StringBuilder &string_builder, const RestrictedRights &status);
|
||||||
|
|
||||||
class DialogParticipantStatus {
|
class DialogParticipantStatus {
|
||||||
// only flags 11 and 12 are unused
|
// all flags are used
|
||||||
static constexpr uint32 HAS_RANK = 1 << 14;
|
static constexpr uint32 HAS_RANK = 1 << 14;
|
||||||
static constexpr uint32 CAN_BE_EDITED = 1 << 15;
|
static constexpr uint32 CAN_BE_EDITED = 1 << 15;
|
||||||
|
|
||||||
@ -343,6 +355,15 @@ class DialogParticipantStatus {
|
|||||||
return get_administrator_rights().can_pin_messages() || get_restricted_rights().can_pin_messages();
|
return get_administrator_rights().can_pin_messages() || get_restricted_rights().can_pin_messages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool can_edit_topics() const {
|
||||||
|
// topics can be edited, only if administrator was explicitly granted the right
|
||||||
|
return get_administrator_rights().can_manage_topics();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool can_create_topics() const {
|
||||||
|
return get_administrator_rights().can_manage_topics() || get_restricted_rights().can_manage_topics();
|
||||||
|
}
|
||||||
|
|
||||||
bool can_promote_members() const {
|
bool can_promote_members() const {
|
||||||
return get_administrator_rights().can_promote_members();
|
return get_administrator_rights().can_promote_members();
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,7 @@ static AdministratorRights get_administrator_rights(Slice rights, bool for_chann
|
|||||||
bool can_invite_users = false;
|
bool can_invite_users = false;
|
||||||
bool can_restrict_members = false;
|
bool can_restrict_members = false;
|
||||||
bool can_pin_messages = false;
|
bool can_pin_messages = false;
|
||||||
|
bool can_manage_topics = false;
|
||||||
bool can_promote_members = false;
|
bool can_promote_members = false;
|
||||||
bool can_manage_calls = false;
|
bool can_manage_calls = false;
|
||||||
bool is_anonymous = false;
|
bool is_anonymous = false;
|
||||||
@ -108,6 +109,8 @@ static AdministratorRights get_administrator_rights(Slice rights, bool for_chann
|
|||||||
can_invite_users = true;
|
can_invite_users = true;
|
||||||
} else if (right == "pin_messages") {
|
} else if (right == "pin_messages") {
|
||||||
can_pin_messages = true;
|
can_pin_messages = true;
|
||||||
|
} else if (right == "manage_topics") {
|
||||||
|
can_manage_topics = true;
|
||||||
} else if (right == "promote_members") {
|
} else if (right == "promote_members") {
|
||||||
can_promote_members = true;
|
can_promote_members = true;
|
||||||
} else if (right == "manage_video_chats") {
|
} else if (right == "manage_video_chats") {
|
||||||
@ -120,7 +123,7 @@ static AdministratorRights get_administrator_rights(Slice rights, bool for_chann
|
|||||||
}
|
}
|
||||||
return AdministratorRights(is_anonymous, can_manage_dialog, can_change_info, can_post_messages, can_edit_messages,
|
return AdministratorRights(is_anonymous, can_manage_dialog, can_change_info, can_post_messages, can_edit_messages,
|
||||||
can_delete_messages, can_invite_users, can_restrict_members, can_pin_messages,
|
can_delete_messages, can_invite_users, can_restrict_members, can_pin_messages,
|
||||||
can_promote_members, can_manage_calls,
|
can_manage_topics, can_promote_members, can_manage_calls,
|
||||||
for_channel ? ChannelType::Broadcast : ChannelType::Megagroup);
|
for_channel ? ChannelType::Broadcast : ChannelType::Megagroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33678,7 +33678,7 @@ RestrictedRights MessagesManager::get_dialog_default_permissions(DialogId dialog
|
|||||||
case DialogType::None:
|
case DialogType::None:
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false);
|
return RestrictedRights(false, false, false, false, false, false, false, false, false, false, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1435,10 +1435,11 @@ class CliClient final : public Actor {
|
|||||||
static td_api::object_ptr<td_api::chatAdministratorRights> as_chat_administrator_rights(
|
static td_api::object_ptr<td_api::chatAdministratorRights> as_chat_administrator_rights(
|
||||||
bool can_manage_chat, bool can_change_info, bool can_post_messages, bool can_edit_messages,
|
bool can_manage_chat, 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_delete_messages, bool can_invite_users, bool can_restrict_members, bool can_pin_messages,
|
||||||
bool can_promote_members, bool can_manage_video_chats, bool is_anonymous) {
|
bool can_manage_topics, bool can_promote_members, bool can_manage_video_chats, bool is_anonymous) {
|
||||||
return td_api::make_object<td_api::chatAdministratorRights>(
|
return td_api::make_object<td_api::chatAdministratorRights>(
|
||||||
can_manage_chat, can_change_info, can_post_messages, can_edit_messages, can_delete_messages, can_invite_users,
|
can_manage_chat, can_change_info, can_post_messages, can_edit_messages, can_delete_messages, can_invite_users,
|
||||||
can_restrict_members, can_pin_messages, can_promote_members, can_manage_video_chats, is_anonymous);
|
can_restrict_members, can_pin_messages, can_manage_topics, can_promote_members, can_manage_video_chats,
|
||||||
|
is_anonymous);
|
||||||
}
|
}
|
||||||
|
|
||||||
static td_api::object_ptr<td_api::TopChatCategory> as_top_chat_category(MutableSlice category) {
|
static td_api::object_ptr<td_api::TopChatCategory> as_top_chat_category(MutableSlice category) {
|
||||||
@ -4340,11 +4341,12 @@ class CliClient final : public Actor {
|
|||||||
ChatId chat_id;
|
ChatId chat_id;
|
||||||
string permissions;
|
string permissions;
|
||||||
get_args(args, chat_id, permissions);
|
get_args(args, chat_id, permissions);
|
||||||
if (permissions.size() == 8) {
|
if (permissions.size() == 9) {
|
||||||
auto &s = permissions;
|
auto &s = permissions;
|
||||||
send_request(td_api::make_object<td_api::setChatPermissions>(
|
send_request(td_api::make_object<td_api::setChatPermissions>(
|
||||||
chat_id, td_api::make_object<td_api::chatPermissions>(s[0] == '1', s[1] == '1', s[2] == '1', s[3] == '1',
|
chat_id, td_api::make_object<td_api::chatPermissions>(s[0] == '1', s[1] == '1', s[2] == '1', s[3] == '1',
|
||||||
s[4] == '1', s[5] == '1', s[6] == '1', s[7] == '1')));
|
s[4] == '1', s[5] == '1', s[6] == '1', s[7] == '1',
|
||||||
|
s[8] == '1')));
|
||||||
} else {
|
} else {
|
||||||
LOG(ERROR) << "Wrong permissions size, expected 8";
|
LOG(ERROR) << "Wrong permissions size, expected 8";
|
||||||
}
|
}
|
||||||
@ -4423,47 +4425,54 @@ class CliClient final : public Actor {
|
|||||||
} else if (status_str == "anonadmin") {
|
} else if (status_str == "anonadmin") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
||||||
"anon", true,
|
"anon", true,
|
||||||
as_chat_administrator_rights(true, true, true, true, true, true, true, true, true, true, true));
|
as_chat_administrator_rights(true, true, true, true, true, true, true, true, true, true, true, true));
|
||||||
} else if (status_str == "anon") {
|
} else if (status_str == "anon") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
||||||
"anon", false,
|
"anon", false,
|
||||||
as_chat_administrator_rights(false, false, false, false, false, false, false, false, false, false, true));
|
as_chat_administrator_rights(false, false, false, false, false, false, false, false, false, false, false,
|
||||||
|
true));
|
||||||
} else if (status_str == "addadmin") {
|
} else if (status_str == "addadmin") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
||||||
"anon", false,
|
"anon", false,
|
||||||
as_chat_administrator_rights(false, false, false, false, false, false, false, false, true, false, false));
|
as_chat_administrator_rights(false, false, false, false, false, false, false, false, false, true, false,
|
||||||
|
false));
|
||||||
} else if (status_str == "calladmin") {
|
} else if (status_str == "calladmin") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
||||||
"anon", false,
|
"anon", false,
|
||||||
as_chat_administrator_rights(false, false, false, false, false, false, false, false, false, true, false));
|
as_chat_administrator_rights(false, false, false, false, false, false, false, false, false, false, true,
|
||||||
|
false));
|
||||||
} else if (status_str == "admin") {
|
} else if (status_str == "admin") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
||||||
"", true, as_chat_administrator_rights(false, true, true, true, true, true, true, true, true, true, false));
|
"", true,
|
||||||
|
as_chat_administrator_rights(false, true, true, true, true, true, true, true, true, true, true, false));
|
||||||
} else if (status_str == "adminq") {
|
} else if (status_str == "adminq") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
||||||
"title", true,
|
"title", true,
|
||||||
as_chat_administrator_rights(false, true, true, true, true, true, true, true, true, true, false));
|
as_chat_administrator_rights(false, true, true, true, true, true, true, true, true, true, true, false));
|
||||||
} else if (status_str == "minadmin") {
|
} else if (status_str == "minadmin") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
||||||
"", true,
|
"", true,
|
||||||
as_chat_administrator_rights(true, false, false, false, false, false, false, false, false, false, false));
|
as_chat_administrator_rights(true, false, false, false, false, false, false, false, false, false, false,
|
||||||
|
false));
|
||||||
} else if (status_str == "unadmin") {
|
} else if (status_str == "unadmin") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("", true, nullptr);
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("", true, nullptr);
|
||||||
} else if (status_str == "rest") {
|
} else if (status_str == "rest") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
||||||
true, static_cast<int32>(120 + std::time(nullptr)),
|
true, static_cast<int32>(120 + std::time(nullptr)),
|
||||||
td_api::make_object<td_api::chatPermissions>(false, false, false, false, false, false, false, false));
|
td_api::make_object<td_api::chatPermissions>(false, false, false, false, false, false, false, false,
|
||||||
|
false));
|
||||||
} else if (status_str == "restkick") {
|
} else if (status_str == "restkick") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
||||||
false, static_cast<int32>(120 + std::time(nullptr)),
|
false, static_cast<int32>(120 + std::time(nullptr)),
|
||||||
td_api::make_object<td_api::chatPermissions>(true, false, false, false, false, false, false, false));
|
td_api::make_object<td_api::chatPermissions>(true, false, false, false, false, false, false, false, false));
|
||||||
} else if (status_str == "restunkick") {
|
} else if (status_str == "restunkick") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
||||||
true, static_cast<int32>(120 + std::time(nullptr)),
|
true, static_cast<int32>(120 + std::time(nullptr)),
|
||||||
td_api::make_object<td_api::chatPermissions>(true, false, false, false, false, false, false, false));
|
td_api::make_object<td_api::chatPermissions>(true, false, false, false, false, false, false, false, false));
|
||||||
} else if (status_str == "unrest") {
|
} else if (status_str == "unrest") {
|
||||||
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
||||||
true, 0, td_api::make_object<td_api::chatPermissions>(true, true, true, true, true, true, true, true));
|
true, 0,
|
||||||
|
td_api::make_object<td_api::chatPermissions>(true, true, true, true, true, true, true, true, true));
|
||||||
}
|
}
|
||||||
if (status != nullptr) {
|
if (status != nullptr) {
|
||||||
send_request(
|
send_request(
|
||||||
|
@ -100,11 +100,12 @@ static void parse_internal_link(const td::string &url, td::td_api::object_ptr<td
|
|||||||
TEST(Link, parse_internal_link) {
|
TEST(Link, parse_internal_link) {
|
||||||
auto chat_administrator_rights = [](bool can_manage_chat, bool can_change_info, bool can_post_messages,
|
auto chat_administrator_rights = [](bool can_manage_chat, bool can_change_info, bool can_post_messages,
|
||||||
bool can_edit_messages, bool can_delete_messages, bool can_invite_users,
|
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 can_restrict_members, bool can_pin_messages, bool can_manage_topics,
|
||||||
bool can_manage_video_chats, bool is_anonymous) {
|
bool can_promote_members, bool can_manage_video_chats, bool is_anonymous) {
|
||||||
return td::td_api::make_object<td::td_api::chatAdministratorRights>(
|
return td::td_api::make_object<td::td_api::chatAdministratorRights>(
|
||||||
can_manage_chat, can_change_info, can_post_messages, can_edit_messages, can_delete_messages, can_invite_users,
|
can_manage_chat, can_change_info, can_post_messages, can_edit_messages, can_delete_messages, can_invite_users,
|
||||||
can_restrict_members, can_pin_messages, can_promote_members, can_manage_video_chats, is_anonymous);
|
can_restrict_members, can_pin_messages, can_manage_topics, can_promote_members, can_manage_video_chats,
|
||||||
|
is_anonymous);
|
||||||
};
|
};
|
||||||
auto target_chat_chosen = [](bool allow_users, bool allow_bots, bool allow_groups, bool allow_channels) {
|
auto target_chat_chosen = [](bool allow_users, bool allow_bots, bool allow_groups, bool allow_channels) {
|
||||||
return td::td_api::make_object<td::td_api::targetChatChosen>(allow_users, allow_bots, allow_groups, allow_channels);
|
return td::td_api::make_object<td::td_api::targetChatChosen>(allow_users, allow_bots, allow_groups, allow_channels);
|
||||||
@ -795,24 +796,25 @@ TEST(Link, parse_internal_link) {
|
|||||||
parse_internal_link("tg:resolve?domain=username&startgroup=1&admin=delete_messages+anonymous",
|
parse_internal_link("tg:resolve?domain=username&startgroup=1&admin=delete_messages+anonymous",
|
||||||
bot_start_in_group("username", "1",
|
bot_start_in_group("username", "1",
|
||||||
chat_administrator_rights(true, false, false, false, true, false, false, false,
|
chat_administrator_rights(true, false, false, false, true, false, false, false,
|
||||||
false, false, true)));
|
false, false, false, true)));
|
||||||
parse_internal_link(
|
parse_internal_link(
|
||||||
"tg:resolve?domain=username&startgroup&admin=manage_chat+change_info+post_messages+edit_messages+delete_messages+"
|
"tg:resolve?domain=username&startgroup&admin=manage_chat+change_info+post_messages+edit_messages+delete_messages+"
|
||||||
"invite_users+restrict_members+pin_messages+promote_members+manage_video_chats+anonymous",
|
"invite_users+restrict_members+pin_messages+manage_topics+promote_members+manage_video_chats+anonymous",
|
||||||
bot_start_in_group(
|
bot_start_in_group(
|
||||||
"username", "",
|
"username", "",
|
||||||
chat_administrator_rights(true, true, false, false, true, true, true, true, true, true, true)));
|
chat_administrator_rights(true, true, false, false, true, true, true, true, true, true, true, true)));
|
||||||
|
|
||||||
parse_internal_link("tg:resolve?domain=username&startchannel", public_chat("username"));
|
parse_internal_link("tg:resolve?domain=username&startchannel", public_chat("username"));
|
||||||
parse_internal_link("tg:resolve?domain=username&startchannel&admin=", public_chat("username"));
|
parse_internal_link("tg:resolve?domain=username&startchannel&admin=", public_chat("username"));
|
||||||
parse_internal_link("tg:resolve?domain=username&startchannel&admin=post_messages",
|
parse_internal_link(
|
||||||
bot_add_to_channel("username", chat_administrator_rights(true, false, true, false, false, false,
|
"tg:resolve?domain=username&startchannel&admin=post_messages",
|
||||||
true, false, false, false, false)));
|
bot_add_to_channel("username", chat_administrator_rights(true, false, true, false, false, false, true, false,
|
||||||
|
false, false, false, false)));
|
||||||
parse_internal_link(
|
parse_internal_link(
|
||||||
"tg:resolve?domain=username&startchannel&admin=manage_chat+change_info+post_messages+edit_messages+delete_"
|
"tg:resolve?domain=username&startchannel&admin=manage_chat+change_info+post_messages+edit_messages+delete_"
|
||||||
"messages+invite_users+restrict_members+pin_messages+promote_members+manage_video_chats+anonymous",
|
"messages+invite_users+restrict_members+pin_messages+manage_topics+promote_members+manage_video_chats+anonymous",
|
||||||
bot_add_to_channel(
|
bot_add_to_channel("username", chat_administrator_rights(true, true, true, true, true, true, true, false, false,
|
||||||
"username", chat_administrator_rights(true, true, true, true, true, true, true, false, true, true, false)));
|
true, true, false)));
|
||||||
|
|
||||||
parse_internal_link("t.me/username/0/a//s/as?startgroup=", bot_start_in_group("username", "", nullptr));
|
parse_internal_link("t.me/username/0/a//s/as?startgroup=", bot_start_in_group("username", "", nullptr));
|
||||||
parse_internal_link("t.me/username/aasdas?test=1&startgroup=#12312", bot_start_in_group("username", "", nullptr));
|
parse_internal_link("t.me/username/aasdas?test=1&startgroup=#12312", bot_start_in_group("username", "", nullptr));
|
||||||
@ -830,26 +832,27 @@ TEST(Link, parse_internal_link) {
|
|||||||
parse_internal_link("t.me/username?startgroup=1&admin=delete_messages+anonymous",
|
parse_internal_link("t.me/username?startgroup=1&admin=delete_messages+anonymous",
|
||||||
bot_start_in_group("username", "1",
|
bot_start_in_group("username", "1",
|
||||||
chat_administrator_rights(true, false, false, false, true, false, false, false,
|
chat_administrator_rights(true, false, false, false, true, false, false, false,
|
||||||
false, false, true)));
|
false, false, false, true)));
|
||||||
parse_internal_link(
|
parse_internal_link(
|
||||||
"t.me/"
|
"t.me/"
|
||||||
"username?startgroup&admin=manage_chat+change_info+post_messages+edit_messages+delete_messages+invite_users+"
|
"username?startgroup&admin=manage_chat+change_info+post_messages+edit_messages+delete_messages+invite_users+"
|
||||||
"restrict_members+pin_messages+promote_members+manage_video_chats+anonymous",
|
"restrict_members+pin_messages+manage_topics+promote_members+manage_video_chats+anonymous",
|
||||||
bot_start_in_group(
|
bot_start_in_group(
|
||||||
"username", "",
|
"username", "",
|
||||||
chat_administrator_rights(true, true, false, false, true, true, true, true, true, true, true)));
|
chat_administrator_rights(true, true, false, false, true, true, true, true, true, true, true, true)));
|
||||||
|
|
||||||
parse_internal_link("t.me/username?startchannel", public_chat("username"));
|
parse_internal_link("t.me/username?startchannel", public_chat("username"));
|
||||||
parse_internal_link("t.me/username?startchannel&admin=", public_chat("username"));
|
parse_internal_link("t.me/username?startchannel&admin=", public_chat("username"));
|
||||||
parse_internal_link("t.me/username?startchannel&admin=post_messages",
|
parse_internal_link(
|
||||||
bot_add_to_channel("username", chat_administrator_rights(true, false, true, false, false, false,
|
"t.me/username?startchannel&admin=post_messages",
|
||||||
true, false, false, false, false)));
|
bot_add_to_channel("username", chat_administrator_rights(true, false, true, false, false, false, true, false,
|
||||||
|
false, false, false, false)));
|
||||||
parse_internal_link(
|
parse_internal_link(
|
||||||
"t.me/"
|
"t.me/"
|
||||||
"username?startchannel&admin=manage_chat+change_info+post_messages+edit_messages+delete_messages+invite_users+"
|
"username?startchannel&admin=manage_chat+change_info+post_messages+edit_messages+delete_messages+invite_users+"
|
||||||
"restrict_members+pin_messages+promote_members+manage_video_chats+anonymous",
|
"restrict_members+pin_messages+manage_topics+promote_members+manage_video_chats+anonymous",
|
||||||
bot_add_to_channel(
|
bot_add_to_channel("username", chat_administrator_rights(true, true, true, true, true, true, true, false, false,
|
||||||
"username", chat_administrator_rights(true, true, true, true, true, true, true, false, true, true, false)));
|
true, true, false)));
|
||||||
|
|
||||||
parse_internal_link("tg:resolve?domain=username&game=aasdasd", game("username", "aasdasd"));
|
parse_internal_link("tg:resolve?domain=username&game=aasdasd", game("username", "aasdasd"));
|
||||||
parse_internal_link("TG://resolve?domain=username&game=", public_chat("username"));
|
parse_internal_link("TG://resolve?domain=username&game=", public_chat("username"));
|
||||||
|
Loading…
Reference in New Issue
Block a user