diff --git a/Telegram/SourceFiles/structs.cpp b/Telegram/SourceFiles/structs.cpp index 4653e8714..58867ab9d 100644 --- a/Telegram/SourceFiles/structs.cpp +++ b/Telegram/SourceFiles/structs.cpp @@ -922,6 +922,15 @@ void ChannelData::setPinnedMessageId(MsgId messageId) { } } +bool ChannelData::canPinMessages() const { + if (isMegagroup()) { + return (adminRights().is_pin_messages()) || amCreator(); + } + // yes, you could pin messages in a channel if you have + // "edit messages" permission. + return (adminRights().is_edit_messages()) || amCreator(); +} + bool ChannelData::canNotEditLastAdmin(not_null user) const { if (mgInfo) { auto i = mgInfo->lastAdmins.constFind(user); diff --git a/Telegram/SourceFiles/structs.h b/Telegram/SourceFiles/structs.h index 1b661e1b4..394d2902f 100644 --- a/Telegram/SourceFiles/structs.h +++ b/Telegram/SourceFiles/structs.h @@ -909,9 +909,6 @@ public: bool canAddAdmins() const { return adminRights().is_add_admins() || amCreator(); } - bool canPinMessages() const { - return adminRights().is_pin_messages() || amCreator(); - } bool canPublish() const { return adminRights().is_post_messages() || amCreator(); } @@ -1004,6 +1001,8 @@ public: setPinnedMessageId(0); } + bool canPinMessages() const; + private: bool canNotEditLastAdmin(not_null user) const;