Fix bot permissions.
GitOrigin-RevId: 86929755cff1673c3404beeff2a6bfbfcb2e2365
This commit is contained in:
parent
e83184f9fc
commit
eed517a2e7
@ -9155,11 +9155,11 @@ DialogParticipantStatus ContactsManager::get_chat_permissions(ChatId chat_id) co
|
||||
return get_chat_permissions(c);
|
||||
}
|
||||
|
||||
DialogParticipantStatus ContactsManager::get_chat_permissions(const Chat *c) {
|
||||
DialogParticipantStatus ContactsManager::get_chat_permissions(const Chat *c) const {
|
||||
if (!c->is_active) {
|
||||
return DialogParticipantStatus::Banned(0);
|
||||
}
|
||||
return c->status.apply_restrictions(c->default_permissions);
|
||||
return c->status.apply_restrictions(c->default_permissions, td_->auth_manager_->is_bot());
|
||||
}
|
||||
|
||||
bool ContactsManager::is_appointed_chat_administrator(ChatId chat_id) const {
|
||||
@ -9223,13 +9223,13 @@ DialogParticipantStatus ContactsManager::get_channel_permissions(ChannelId chann
|
||||
return get_channel_permissions(c);
|
||||
}
|
||||
|
||||
DialogParticipantStatus ContactsManager::get_channel_permissions(const Channel *c) {
|
||||
DialogParticipantStatus ContactsManager::get_channel_permissions(const Channel *c) const {
|
||||
c->status.update_restrictions();
|
||||
if (!c->is_megagroup) {
|
||||
// there is no restrictions in broadcast channels
|
||||
return c->status;
|
||||
}
|
||||
return c->status.apply_restrictions(c->default_permissions);
|
||||
return c->status.apply_restrictions(c->default_permissions, td_->auth_manager_->is_bot());
|
||||
}
|
||||
|
||||
int32 ContactsManager::get_channel_participant_count(ChannelId channel_id) const {
|
||||
|
@ -857,11 +857,11 @@ class ContactsManager : public Actor {
|
||||
SecretChat *add_secret_chat(SecretChatId secret_chat_id);
|
||||
|
||||
static DialogParticipantStatus get_chat_status(const Chat *c);
|
||||
static DialogParticipantStatus get_chat_permissions(const Chat *c);
|
||||
DialogParticipantStatus get_chat_permissions(const Chat *c) const;
|
||||
|
||||
static ChannelType get_channel_type(const Channel *c);
|
||||
static DialogParticipantStatus get_channel_status(const Channel *c);
|
||||
static DialogParticipantStatus get_channel_permissions(const Channel *c);
|
||||
DialogParticipantStatus get_channel_permissions(const Channel *c) const;
|
||||
static bool get_channel_sign_messages(const Channel *c);
|
||||
|
||||
void set_my_id(UserId my_id);
|
||||
|
@ -201,7 +201,8 @@ tl_object_ptr<telegram_api::chatBannedRights> DialogParticipantStatus::get_chat_
|
||||
false /*ignored*/, until_date_);
|
||||
}
|
||||
|
||||
DialogParticipantStatus DialogParticipantStatus::apply_restrictions(RestrictedRights default_restrictions) const {
|
||||
DialogParticipantStatus DialogParticipantStatus::apply_restrictions(RestrictedRights default_restrictions,
|
||||
bool is_bot) const {
|
||||
auto flags = flags_;
|
||||
switch (type_) {
|
||||
case Type::Creator:
|
||||
@ -210,13 +211,18 @@ DialogParticipantStatus DialogParticipantStatus::apply_restrictions(RestrictedRi
|
||||
case Type::Administrator:
|
||||
// administrators aren't affected by restrictions, but if everyone can invite users,
|
||||
// pin messages or change info, they also can do that
|
||||
flags |= default_restrictions.flags_ & ALL_ADMIN_PERMISSION_RIGHTS;
|
||||
if (!is_bot) {
|
||||
flags |= default_restrictions.flags_ & ALL_ADMIN_PERMISSION_RIGHTS;
|
||||
}
|
||||
break;
|
||||
case Type::Member:
|
||||
case Type::Restricted:
|
||||
case Type::Left:
|
||||
// members and restricted are affected by default restrictions
|
||||
flags &= ~ALL_PERMISSION_RIGHTS | default_restrictions.flags_;
|
||||
if (is_bot) {
|
||||
flags &= ~ALL_ADMIN_PERMISSION_RIGHTS;
|
||||
}
|
||||
break;
|
||||
case Type::Banned:
|
||||
// banned can do nothing, even restirctions allows them to do that
|
||||
|
@ -193,7 +193,7 @@ class DialogParticipantStatus {
|
||||
|
||||
RestrictedRights get_restricted_rights() const;
|
||||
|
||||
DialogParticipantStatus apply_restrictions(RestrictedRights default_restrictions) const;
|
||||
DialogParticipantStatus apply_restrictions(RestrictedRights default_restrictions, bool is_bot) const;
|
||||
|
||||
tl_object_ptr<td_api::ChatMemberStatus> get_chat_member_status_object() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user