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);
|
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) {
|
if (!c->is_active) {
|
||||||
return DialogParticipantStatus::Banned(0);
|
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 {
|
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);
|
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();
|
c->status.update_restrictions();
|
||||||
if (!c->is_megagroup) {
|
if (!c->is_megagroup) {
|
||||||
// there is no restrictions in broadcast channels
|
// there is no restrictions in broadcast channels
|
||||||
return c->status;
|
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 {
|
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);
|
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);
|
DialogParticipantStatus get_chat_permissions(const Chat *c) const;
|
||||||
|
|
||||||
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);
|
DialogParticipantStatus get_channel_permissions(const Channel *c) const;
|
||||||
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);
|
||||||
|
@ -201,7 +201,8 @@ tl_object_ptr<telegram_api::chatBannedRights> DialogParticipantStatus::get_chat_
|
|||||||
false /*ignored*/, until_date_);
|
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_;
|
auto flags = flags_;
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case Type::Creator:
|
case Type::Creator:
|
||||||
@ -210,13 +211,18 @@ DialogParticipantStatus DialogParticipantStatus::apply_restrictions(RestrictedRi
|
|||||||
case Type::Administrator:
|
case Type::Administrator:
|
||||||
// administrators aren't affected by restrictions, but if everyone can invite users,
|
// administrators aren't affected by restrictions, but if everyone can invite users,
|
||||||
// pin messages or change info, they also can do that
|
// pin messages or change info, they also can do that
|
||||||
|
if (!is_bot) {
|
||||||
flags |= default_restrictions.flags_ & ALL_ADMIN_PERMISSION_RIGHTS;
|
flags |= default_restrictions.flags_ & ALL_ADMIN_PERMISSION_RIGHTS;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Type::Member:
|
case Type::Member:
|
||||||
case Type::Restricted:
|
case Type::Restricted:
|
||||||
case Type::Left:
|
case Type::Left:
|
||||||
// members and restricted are affected by default restrictions
|
// members and restricted are affected by default restrictions
|
||||||
flags &= ~ALL_PERMISSION_RIGHTS | default_restrictions.flags_;
|
flags &= ~ALL_PERMISSION_RIGHTS | default_restrictions.flags_;
|
||||||
|
if (is_bot) {
|
||||||
|
flags &= ~ALL_ADMIN_PERMISSION_RIGHTS;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Type::Banned:
|
case Type::Banned:
|
||||||
// banned can do nothing, even restirctions allows them to do that
|
// banned can do nothing, even restirctions allows them to do that
|
||||||
|
@ -193,7 +193,7 @@ class DialogParticipantStatus {
|
|||||||
|
|
||||||
RestrictedRights get_restricted_rights() const;
|
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;
|
tl_object_ptr<td_api::ChatMemberStatus> get_chat_member_status_object() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user