mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Always show that bot-admin reads all messages.
A bot with any admin rights has access to messages.
This commit is contained in:
@@ -1430,8 +1430,8 @@ void ContactsBox::Inner::addSelectedAsChannelAdmin() {
|
||||
}
|
||||
if (_addAdminBox) _addAdminBox->deleteLater();
|
||||
|
||||
auto showBox = [this](auto &¤tRights) {
|
||||
_addAdminBox = Ui::show(Box<EditAdminBox>(_channel, _addAdmin, currentRights, base::lambda_guarded(this, [this](const MTPChannelAdminRights &rights) {
|
||||
auto showBox = [this](auto &¤tRights, bool hasAdminRights) {
|
||||
_addAdminBox = Ui::show(Box<EditAdminBox>(_channel, _addAdmin, hasAdminRights, currentRights, base::lambda_guarded(this, [this](const MTPChannelAdminRights &rights) {
|
||||
if (_addAdminRequestId) return;
|
||||
_addAdminRequestId = MTP::send(MTPchannels_EditAdmin(_channel->inputChannel, _addAdmin->inputUser, rights), rpcDone(&Inner::addAdminDone, rights), rpcFail(&Inner::addAdminFail));
|
||||
})), KeepOtherLayers);
|
||||
@@ -1449,7 +1449,7 @@ void ContactsBox::Inner::addSelectedAsChannelAdmin() {
|
||||
|
||||
if (auto rights = loadedRights()) {
|
||||
if (rights->canEdit) {
|
||||
showBox(rights->rights);
|
||||
showBox(rights->rights, true);
|
||||
} else {
|
||||
Ui::show(Box<InformBox>(lang(lng_error_cant_edit_admin)), KeepOtherLayers);
|
||||
}
|
||||
@@ -1462,12 +1462,12 @@ void ContactsBox::Inner::addSelectedAsChannelAdmin() {
|
||||
_addAdminRequestId = 0;
|
||||
if (participant.vparticipant.type() == mtpc_channelParticipantAdmin) {
|
||||
if (participant.vparticipant.c_channelParticipantAdmin().is_can_edit()) {
|
||||
showBox(participant.vparticipant.c_channelParticipantAdmin().vadmin_rights);
|
||||
showBox(participant.vparticipant.c_channelParticipantAdmin().vadmin_rights, true);
|
||||
} else {
|
||||
Ui::show(Box<InformBox>(lang(lng_error_cant_edit_admin)), KeepOtherLayers);
|
||||
}
|
||||
} else {
|
||||
showBox(EditAdminBox::DefaultRights(_channel));
|
||||
showBox(EditAdminBox::DefaultRights(_channel), false);
|
||||
}
|
||||
})), ::rpcFail(base::lambda_guarded(this, [this](const RPCError &error) {
|
||||
if (MTP::isDefaultHandledError(error)) {
|
||||
|
@@ -72,9 +72,10 @@ void ApplyDependencies(CheckboxesMap &checkboxes, DependenciesMap &dependencies,
|
||||
|
||||
class EditParticipantBox::Inner : public TWidget {
|
||||
public:
|
||||
Inner(QWidget *parent, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user) : TWidget(parent)
|
||||
, _channel(channel)
|
||||
, _user(user) {
|
||||
Inner(QWidget *parent, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, bool hasAdminRights) : TWidget(parent)
|
||||
, _channel(channel)
|
||||
, _user(user)
|
||||
, _hasAdminRights(hasAdminRights) {
|
||||
}
|
||||
|
||||
template <typename Widget>
|
||||
@@ -92,6 +93,7 @@ protected:
|
||||
private:
|
||||
gsl::not_null<ChannelData*> _channel;
|
||||
gsl::not_null<UserData*> _user;
|
||||
bool _hasAdminRights = false;
|
||||
std::vector<object_ptr<TWidget>> _rows;
|
||||
|
||||
};
|
||||
@@ -130,8 +132,7 @@ void EditParticipantBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
_user->nameText.drawLeftElided(p, namex, st::contactsNameTop, namew, width());
|
||||
auto statusText = [this] {
|
||||
if (_user->botInfo) {
|
||||
auto isAdmin = _channel->mgInfo ? _channel->mgInfo->lastAdmins.contains(_user) : false;
|
||||
auto seesAllMessages = (_user->botInfo->readsAllHistory || isAdmin);
|
||||
auto seesAllMessages = (_user->botInfo->readsAllHistory || _hasAdminRights);
|
||||
return lang(seesAllMessages ? lng_status_bot_reads_all : lng_status_bot_not_reads_all);
|
||||
}
|
||||
return App::onlineText(_user->onlineTill, unixtime());
|
||||
@@ -141,13 +142,14 @@ void EditParticipantBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
p.drawTextLeft(namex, st::contactsStatusTop, width(), statusText());
|
||||
}
|
||||
|
||||
EditParticipantBox::EditParticipantBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user) : BoxContent()
|
||||
EditParticipantBox::EditParticipantBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, bool hasAdminRights) : BoxContent()
|
||||
, _channel(channel)
|
||||
, _user(user) {
|
||||
, _user(user)
|
||||
, _hasAdminRights(hasAdminRights) {
|
||||
}
|
||||
|
||||
void EditParticipantBox::prepare() {
|
||||
_inner = setInnerWidget(object_ptr<Inner>(this, _channel, _user));
|
||||
_inner = setInnerWidget(object_ptr<Inner>(this, _channel, _user, hasAdminRights()));
|
||||
}
|
||||
|
||||
template <typename Widget>
|
||||
@@ -161,7 +163,7 @@ void EditParticipantBox::resizeToContent() {
|
||||
setDimensions(_inner->width(), _inner->height());
|
||||
}
|
||||
|
||||
EditAdminBox::EditAdminBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, const MTPChannelAdminRights &rights, base::lambda<void(MTPChannelAdminRights)> callback) : EditParticipantBox(nullptr, channel, user)
|
||||
EditAdminBox::EditAdminBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, bool hasAdminRights, const MTPChannelAdminRights &rights, base::lambda<void(MTPChannelAdminRights)> callback) : EditParticipantBox(nullptr, channel, user, hasAdminRights)
|
||||
, _rights(rights)
|
||||
, _saveCallback(std::move(callback)) {
|
||||
auto dependency = [this](Flag dependent, Flag dependency) {
|
||||
@@ -261,7 +263,7 @@ void EditAdminBox::refreshAboutAddAdminsText() {
|
||||
resizeToContent();
|
||||
}
|
||||
|
||||
EditRestrictedBox::EditRestrictedBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, const MTPChannelBannedRights &rights, base::lambda<void(MTPChannelBannedRights)> callback) : EditParticipantBox(nullptr, channel, user)
|
||||
EditRestrictedBox::EditRestrictedBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, bool hasAdminRights, const MTPChannelBannedRights &rights, base::lambda<void(MTPChannelBannedRights)> callback) : EditParticipantBox(nullptr, channel, user, hasAdminRights)
|
||||
, _rights(rights)
|
||||
, _until(rights.c_channelBannedRights().vuntil_date.v)
|
||||
, _saveCallback(std::move(callback)) {
|
||||
|
@@ -32,7 +32,7 @@ class CalendarBox;
|
||||
|
||||
class EditParticipantBox : public BoxContent {
|
||||
public:
|
||||
EditParticipantBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user);
|
||||
EditParticipantBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, bool hasAdminRights);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
@@ -49,9 +49,14 @@ protected:
|
||||
template <typename Widget>
|
||||
QPointer<Widget> addControl(object_ptr<Widget> row);
|
||||
|
||||
bool hasAdminRights() const {
|
||||
return _hasAdminRights;
|
||||
}
|
||||
|
||||
private:
|
||||
gsl::not_null<UserData*> _user;
|
||||
gsl::not_null<ChannelData*> _channel;
|
||||
gsl::not_null<UserData*> _user;
|
||||
bool _hasAdminRights = false;
|
||||
|
||||
class Inner;
|
||||
QPointer<Inner> _inner;
|
||||
@@ -60,7 +65,7 @@ private:
|
||||
|
||||
class EditAdminBox : public EditParticipantBox {
|
||||
public:
|
||||
EditAdminBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, const MTPChannelAdminRights &rights, base::lambda<void(MTPChannelAdminRights)> callback);
|
||||
EditAdminBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, bool hasAdminRights, const MTPChannelAdminRights &rights, base::lambda<void(MTPChannelAdminRights)> callback);
|
||||
|
||||
static MTPChannelAdminRights DefaultRights(gsl::not_null<ChannelData*> channel);
|
||||
|
||||
@@ -88,7 +93,7 @@ private:
|
||||
|
||||
class EditRestrictedBox : public EditParticipantBox {
|
||||
public:
|
||||
EditRestrictedBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, const MTPChannelBannedRights &rights, base::lambda<void(MTPChannelBannedRights)> callback);
|
||||
EditRestrictedBox(QWidget*, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, bool hasAdminRights, const MTPChannelBannedRights &rights, base::lambda<void(MTPChannelBannedRights)> callback);
|
||||
|
||||
static MTPChannelBannedRights DefaultRights(gsl::not_null<ChannelData*> channel);
|
||||
static constexpr auto kRestrictUntilForever = TimeId(INT_MAX);
|
||||
|
@@ -274,7 +274,8 @@ void MembersBox::Inner::actionPressed(Member &row) {
|
||||
})), KeepOtherLayers);
|
||||
} else {
|
||||
auto currentRights = _rows[_kickSelected].adminRights;
|
||||
_kickBox = Ui::show(Box<EditAdminBox>(_channel, user, currentRights, base::lambda_guarded(this, [this, user](const MTPChannelAdminRights &rights) {
|
||||
auto hasAdminRights = true;
|
||||
_kickBox = Ui::show(Box<EditAdminBox>(_channel, user, hasAdminRights, currentRights, base::lambda_guarded(this, [this, user](const MTPChannelAdminRights &rights) {
|
||||
if (_kickBox) _kickBox->closeBox();
|
||||
MTP::send(MTPchannels_EditAdmin(_channel->inputChannel, user->inputUser, rights), ::rpcDone(base::lambda_guarded(this, [this, user, rights](const MTPUpdates &result, mtpRequestId req) {
|
||||
if (App::main()) App::main()->sentUpdatesReceived(result);
|
||||
|
Reference in New Issue
Block a user