From 964846f1bb35f8017897b1e5389c0c39278f2644 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 9 Feb 2024 18:19:40 +0400 Subject: [PATCH] Add stories rights to group admins edit. --- .../boxes/peers/edit_peer_permissions_box.cpp | 21 ++++++++++++++----- Telegram/SourceFiles/data/data_channel.cpp | 9 -------- .../history/history_inner_widget.cpp | 1 + 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index 9b0747870..385cb1ac6 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -104,7 +104,7 @@ constexpr auto kForceDisableTooltipDuration = 3 * crl::time(1000); using Flag = ChatAdminRight; if (options.isGroup) { - auto result = std::vector{ + auto first = std::vector{ { Flag::ChangeInfo, tr::lng_rights_group_info(tr::now) }, { Flag::DeleteMessages, tr::lng_rights_group_delete(tr::now) }, { Flag::BanUsers, tr::lng_rights_group_ban(tr::now) }, @@ -113,19 +113,30 @@ constexpr auto kForceDisableTooltipDuration = 3 * crl::time(1000); : tr::lng_rights_group_invite(tr::now) }, { Flag::ManageTopics, tr::lng_rights_group_topics(tr::now) }, { Flag::PinMessages, tr::lng_rights_group_pin(tr::now) }, + }; + auto stories = std::vector{ + { Flag::PostStories, tr::lng_rights_channel_post_stories(tr::now) }, + { Flag::EditStories, tr::lng_rights_channel_edit_stories(tr::now) }, + { Flag::DeleteStories, tr::lng_rights_channel_delete_stories(tr::now) }, + }; + auto second = std::vector{ { Flag::ManageCall, tr::lng_rights_group_manage_calls(tr::now) }, { Flag::Anonymous, tr::lng_rights_group_anonymous(tr::now) }, { Flag::AddAdmins, tr::lng_rights_add_admins(tr::now) }, }; if (!options.isForum) { - result.erase( + first.erase( ranges::remove( - result, + first, Flag::ManageTopics | Flag(), &AdminRightLabel::flags), - end(result)); + end(first)); } - return { { std::nullopt, std::move(result) } }; + return { + { std::nullopt, std::move(first) }, + { tr::lng_rights_channel_manage_stories(), std::move(stories) }, + { std::nullopt, std::move(second) }, + }; } auto first = std::vector{ { Flag::ChangeInfo, tr::lng_rights_channel_info(tr::now) }, diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index 87d2a5301..469351af2 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -556,25 +556,16 @@ bool ChannelData::canDeleteMessages() const { } bool ChannelData::canPostStories() const { - if (!isBroadcast()) { - return false; - } return amCreator() || (adminRights() & AdminRight::PostStories); } bool ChannelData::canEditStories() const { - if (!isBroadcast()) { - return false; - } return amCreator() || (adminRights() & AdminRight::EditStories); } bool ChannelData::canDeleteStories() const { - if (!isBroadcast()) { - return false; - } return amCreator() || (adminRights() & AdminRight::DeleteStories); } diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index b7955f4ba..b85703cf0 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -355,6 +355,7 @@ HistoryInner::HistoryInner( _theme = std::move(theme); controller->setChatStyleTheme(_theme); }, lifetime()); + Assert(_theme != nullptr); setAttribute(Qt::WA_AcceptTouchEvents);