Add get_effective_restricted_rights.
This commit is contained in:
parent
07b4f6c16d
commit
d913e6ec0e
@ -313,7 +313,7 @@ DialogParticipantStatus DialogParticipantStatus::ChannelAdministrator(bool is_cr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RestrictedRights DialogParticipantStatus::get_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());
|
||||||
|
@ -135,6 +135,9 @@ class RestrictedRights {
|
|||||||
|
|
||||||
friend class DialogParticipantStatus;
|
friend class DialogParticipantStatus;
|
||||||
|
|
||||||
|
explicit RestrictedRights(int32 flags) : flags_(flags) {
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
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,
|
||||||
@ -210,6 +213,9 @@ 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
|
||||||
|
static constexpr uint32 IS_ANONYMOUS = 1 << 13;
|
||||||
|
static constexpr uint32 HAS_RANK = 1 << 14;
|
||||||
static constexpr uint32 CAN_BE_EDITED = 1 << 15;
|
static constexpr uint32 CAN_BE_EDITED = 1 << 15;
|
||||||
|
|
||||||
static constexpr uint32 CAN_SEND_MESSAGES = 1 << 16;
|
static constexpr uint32 CAN_SEND_MESSAGES = 1 << 16;
|
||||||
@ -226,8 +232,6 @@ class DialogParticipantStatus {
|
|||||||
|
|
||||||
static constexpr uint32 IS_MEMBER = 1 << 27;
|
static constexpr uint32 IS_MEMBER = 1 << 27;
|
||||||
|
|
||||||
static constexpr uint32 IS_ANONYMOUS = 1 << 13;
|
|
||||||
static constexpr uint32 HAS_RANK = 1 << 14;
|
|
||||||
// bits 28-30 reserved for Type
|
// bits 28-30 reserved for Type
|
||||||
static constexpr int TYPE_SHIFT = 28;
|
static constexpr int TYPE_SHIFT = 28;
|
||||||
static constexpr uint32 HAS_UNTIL_DATE = 1u << 31;
|
static constexpr uint32 HAS_UNTIL_DATE = 1u << 31;
|
||||||
@ -252,6 +256,14 @@ class DialogParticipantStatus {
|
|||||||
|
|
||||||
DialogParticipantStatus(Type type, uint32 flags, int32 until_date, string rank);
|
DialogParticipantStatus(Type type, uint32 flags, int32 until_date, string rank);
|
||||||
|
|
||||||
|
AdministratorRights get_administrator_rights() const {
|
||||||
|
return AdministratorRights(flags_);
|
||||||
|
}
|
||||||
|
|
||||||
|
RestrictedRights get_restricted_rights() const {
|
||||||
|
return RestrictedRights(flags_ & ALL_PERMISSION_RIGHTS);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static DialogParticipantStatus Creator(bool is_member, bool is_anonymous, string rank);
|
static DialogParticipantStatus Creator(bool is_member, bool is_anonymous, string rank);
|
||||||
|
|
||||||
@ -280,11 +292,7 @@ class DialogParticipantStatus {
|
|||||||
// legacy rights
|
// legacy rights
|
||||||
static DialogParticipantStatus ChannelAdministrator(bool is_creator, bool is_megagroup);
|
static DialogParticipantStatus ChannelAdministrator(bool is_creator, bool is_megagroup);
|
||||||
|
|
||||||
AdministratorRights get_administrator_rights() const {
|
RestrictedRights get_effective_restricted_rights() const;
|
||||||
return AdministratorRights(flags_);
|
|
||||||
}
|
|
||||||
|
|
||||||
RestrictedRights get_restricted_rights() const;
|
|
||||||
|
|
||||||
DialogParticipantStatus apply_restrictions(RestrictedRights default_restrictions, bool is_bot) const;
|
DialogParticipantStatus apply_restrictions(RestrictedRights default_restrictions, bool is_bot) const;
|
||||||
|
|
||||||
|
@ -2489,9 +2489,10 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
|
|||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
return td->contacts_manager_->get_user_default_permissions(dialog_id.get_user_id());
|
return td->contacts_manager_->get_user_default_permissions(dialog_id.get_user_id());
|
||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
return td->contacts_manager_->get_chat_permissions(dialog_id.get_chat_id()).get_restricted_rights();
|
return td->contacts_manager_->get_chat_permissions(dialog_id.get_chat_id()).get_effective_restricted_rights();
|
||||||
case DialogType::Channel:
|
case DialogType::Channel:
|
||||||
return td->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id()).get_restricted_rights();
|
return td->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id())
|
||||||
|
.get_effective_restricted_rights();
|
||||||
case DialogType::SecretChat:
|
case DialogType::SecretChat:
|
||||||
return td->contacts_manager_->get_secret_chat_default_permissions(dialog_id.get_secret_chat_id());
|
return td->contacts_manager_->get_secret_chat_default_permissions(dialog_id.get_secret_chat_id());
|
||||||
case DialogType::None:
|
case DialogType::None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user