Fix channel message pinning for channel moderators

The way of fixing this is weird and is a natural clutch. But we have to
live with it. And I hate it.

Note: all another function members movings from header file to source
are postponed to another commit.

This commit based on
75d8d01b17 (diff-efcc341e70654031bd8fee83d8b7105bR999)

Fixes #189.
This commit is contained in:
leha-bot 2018-10-17 22:22:29 +03:00 committed by Alex
parent 04882ed746
commit 8b5f81a218
2 changed files with 11 additions and 3 deletions

View File

@ -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<UserData *> user) const {
if (mgInfo) {
auto i = mgInfo->lastAdmins.constFind(user);

View File

@ -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<UserData *> user) const;