Skip to content

Commit

Permalink
Fix channel message pinning for channel moderators
Browse files Browse the repository at this point in the history
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 movings are postponed to another commit.

This commit based on
telegramdesktop/tdesktop@75d8d01#diff-efcc341e70654031bd8fee83d8b7105bR999

Fixes #189.
  • Loading branch information
leha-bot committed Oct 17, 2018
1 parent 60b74e3 commit 7729f11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Telegram/SourceFiles/structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,15 @@ void ChannelData::setPinnedMessageId(MsgId messageId) {
}
}

bool ChannelData::canPinMessages() const {
if (isMegagroup()) {
return (adminRights() & AdminRight::f_pin_messages)
|| amCreator();
}
return (adminRights() & AdminRight::f_edit_messages)
|| amCreator();
}

bool ChannelData::canNotEditLastAdmin(not_null<UserData *> user) const {
if (mgInfo) {
auto i = mgInfo->lastAdmins.constFind(user);
Expand Down
3 changes: 0 additions & 3 deletions Telegram/SourceFiles/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -909,9 +909,6 @@ class ChannelData : public PeerData {
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();
}
Expand Down

0 comments on commit 7729f11

Please sign in to comment.