Bot privacy status in members list

This commit is contained in:
Eric Kotato 2020-03-08 01:32:29 +03:00
parent 2bdc5d5822
commit 64266cd7f5
4 changed files with 19 additions and 1 deletions

View file

@ -121,7 +121,7 @@ public:
LastSeen, LastSeen,
Custom, Custom,
}; };
void refreshStatus(); virtual void refreshStatus();
crl::time refreshStatusTime() const; crl::time refreshStatusTime() const;
void setAbsoluteIndex(int index) { void setAbsoluteIndex(int index) {

View file

@ -1797,6 +1797,12 @@ std::unique_ptr<PeerListRow> ParticipantsBoxController::createRow(
|| _additional.canEditAdmin(user))) { || _additional.canEditAdmin(user))) {
row->setActionLink(tr::lng_profile_kick(tr::now)); 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; return row;
} }

View file

@ -85,6 +85,17 @@ void MemberListRow::paintAdminRank(
p.drawTextLeft(x, y, outerWidth, _type.adminRank, adminRankWidth()); p.drawTextLeft(x, y, outerWidth, _type.adminRank, adminRankWidth());
} }
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<PeerListController> CreateMembersController( std::unique_ptr<PeerListController> CreateMembersController(
not_null<Window::SessionNavigation*> navigation, not_null<Window::SessionNavigation*> navigation,
not_null<PeerData*> peer) { not_null<PeerData*> peer) {

View file

@ -47,6 +47,7 @@ public:
int y, int y,
int outerWidth, int outerWidth,
bool selected) override; bool selected) override;
void refreshStatus() override;
not_null<UserData*> user() const; not_null<UserData*> user() const;
bool canRemove() const { bool canRemove() const {