From ca49e74b6fd492c110bfe025d7e606cea5b23a76 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Thu, 30 Apr 2020 18:31:44 +0300 Subject: [PATCH] Show bot privacy status --- Telegram/SourceFiles/boxes/peer_list_box.h | 2 +- .../SourceFiles/boxes/peers/edit_participants_box.cpp | 6 ++++++ Telegram/SourceFiles/calls/calls_box_controller.cpp | 2 +- .../info/profile/info_profile_members_controllers.cpp | 11 +++++++++++ .../info/profile/info_profile_members_controllers.h | 1 + 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index 706a1d9f6..fbc95a30f 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -130,7 +130,7 @@ public: LastSeen, Custom, }; - void refreshStatus(); + virtual void refreshStatus(); crl::time refreshStatusTime() const; void setAbsoluteIndex(int index) { diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index f250ca81f..8134251a8 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1786,6 +1786,12 @@ std::unique_ptr ParticipantsBoxController::createRow( || _additional.canEditAdmin(user))) { row->setActionLink(tr::lng_profile_kick(tr::now)); } + if (_role == Role::Members && user->isBot()) { + auto seesAllMessages = (user->botInfo->readsAllHistory || _additional.adminRights(user).has_value()); + row->setCustomStatus(seesAllMessages + ? tr::lng_status_bot_reads_all(tr::now) + : tr::lng_status_bot_not_reads_all(tr::now)); + } } return row; } diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index 7b2000892..4d441067e 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -109,7 +109,7 @@ public: bool actionSelected) override; private: - void refreshStatus(); + void refreshStatus() override; static Type ComputeType(not_null item); std::vector> _items; diff --git a/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp b/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp index b47065e73..5c243d304 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_members_controllers.cpp @@ -93,6 +93,17 @@ void MemberListRow::paintNameIcon( icon->paint(p, x, y, outerWidth); } +void MemberListRow::refreshStatus() { + if (user()->isBot()) { + auto seesAllMessages = (user()->botInfo->readsAllHistory || _type.rights != Rights::Normal); + setCustomStatus(seesAllMessages + ? tr::lng_status_bot_reads_all(tr::now) + : tr::lng_status_bot_not_reads_all(tr::now)); + } else { + PeerListRow::refreshStatus(); + } +} + std::unique_ptr CreateMembersController( not_null navigation, not_null peer) { diff --git a/Telegram/SourceFiles/info/profile/info_profile_members_controllers.h b/Telegram/SourceFiles/info/profile/info_profile_members_controllers.h index 70179be19..fb4bd32c7 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_members_controllers.h +++ b/Telegram/SourceFiles/info/profile/info_profile_members_controllers.h @@ -46,6 +46,7 @@ public: int y, int outerWidth, bool selected) override; + void refreshStatus() override; not_null user() const; bool canRemove() const {