Add get_cha{t,nnel}_permissions.
GitOrigin-RevId: 7d00023ed7497f89cc3895c9a1d4f267f7332922
This commit is contained in:
parent
2a0f26d24e
commit
5e69f957f3
@ -9149,6 +9149,24 @@ DialogParticipantStatus ContactsManager::get_chat_status(const Chat *c) {
|
|||||||
return c->status;
|
return c->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DialogParticipantStatus ContactsManager::get_chat_permissions(ChatId chat_id) const {
|
||||||
|
auto c = get_chat(chat_id);
|
||||||
|
if (c == nullptr) {
|
||||||
|
return DialogParticipantStatus::Banned(0);
|
||||||
|
}
|
||||||
|
return get_chat_permissions(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogParticipantStatus ContactsManager::get_chat_permissions(const Chat *c) {
|
||||||
|
if (!c->is_active) {
|
||||||
|
return DialogParticipantStatus::Banned(0);
|
||||||
|
}
|
||||||
|
if (c->status.is_administrator() || c->status.is_banned()) {
|
||||||
|
return c->status;
|
||||||
|
}
|
||||||
|
return c->status.apply_restrictions(c->default_permissions);
|
||||||
|
}
|
||||||
|
|
||||||
bool ContactsManager::is_appointed_chat_administrator(ChatId chat_id) const {
|
bool ContactsManager::is_appointed_chat_administrator(ChatId chat_id) const {
|
||||||
auto c = get_chat(chat_id);
|
auto c = get_chat(chat_id);
|
||||||
if (c == nullptr) {
|
if (c == nullptr) {
|
||||||
@ -9202,6 +9220,22 @@ DialogParticipantStatus ContactsManager::get_channel_status(const Channel *c) {
|
|||||||
return c->status;
|
return c->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DialogParticipantStatus ContactsManager::get_channel_permissions(ChannelId channel_id) const {
|
||||||
|
auto c = get_channel(channel_id);
|
||||||
|
if (c == nullptr) {
|
||||||
|
return DialogParticipantStatus::Banned(0);
|
||||||
|
}
|
||||||
|
return get_channel_permissions(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogParticipantStatus ContactsManager::get_channel_permissions(const Channel *c) {
|
||||||
|
c->status.update_restrictions();
|
||||||
|
if (!c->is_megagroup || c->status.is_administrator() || c->status.is_banned()) {
|
||||||
|
return c->status;
|
||||||
|
}
|
||||||
|
return c->status.apply_restrictions(c->default_permissions);
|
||||||
|
}
|
||||||
|
|
||||||
int32 ContactsManager::get_channel_participant_count(ChannelId channel_id) const {
|
int32 ContactsManager::get_channel_participant_count(ChannelId channel_id) const {
|
||||||
auto c = get_channel(channel_id);
|
auto c = get_channel(channel_id);
|
||||||
if (c == nullptr) {
|
if (c == nullptr) {
|
||||||
|
@ -366,6 +366,7 @@ class ContactsManager : public Actor {
|
|||||||
|
|
||||||
bool get_chat_is_active(ChatId chat_id) const;
|
bool get_chat_is_active(ChatId chat_id) const;
|
||||||
DialogParticipantStatus get_chat_status(ChatId chat_id) const;
|
DialogParticipantStatus get_chat_status(ChatId chat_id) const;
|
||||||
|
DialogParticipantStatus get_chat_permissions(ChatId chat_id) const;
|
||||||
bool is_appointed_chat_administrator(ChatId chat_id) const;
|
bool is_appointed_chat_administrator(ChatId chat_id) const;
|
||||||
FileSourceId get_chat_photo_file_source_id(ChatId chat_id);
|
FileSourceId get_chat_photo_file_source_id(ChatId chat_id);
|
||||||
|
|
||||||
@ -384,6 +385,7 @@ class ContactsManager : public Actor {
|
|||||||
ChannelType get_channel_type(ChannelId channel_id) const;
|
ChannelType get_channel_type(ChannelId channel_id) const;
|
||||||
int32 get_channel_date(ChannelId channel_id) const;
|
int32 get_channel_date(ChannelId channel_id) const;
|
||||||
DialogParticipantStatus get_channel_status(ChannelId channel_id) const;
|
DialogParticipantStatus get_channel_status(ChannelId channel_id) const;
|
||||||
|
DialogParticipantStatus get_channel_permissions(ChannelId channel_id) const;
|
||||||
int32 get_channel_participant_count(ChannelId channel_id) const;
|
int32 get_channel_participant_count(ChannelId channel_id) const;
|
||||||
bool get_channel_sign_messages(ChannelId channel_id) const;
|
bool get_channel_sign_messages(ChannelId channel_id) const;
|
||||||
FileSourceId get_channel_photo_file_source_id(ChannelId channel_id);
|
FileSourceId get_channel_photo_file_source_id(ChannelId channel_id);
|
||||||
@ -855,9 +857,11 @@ class ContactsManager : public Actor {
|
|||||||
SecretChat *add_secret_chat(SecretChatId secret_chat_id);
|
SecretChat *add_secret_chat(SecretChatId secret_chat_id);
|
||||||
|
|
||||||
static DialogParticipantStatus get_chat_status(const Chat *c);
|
static DialogParticipantStatus get_chat_status(const Chat *c);
|
||||||
|
static DialogParticipantStatus get_chat_permissions(const Chat *c);
|
||||||
|
|
||||||
static ChannelType get_channel_type(const Channel *c);
|
static ChannelType get_channel_type(const Channel *c);
|
||||||
static DialogParticipantStatus get_channel_status(const Channel *c);
|
static DialogParticipantStatus get_channel_status(const Channel *c);
|
||||||
|
static DialogParticipantStatus get_channel_permissions(const Channel *c);
|
||||||
static bool get_channel_sign_messages(const Channel *c);
|
static bool get_channel_sign_messages(const Channel *c);
|
||||||
|
|
||||||
void set_my_id(UserId my_id);
|
void set_my_id(UserId my_id);
|
||||||
|
@ -32,6 +32,8 @@ class RestrictedRights {
|
|||||||
|
|
||||||
uint32 flags_;
|
uint32 flags_;
|
||||||
|
|
||||||
|
friend class DialogParticipantStatus;
|
||||||
|
|
||||||
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,
|
||||||
@ -187,6 +189,10 @@ class DialogParticipantStatus {
|
|||||||
|
|
||||||
RestrictedRights get_restricted_rights() const;
|
RestrictedRights get_restricted_rights() const;
|
||||||
|
|
||||||
|
DialogParticipantStatus apply_restrictions(RestrictedRights default_restrictions) const {
|
||||||
|
return DialogParticipantStatus(type_, flags_ & (~ALL_RESTRICTED_RIGHTS | default_restrictions.flags_), 0);
|
||||||
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::ChatMemberStatus> get_chat_member_status_object() const;
|
tl_object_ptr<td_api::ChatMemberStatus> get_chat_member_status_object() const;
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::chatAdminRights> get_chat_admin_rights() const;
|
tl_object_ptr<telegram_api::chatAdminRights> get_chat_admin_rights() const;
|
||||||
|
@ -1487,7 +1487,7 @@ static Result<InputMessageContent> create_input_message_content(
|
|||||||
WebPageId web_page_id;
|
WebPageId web_page_id;
|
||||||
bool can_add_web_page_previews =
|
bool can_add_web_page_previews =
|
||||||
dialog_id.get_type() != DialogType::Channel ||
|
dialog_id.get_type() != DialogType::Channel ||
|
||||||
td->contacts_manager_->get_channel_status(dialog_id.get_channel_id()).can_add_web_page_previews();
|
td->contacts_manager_->get_channel_permissions(dialog_id.get_channel_id()).can_add_web_page_previews();
|
||||||
if (!is_bot && !disable_web_page_preview && can_add_web_page_previews) {
|
if (!is_bot && !disable_web_page_preview && can_add_web_page_previews) {
|
||||||
web_page_id = td->web_pages_manager_->get_web_page_by_url(
|
web_page_id = td->web_pages_manager_->get_web_page_by_url(
|
||||||
get_first_url(input_message_text.text.text, input_message_text.text.entities));
|
get_first_url(input_message_text.text.text, input_message_text.text.entities));
|
||||||
|
Reference in New Issue
Block a user