From 547720ccf6d4c2b9a364ac924fad1e855d0690f1 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 8 Mar 2019 04:04:30 +0300 Subject: [PATCH] Remove export dialog invite link admin right. GitOrigin-RevId: 0960bf0f6ecac10e714769089a0fbda347b459d8 --- td/generate/scheme/td_api.tl | 2 +- td/telegram/ContactsManager.cpp | 4 ++-- td/telegram/DialogParticipant.cpp | 27 ++++++++++----------------- td/telegram/DialogParticipant.h | 16 ++++++---------- 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index e889f20e..ddd063a0 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3277,7 +3277,7 @@ readFilePart file_id:int32 offset:int32 count:int32 = FilePart; deleteFile file_id:int32 = Ok; -//@description Generates a new invite link for a chat; the previously generated link is revoked. Available for basic groups, supergroups, and channels. In basic groups this can be called only by the group's creator; in supergroups and channels this requires appropriate administrator rights @chat_id Chat identifier +//@description Generates a new invite link for a chat; the previously generated link is revoked. Available for basic groups, supergroups, and channels. Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels @chat_id Chat identifier generateChatInviteLink chat_id:int53 = ChatInviteLink; //@description Checks the validity of an invite link for a chat and returns information about the corresponding chat @invite_link Invite link to be checked; should begin with "https://t.me/joinchat/", "https://telegram.me/joinchat/", or "https://telegram.dog/joinchat/" diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 5ccf726f..a8c367fc 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -4498,7 +4498,7 @@ void ContactsManager::export_chat_invite_link(ChatId chat_id, Promise &&pr return promise.set_error(Status::Error(3, "Chat is deactivated")); } - if (!get_chat_status(c).can_export_dialog_invite_link()) { + if (!get_chat_status(c).can_invite_users()) { return promise.set_error(Status::Error(3, "Not enough rights to export chat invite link")); } @@ -4511,7 +4511,7 @@ void ContactsManager::export_channel_invite_link(ChannelId channel_id, Promise(can_be_edited) * CAN_BE_EDITED) | @@ -39,7 +38,6 @@ DialogParticipantStatus DialogParticipantStatus::Administrator(bool can_be_edite (static_cast(can_edit_messages) * CAN_EDIT_MESSAGES) | (static_cast(can_delete_messages) * CAN_DELETE_MESSAGES) | (static_cast(can_invite_users) * CAN_INVITE_USERS) | - (static_cast(can_export_dialog_invite_link) * CAN_EXPORT_DIALOG_INVITE_LINK) | (static_cast(can_restrict_members) * CAN_RESTRICT_MEMBERS) | (static_cast(can_pin_messages) * CAN_PIN_MESSAGES) | (static_cast(can_promote_members) * CAN_PROMOTE_MEMBERS); @@ -81,15 +79,14 @@ DialogParticipantStatus DialogParticipantStatus::Banned(int32 banned_until_date) } DialogParticipantStatus DialogParticipantStatus::GroupAdministrator(bool is_creator) { - return DialogParticipantStatus::Administrator(is_creator, true, false, false, true, true, false, true, true, false); + return DialogParticipantStatus::Administrator(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, false, true, true, false); + return DialogParticipantStatus::Administrator(is_creator, true, false, false, true, true, true, true, false); } else { - return DialogParticipantStatus::Administrator(is_creator, false, true, true, true, false, false, true, false, - false); + return DialogParticipantStatus::Administrator(is_creator, false, true, true, true, false, true, false, false); } } @@ -100,8 +97,7 @@ tl_object_ptr DialogParticipantStatus::get_chat_member case Type::Administrator: return make_tl_object( can_be_edited(), can_change_info_and_settings(), can_post_messages(), can_edit_messages(), - can_delete_messages(), can_invite_users() || can_export_dialog_invite_link(), can_restrict_members(), - can_pin_messages(), can_promote_members()); + can_delete_messages(), can_invite_users(), can_restrict_members(), can_pin_messages(), can_promote_members()); case Type::Member: return make_tl_object(); case Type::Restricted: @@ -135,8 +131,6 @@ tl_object_ptr DialogParticipantStatus::get_cha } if (can_invite_users()) { flags |= telegram_api::channelAdminRights::INVITE_USERS_MASK; - } - if (can_export_dialog_invite_link()) { flags |= telegram_api::channelAdminRights::INVITE_LINK_MASK; } if (can_restrict_members()) { @@ -309,10 +303,10 @@ DialogParticipantStatus get_dialog_participant_status(const tl_object_ptr(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_invite_users_, st->can_restrict_members_, - st->can_pin_messages_, st->can_promote_members_); + 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_); } case td_api::chatMemberStatusMember::ID: return DialogParticipantStatus::Member(); @@ -344,13 +338,12 @@ DialogParticipantStatus get_dialog_participant_status( bool can_edit_messages = (admin_rights->flags_ & telegram_api::channelAdminRights::EDIT_MESSAGES_MASK) != 0; bool can_delete_messages = (admin_rights->flags_ & telegram_api::channelAdminRights::DELETE_MESSAGES_MASK) != 0; bool can_invite_users = (admin_rights->flags_ & telegram_api::channelAdminRights::INVITE_USERS_MASK) != 0; - bool can_export_invite_link = (admin_rights->flags_ & telegram_api::channelAdminRights::INVITE_LINK_MASK) != 0; bool can_restrict_members = (admin_rights->flags_ & telegram_api::channelAdminRights::BAN_USERS_MASK) != 0; bool can_pin_messages = (admin_rights->flags_ & telegram_api::channelAdminRights::PIN_MESSAGES_MASK) != 0; bool can_promote_members = (admin_rights->flags_ & telegram_api::channelAdminRights::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_export_invite_link, - can_restrict_members, can_pin_messages, can_promote_members); + can_delete_messages, can_invite_users, can_restrict_members, + can_pin_messages, can_promote_members); } DialogParticipantStatus get_dialog_participant_status( diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h index 272332cf..82b36c79 100644 --- a/td/telegram/DialogParticipant.h +++ b/td/telegram/DialogParticipant.h @@ -23,7 +23,7 @@ class DialogParticipantStatus { static constexpr uint32 CAN_EDIT_MESSAGES = 1 << 2; static constexpr uint32 CAN_DELETE_MESSAGES = 1 << 3; static constexpr uint32 CAN_INVITE_USERS = 1 << 4; - static constexpr uint32 CAN_EXPORT_DIALOG_INVITE_LINK = 1 << 5; + // static constexpr uint32 CAN_EXPORT_DIALOG_INVITE_LINK = 1 << 5; static constexpr uint32 CAN_RESTRICT_MEMBERS = 1 << 6; static constexpr uint32 CAN_PIN_MESSAGES = 1 << 7; static constexpr uint32 CAN_PROMOTE_MEMBERS = 1 << 8; @@ -44,9 +44,9 @@ class DialogParticipantStatus { static constexpr int TYPE_SHIFT = 28; static constexpr uint32 HAS_UNTIL_DATE = 1u << 31; - static constexpr uint32 ALL_ADMINISTRATOR_RIGHTS = - CAN_CHANGE_INFO_AND_SETTINGS | CAN_POST_MESSAGES | CAN_EDIT_MESSAGES | CAN_DELETE_MESSAGES | CAN_INVITE_USERS | - CAN_EXPORT_DIALOG_INVITE_LINK | CAN_RESTRICT_MEMBERS | CAN_PIN_MESSAGES | CAN_PROMOTE_MEMBERS; + static constexpr uint32 ALL_ADMINISTRATOR_RIGHTS = 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; static constexpr uint32 ALL_RESTRICTED_RIGHTS = CAN_SEND_MESSAGES | CAN_SEND_MEDIA | CAN_SEND_STICKERS | CAN_SEND_ANIMATIONS | CAN_SEND_GAMES | CAN_USE_INLINE_BOTS | @@ -69,8 +69,8 @@ class DialogParticipantStatus { 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_export_dialog_invite_link, bool can_restrict_members, - bool can_pin_messages, bool can_promote_members); + bool can_restrict_members, bool can_pin_messages, + bool can_promote_members); static DialogParticipantStatus Member(); @@ -118,10 +118,6 @@ class DialogParticipantStatus { return (flags_ & CAN_INVITE_USERS) != 0; } - bool can_export_dialog_invite_link() const { - return (flags_ & CAN_EXPORT_DIALOG_INVITE_LINK) != 0; - } - bool can_restrict_members() const { return (flags_ & CAN_RESTRICT_MEMBERS) != 0; }