2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 22:55:11 +00:00

Correctly handle complex pin_messages/manage_topics.

This commit is contained in:
John Preston
2022-10-24 13:13:21 +04:00
parent 53beb6f562
commit 70e5f752ba
16 changed files with 135 additions and 53 deletions

View File

@@ -210,10 +210,12 @@ bool ForumTopic::canEdit() const {
}
bool ForumTopic::canDelete() const {
return !creating()
&& (channel()->canEditTopics()
// We don't know if we can delete or not.
/*|| (my() && onlyOneMyMessage)*/);
if (creating()) {
return false;
} else if (channel()->canDeleteMessages()) {
return true;
}
return my() && replies()->canDeleteMyTopic();
}
bool ForumTopic::canToggleClosed() const {
@@ -221,7 +223,12 @@ bool ForumTopic::canToggleClosed() const {
}
bool ForumTopic::canTogglePinned() const {
return !creating() && channel()->canEditTopics();
if (creating()) {
return false;
}
const auto channel = this->channel();
return channel->amCreator()
|| (channel->adminRights() & ChatAdminRight::PinMessagesOrTopics);
}
bool ForumTopic::creating() const {