mirror of https://github.com/procxx/kepka.git
Always show that bot-admin reads all messages.
A bot with any admin rights has access to messages.
This commit is contained in:
parent
8fe56b9a7d
commit
c3ad0ae129
|
@ -1430,8 +1430,8 @@ void ContactsBox::Inner::addSelectedAsChannelAdmin() {
|
||||||
}
|
}
|
||||||
if (_addAdminBox) _addAdminBox->deleteLater();
|
if (_addAdminBox) _addAdminBox->deleteLater();
|
||||||
|
|
||||||
auto showBox = [this](auto &¤tRights) {
|
auto showBox = [this](auto &¤tRights, bool hasAdminRights) {
|
||||||
_addAdminBox = Ui::show(Box<EditAdminBox>(_channel, _addAdmin, currentRights, base::lambda_guarded(this, [this](const MTPChannelAdminRights &rights) {
|
_addAdminBox = Ui::show(Box<EditAdminBox>(_channel, _addAdmin, hasAdminRights, currentRights, base::lambda_guarded(this, [this](const MTPChannelAdminRights &rights) {
|
||||||
if (_addAdminRequestId) return;
|
if (_addAdminRequestId) return;
|
||||||
_addAdminRequestId = MTP::send(MTPchannels_EditAdmin(_channel->inputChannel, _addAdmin->inputUser, rights), rpcDone(&Inner::addAdminDone, rights), rpcFail(&Inner::addAdminFail));
|
_addAdminRequestId = MTP::send(MTPchannels_EditAdmin(_channel->inputChannel, _addAdmin->inputUser, rights), rpcDone(&Inner::addAdminDone, rights), rpcFail(&Inner::addAdminFail));
|
||||||
})), KeepOtherLayers);
|
})), KeepOtherLayers);
|
||||||
|
@ -1449,7 +1449,7 @@ void ContactsBox::Inner::addSelectedAsChannelAdmin() {
|
||||||
|
|
||||||
if (auto rights = loadedRights()) {
|
if (auto rights = loadedRights()) {
|
||||||
if (rights->canEdit) {
|
if (rights->canEdit) {
|
||||||
showBox(rights->rights);
|
showBox(rights->rights, true);
|
||||||
} else {
|
} else {
|
||||||
Ui::show(Box<InformBox>(lang(lng_error_cant_edit_admin)), KeepOtherLayers);
|
Ui::show(Box<InformBox>(lang(lng_error_cant_edit_admin)), KeepOtherLayers);
|
||||||
}
|
}
|
||||||
|
@ -1462,12 +1462,12 @@ void ContactsBox::Inner::addSelectedAsChannelAdmin() {
|
||||||
_addAdminRequestId = 0;
|
_addAdminRequestId = 0;
|
||||||
if (participant.vparticipant.type() == mtpc_channelParticipantAdmin) {
|
if (participant.vparticipant.type() == mtpc_channelParticipantAdmin) {
|
||||||
if (participant.vparticipant.c_channelParticipantAdmin().is_can_edit()) {
|
if (participant.vparticipant.c_channelParticipantAdmin().is_can_edit()) {
|
||||||
showBox(participant.vparticipant.c_channelParticipantAdmin().vadmin_rights);
|
showBox(participant.vparticipant.c_channelParticipantAdmin().vadmin_rights, true);
|
||||||
} else {
|
} else {
|
||||||
Ui::show(Box<InformBox>(lang(lng_error_cant_edit_admin)), KeepOtherLayers);
|
Ui::show(Box<InformBox>(lang(lng_error_cant_edit_admin)), KeepOtherLayers);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showBox(EditAdminBox::DefaultRights(_channel));
|
showBox(EditAdminBox::DefaultRights(_channel), false);
|
||||||
}
|
}
|
||||||
})), ::rpcFail(base::lambda_guarded(this, [this](const RPCError &error) {
|
})), ::rpcFail(base::lambda_guarded(this, [this](const RPCError &error) {
|
||||||
if (MTP::isDefaultHandledError(error)) {
|
if (MTP::isDefaultHandledError(error)) {
|
||||||
|
|
|
@ -72,9 +72,10 @@ void ApplyDependencies(CheckboxesMap &checkboxes, DependenciesMap &dependencies,
|
||||||
|
|
||||||
class EditParticipantBox::Inner : public TWidget {
|
class EditParticipantBox::Inner : public TWidget {
|
||||||
public:
|
public:
|
||||||
Inner(QWidget *parent, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user) : TWidget(parent)
|
Inner(QWidget *parent, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, bool hasAdminRights) : TWidget(parent)
|
||||||
, _channel(channel)
|
, _channel(channel)
|
||||||
, _user(user) {
|
, _user(user)
|
||||||
|
, _hasAdminRights(hasAdminRights) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Widget>
|
template <typename Widget>
|
||||||
|
@ -92,6 +93,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
gsl::not_null<ChannelData*> _channel;
|
gsl::not_null<ChannelData*> _channel;
|
||||||
gsl::not_null<UserData*> _user;
|
gsl::not_null<UserData*> _user;
|
||||||
|
bool _hasAdminRights = false;
|
||||||
std::vector<object_ptr<TWidget>> _rows;
|
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());
|
_user->nameText.drawLeftElided(p, namex, st::contactsNameTop, namew, width());
|
||||||
auto statusText = [this] {
|
auto statusText = [this] {
|
||||||
if (_user->botInfo) {
|
if (_user->botInfo) {
|
||||||
auto isAdmin = _channel->mgInfo ? _channel->mgInfo->lastAdmins.contains(_user) : false;
|
auto seesAllMessages = (_user->botInfo->readsAllHistory || _hasAdminRights);
|
||||||
auto seesAllMessages = (_user->botInfo->readsAllHistory || isAdmin);
|
|
||||||
return lang(seesAllMessages ? lng_status_bot_reads_all : lng_status_bot_not_reads_all);
|
return lang(seesAllMessages ? lng_status_bot_reads_all : lng_status_bot_not_reads_all);
|
||||||
}
|
}
|
||||||
return App::onlineText(_user->onlineTill, unixtime());
|
return App::onlineText(_user->onlineTill, unixtime());
|
||||||
|
@ -141,13 +142,14 @@ void EditParticipantBox::Inner::paintEvent(QPaintEvent *e) {
|
||||||
p.drawTextLeft(namex, st::contactsStatusTop, width(), statusText());
|
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)
|
, _channel(channel)
|
||||||
, _user(user) {
|
, _user(user)
|
||||||
|
, _hasAdminRights(hasAdminRights) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditParticipantBox::prepare() {
|
void EditParticipantBox::prepare() {
|
||||||
_inner = setInnerWidget(object_ptr<Inner>(this, _channel, _user));
|
_inner = setInnerWidget(object_ptr<Inner>(this, _channel, _user, hasAdminRights()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Widget>
|
template <typename Widget>
|
||||||
|
@ -161,7 +163,7 @@ void EditParticipantBox::resizeToContent() {
|
||||||
setDimensions(_inner->width(), _inner->height());
|
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)
|
, _rights(rights)
|
||||||
, _saveCallback(std::move(callback)) {
|
, _saveCallback(std::move(callback)) {
|
||||||
auto dependency = [this](Flag dependent, Flag dependency) {
|
auto dependency = [this](Flag dependent, Flag dependency) {
|
||||||
|
@ -261,7 +263,7 @@ void EditAdminBox::refreshAboutAddAdminsText() {
|
||||||
resizeToContent();
|
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)
|
, _rights(rights)
|
||||||
, _until(rights.c_channelBannedRights().vuntil_date.v)
|
, _until(rights.c_channelBannedRights().vuntil_date.v)
|
||||||
, _saveCallback(std::move(callback)) {
|
, _saveCallback(std::move(callback)) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ class CalendarBox;
|
||||||
|
|
||||||
class EditParticipantBox : public BoxContent {
|
class EditParticipantBox : public BoxContent {
|
||||||
public:
|
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:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
@ -49,9 +49,14 @@ protected:
|
||||||
template <typename Widget>
|
template <typename Widget>
|
||||||
QPointer<Widget> addControl(object_ptr<Widget> row);
|
QPointer<Widget> addControl(object_ptr<Widget> row);
|
||||||
|
|
||||||
|
bool hasAdminRights() const {
|
||||||
|
return _hasAdminRights;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
gsl::not_null<UserData*> _user;
|
|
||||||
gsl::not_null<ChannelData*> _channel;
|
gsl::not_null<ChannelData*> _channel;
|
||||||
|
gsl::not_null<UserData*> _user;
|
||||||
|
bool _hasAdminRights = false;
|
||||||
|
|
||||||
class Inner;
|
class Inner;
|
||||||
QPointer<Inner> _inner;
|
QPointer<Inner> _inner;
|
||||||
|
@ -60,7 +65,7 @@ private:
|
||||||
|
|
||||||
class EditAdminBox : public EditParticipantBox {
|
class EditAdminBox : public EditParticipantBox {
|
||||||
public:
|
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);
|
static MTPChannelAdminRights DefaultRights(gsl::not_null<ChannelData*> channel);
|
||||||
|
|
||||||
|
@ -88,7 +93,7 @@ private:
|
||||||
|
|
||||||
class EditRestrictedBox : public EditParticipantBox {
|
class EditRestrictedBox : public EditParticipantBox {
|
||||||
public:
|
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 MTPChannelBannedRights DefaultRights(gsl::not_null<ChannelData*> channel);
|
||||||
static constexpr auto kRestrictUntilForever = TimeId(INT_MAX);
|
static constexpr auto kRestrictUntilForever = TimeId(INT_MAX);
|
||||||
|
|
|
@ -274,7 +274,8 @@ void MembersBox::Inner::actionPressed(Member &row) {
|
||||||
})), KeepOtherLayers);
|
})), KeepOtherLayers);
|
||||||
} else {
|
} else {
|
||||||
auto currentRights = _rows[_kickSelected].adminRights;
|
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();
|
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) {
|
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);
|
if (App::main()) App::main()->sentUpdatesReceived(result);
|
||||||
|
|
|
@ -1741,11 +1741,17 @@ void HistoryWidget::fastShowAtEnd(History *h) {
|
||||||
|
|
||||||
void HistoryWidget::applyDraft(bool parseLinks, Ui::FlatTextarea::UndoHistoryAction undoHistoryAction) {
|
void HistoryWidget::applyDraft(bool parseLinks, Ui::FlatTextarea::UndoHistoryAction undoHistoryAction) {
|
||||||
auto draft = _history ? _history->draft() : nullptr;
|
auto draft = _history ? _history->draft() : nullptr;
|
||||||
if (!draft || !canWriteMessage()) {
|
auto fieldAvailable = canWriteMessage();
|
||||||
|
if (!draft || (!_history->editDraft() && !fieldAvailable)) {
|
||||||
|
auto fieldWillBeHiddenAfterEdit = (!fieldAvailable && _editMsgId != 0);
|
||||||
clearFieldText(0, undoHistoryAction);
|
clearFieldText(0, undoHistoryAction);
|
||||||
_field->setFocus();
|
_field->setFocus();
|
||||||
_replyEditMsg = nullptr;
|
_replyEditMsg = nullptr;
|
||||||
_editMsgId = _replyToId = 0;
|
_editMsgId = _replyToId = 0;
|
||||||
|
if (fieldWillBeHiddenAfterEdit) {
|
||||||
|
updateControlsVisibility();
|
||||||
|
updateControlsGeometry();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1763,6 +1769,10 @@ void HistoryWidget::applyDraft(bool parseLinks, Ui::FlatTextarea::UndoHistoryAct
|
||||||
_editMsgId = 0;
|
_editMsgId = 0;
|
||||||
_replyToId = readyToForward() ? 0 : _history->localDraft()->msgId;
|
_replyToId = readyToForward() ? 0 : _history->localDraft()->msgId;
|
||||||
}
|
}
|
||||||
|
if (!canWriteMessage()) {
|
||||||
|
updateControlsVisibility();
|
||||||
|
updateControlsGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
if (parseLinks) {
|
if (parseLinks) {
|
||||||
onPreviewParse();
|
onPreviewParse();
|
||||||
|
@ -2201,10 +2211,11 @@ void HistoryWidget::updateControlsVisibility() {
|
||||||
if (_reportSpamPanel) {
|
if (_reportSpamPanel) {
|
||||||
_reportSpamPanel->show();
|
_reportSpamPanel->show();
|
||||||
}
|
}
|
||||||
if (isBlocked() || isJoinChannel() || isMuteUnmute()) {
|
if (!editingMessage() && (isBlocked() || isJoinChannel() || isMuteUnmute() || isBotStart())) {
|
||||||
if (isBlocked()) {
|
if (isBlocked()) {
|
||||||
_joinChannel->hide();
|
_joinChannel->hide();
|
||||||
_muteUnmute->hide();
|
_muteUnmute->hide();
|
||||||
|
_botStart->hide();
|
||||||
if (_unblock->isHidden()) {
|
if (_unblock->isHidden()) {
|
||||||
_unblock->clearState();
|
_unblock->clearState();
|
||||||
_unblock->show();
|
_unblock->show();
|
||||||
|
@ -2212,6 +2223,7 @@ void HistoryWidget::updateControlsVisibility() {
|
||||||
} else if (isJoinChannel()) {
|
} else if (isJoinChannel()) {
|
||||||
_unblock->hide();
|
_unblock->hide();
|
||||||
_muteUnmute->hide();
|
_muteUnmute->hide();
|
||||||
|
_botStart->hide();
|
||||||
if (_joinChannel->isHidden()) {
|
if (_joinChannel->isHidden()) {
|
||||||
_joinChannel->clearState();
|
_joinChannel->clearState();
|
||||||
_joinChannel->show();
|
_joinChannel->show();
|
||||||
|
@ -2219,16 +2231,23 @@ void HistoryWidget::updateControlsVisibility() {
|
||||||
} else if (isMuteUnmute()) {
|
} else if (isMuteUnmute()) {
|
||||||
_unblock->hide();
|
_unblock->hide();
|
||||||
_joinChannel->hide();
|
_joinChannel->hide();
|
||||||
|
_botStart->hide();
|
||||||
if (_muteUnmute->isHidden()) {
|
if (_muteUnmute->isHidden()) {
|
||||||
_muteUnmute->clearState();
|
_muteUnmute->clearState();
|
||||||
_muteUnmute->show();
|
_muteUnmute->show();
|
||||||
}
|
}
|
||||||
|
} else if (isBotStart()) {
|
||||||
|
_unblock->hide();
|
||||||
|
_joinChannel->hide();
|
||||||
|
_muteUnmute->hide();
|
||||||
|
if (_botStart->isHidden()) {
|
||||||
|
_botStart->clearState();
|
||||||
|
_botStart->show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_kbShown = false;
|
_kbShown = false;
|
||||||
_fieldAutocomplete->hide();
|
_fieldAutocomplete->hide();
|
||||||
_send->hide();
|
_send->hide();
|
||||||
_botStart->hide();
|
|
||||||
_attachToggle->hide();
|
|
||||||
_silent->hide();
|
_silent->hide();
|
||||||
_kbScroll->hide();
|
_kbScroll->hide();
|
||||||
_fieldBarCancel->hide();
|
_fieldBarCancel->hide();
|
||||||
|
@ -2248,18 +2267,15 @@ void HistoryWidget::updateControlsVisibility() {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
} else if (_canSendMessages) {
|
} else if (editingMessage() || _canSendMessages) {
|
||||||
onCheckFieldAutocomplete();
|
onCheckFieldAutocomplete();
|
||||||
if (isBotStart()) {
|
_unblock->hide();
|
||||||
_unblock->hide();
|
_botStart->hide();
|
||||||
_joinChannel->hide();
|
_joinChannel->hide();
|
||||||
_muteUnmute->hide();
|
_muteUnmute->hide();
|
||||||
if (_botStart->isHidden()) {
|
_send->show();
|
||||||
_botStart->clearState();
|
updateSendButtonType();
|
||||||
_botStart->show();
|
if (_recording) {
|
||||||
}
|
|
||||||
_kbShown = false;
|
|
||||||
_send->hide();
|
|
||||||
_field->hide();
|
_field->hide();
|
||||||
_tabbedSelectorToggle->hide();
|
_tabbedSelectorToggle->hide();
|
||||||
_botKeyboardShow->hide();
|
_botKeyboardShow->hide();
|
||||||
|
@ -2267,75 +2283,57 @@ void HistoryWidget::updateControlsVisibility() {
|
||||||
_botCommandStart->hide();
|
_botCommandStart->hide();
|
||||||
_attachToggle->hide();
|
_attachToggle->hide();
|
||||||
_silent->hide();
|
_silent->hide();
|
||||||
_kbScroll->hide();
|
if (_kbShown) {
|
||||||
_fieldBarCancel->hide();
|
_kbScroll->show();
|
||||||
} else {
|
|
||||||
_unblock->hide();
|
|
||||||
_botStart->hide();
|
|
||||||
_joinChannel->hide();
|
|
||||||
_muteUnmute->hide();
|
|
||||||
_send->show();
|
|
||||||
updateSendButtonType();
|
|
||||||
if (_recording) {
|
|
||||||
_field->hide();
|
|
||||||
_tabbedSelectorToggle->hide();
|
|
||||||
_botKeyboardShow->hide();
|
|
||||||
_botKeyboardHide->hide();
|
|
||||||
_botCommandStart->hide();
|
|
||||||
_attachToggle->hide();
|
|
||||||
_silent->hide();
|
|
||||||
if (_kbShown) {
|
|
||||||
_kbScroll->show();
|
|
||||||
} else {
|
|
||||||
_kbScroll->hide();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
_field->show();
|
_kbScroll->hide();
|
||||||
if (_kbShown) {
|
}
|
||||||
_kbScroll->show();
|
} else {
|
||||||
_tabbedSelectorToggle->hide();
|
_field->show();
|
||||||
_botKeyboardHide->show();
|
if (_kbShown) {
|
||||||
_botKeyboardShow->hide();
|
_kbScroll->show();
|
||||||
_botCommandStart->hide();
|
_tabbedSelectorToggle->hide();
|
||||||
} else if (_kbReplyTo) {
|
_botKeyboardHide->show();
|
||||||
_kbScroll->hide();
|
_botKeyboardShow->hide();
|
||||||
_tabbedSelectorToggle->show();
|
_botCommandStart->hide();
|
||||||
_botKeyboardHide->hide();
|
} else if (_kbReplyTo) {
|
||||||
_botKeyboardShow->hide();
|
_kbScroll->hide();
|
||||||
|
_tabbedSelectorToggle->show();
|
||||||
|
_botKeyboardHide->hide();
|
||||||
|
_botKeyboardShow->hide();
|
||||||
|
_botCommandStart->hide();
|
||||||
|
} else {
|
||||||
|
_kbScroll->hide();
|
||||||
|
_tabbedSelectorToggle->show();
|
||||||
|
_botKeyboardHide->hide();
|
||||||
|
if (_keyboard->hasMarkup()) {
|
||||||
|
_botKeyboardShow->show();
|
||||||
_botCommandStart->hide();
|
_botCommandStart->hide();
|
||||||
} else {
|
} else {
|
||||||
_kbScroll->hide();
|
_botKeyboardShow->hide();
|
||||||
_tabbedSelectorToggle->show();
|
if (_cmdStartShown) {
|
||||||
_botKeyboardHide->hide();
|
_botCommandStart->show();
|
||||||
if (_keyboard->hasMarkup()) {
|
|
||||||
_botKeyboardShow->show();
|
|
||||||
_botCommandStart->hide();
|
|
||||||
} else {
|
} else {
|
||||||
_botKeyboardShow->hide();
|
_botCommandStart->hide();
|
||||||
if (_cmdStartShown) {
|
|
||||||
_botCommandStart->show();
|
|
||||||
} else {
|
|
||||||
_botCommandStart->hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_attachToggle->show();
|
|
||||||
if (hasSilentToggle()) {
|
|
||||||
_silent->show();
|
|
||||||
} else {
|
|
||||||
_silent->hide();
|
|
||||||
}
|
|
||||||
updateFieldPlaceholder();
|
|
||||||
}
|
}
|
||||||
if (_editMsgId || _replyToId || readyToForward() || (_previewData && _previewData->pendingTill >= 0) || _kbReplyTo) {
|
_attachToggle->show();
|
||||||
if (_fieldBarCancel->isHidden()) {
|
if (hasSilentToggle()) {
|
||||||
_fieldBarCancel->show();
|
_silent->show();
|
||||||
updateControlsGeometry();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
_fieldBarCancel->hide();
|
_silent->hide();
|
||||||
}
|
}
|
||||||
|
updateFieldPlaceholder();
|
||||||
|
}
|
||||||
|
if (_editMsgId || _replyToId || readyToForward() || (_previewData && _previewData->pendingTill >= 0) || _kbReplyTo) {
|
||||||
|
if (_fieldBarCancel->isHidden()) {
|
||||||
|
_fieldBarCancel->show();
|
||||||
|
updateControlsGeometry();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_fieldBarCancel->hide();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_fieldAutocomplete->hide();
|
_fieldAutocomplete->hide();
|
||||||
|
@ -4994,10 +4992,10 @@ void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const S
|
||||||
}
|
}
|
||||||
|
|
||||||
auto newScrollHeight = height() - _topBar->height();
|
auto newScrollHeight = height() - _topBar->height();
|
||||||
if (isBlocked() || isBotStart() || isJoinChannel() || isMuteUnmute()) {
|
if (!editingMessage() && (isBlocked() || isBotStart() || isJoinChannel() || isMuteUnmute())) {
|
||||||
newScrollHeight -= _unblock->height();
|
newScrollHeight -= _unblock->height();
|
||||||
} else {
|
} else {
|
||||||
if (_canSendMessages) {
|
if (editingMessage() || _canSendMessages) {
|
||||||
newScrollHeight -= (_field->height() + 2 * st::historySendPadding);
|
newScrollHeight -= (_field->height() + 2 * st::historySendPadding);
|
||||||
} else if (isRestrictedWrite()) {
|
} else if (isRestrictedWrite()) {
|
||||||
newScrollHeight -= _unblock->height();
|
newScrollHeight -= _unblock->height();
|
||||||
|
@ -5883,6 +5881,9 @@ void HistoryWidget::cancelEdit() {
|
||||||
onTextChange();
|
onTextChange();
|
||||||
_textUpdateEvents = old;
|
_textUpdateEvents = old;
|
||||||
|
|
||||||
|
if (!canWriteMessage()) {
|
||||||
|
updateControlsVisibility();
|
||||||
|
}
|
||||||
updateBotKeyboard();
|
updateBotKeyboard();
|
||||||
updateFieldPlaceholder();
|
updateFieldPlaceholder();
|
||||||
|
|
||||||
|
@ -6556,7 +6557,7 @@ void HistoryWidget::paintEditHeader(Painter &p, const QRect &rect, int left, int
|
||||||
p.setFont(st::msgServiceNameFont);
|
p.setFont(st::msgServiceNameFont);
|
||||||
p.drawTextLeft(left, top + st::msgReplyPadding.top(), width(), lang(lng_edit_message));
|
p.drawTextLeft(left, top + st::msgReplyPadding.top(), width(), lang(lng_edit_message));
|
||||||
|
|
||||||
if (!_replyEditMsg) return;
|
if (!_replyEditMsg || _replyEditMsg->history()->peer->isSelf()) return;
|
||||||
|
|
||||||
QString editTimeLeftText;
|
QString editTimeLeftText;
|
||||||
int updateIn = -1;
|
int updateIn = -1;
|
||||||
|
|
|
@ -543,6 +543,9 @@ private:
|
||||||
|
|
||||||
void updateReplyToName();
|
void updateReplyToName();
|
||||||
void checkForwardingInfo();
|
void checkForwardingInfo();
|
||||||
|
bool editingMessage() const {
|
||||||
|
return _editMsgId != 0;
|
||||||
|
}
|
||||||
|
|
||||||
MsgId _replyToId = 0;
|
MsgId _replyToId = 0;
|
||||||
Text _replyToName;
|
Text _replyToName;
|
||||||
|
|
|
@ -73,8 +73,10 @@ void GroupMembersWidget::editAdmin(gsl::not_null<UserData*> user) {
|
||||||
return; // not supported
|
return; // not supported
|
||||||
}
|
}
|
||||||
auto defaultAdmin = MegagroupInfo::Admin { EditAdminBox::DefaultRights(megagroup) };
|
auto defaultAdmin = MegagroupInfo::Admin { EditAdminBox::DefaultRights(megagroup) };
|
||||||
auto currentRights = megagroup->mgInfo->lastAdmins.value(user, defaultAdmin).rights;
|
auto currentRightsIt = megagroup->mgInfo->lastAdmins.find(user);
|
||||||
Ui::show(Box<EditAdminBox>(megagroup, user, currentRights, base::lambda_guarded(this, [this, megagroup, user](const MTPChannelAdminRights &rights) {
|
auto hasAdminRights = (currentRightsIt != megagroup->mgInfo->lastAdmins.cend());
|
||||||
|
auto currentRights = hasAdminRights ? currentRightsIt->rights : EditAdminBox::DefaultRights(megagroup);
|
||||||
|
Ui::show(Box<EditAdminBox>(megagroup, user, hasAdminRights, currentRights, base::lambda_guarded(this, [this, megagroup, user](const MTPChannelAdminRights &rights) {
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
MTP::send(MTPchannels_EditAdmin(megagroup->inputChannel, user->inputUser, rights), rpcDone(base::lambda_guarded(this, [this, megagroup, user, rights](const MTPUpdates &result) {
|
MTP::send(MTPchannels_EditAdmin(megagroup->inputChannel, user->inputUser, rights), rpcDone(base::lambda_guarded(this, [this, megagroup, user, rights](const MTPUpdates &result) {
|
||||||
if (App::main()) App::main()->sentUpdatesReceived(result);
|
if (App::main()) App::main()->sentUpdatesReceived(result);
|
||||||
|
@ -90,7 +92,8 @@ void GroupMembersWidget::restrictUser(gsl::not_null<UserData*> user) {
|
||||||
}
|
}
|
||||||
auto defaultRestricted = MegagroupInfo::Restricted { EditRestrictedBox::DefaultRights(megagroup) };
|
auto defaultRestricted = MegagroupInfo::Restricted { EditRestrictedBox::DefaultRights(megagroup) };
|
||||||
auto currentRights = megagroup->mgInfo->lastRestricted.value(user, defaultRestricted).rights;
|
auto currentRights = megagroup->mgInfo->lastRestricted.value(user, defaultRestricted).rights;
|
||||||
Ui::show(Box<EditRestrictedBox>(megagroup, user, currentRights, [megagroup, user](const MTPChannelBannedRights &rights) {
|
auto hasAdminRights = megagroup->mgInfo->lastAdmins.find(user) != megagroup->mgInfo->lastAdmins.cend();
|
||||||
|
Ui::show(Box<EditRestrictedBox>(megagroup, user, hasAdminRights, currentRights, [megagroup, user](const MTPChannelBannedRights &rights) {
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
MTP::send(MTPchannels_EditBanned(megagroup->inputChannel, user->inputUser, rights), rpcDone([megagroup, user, rights](const MTPUpdates &result) {
|
MTP::send(MTPchannels_EditBanned(megagroup->inputChannel, user->inputUser, rights), rpcDone([megagroup, user, rights](const MTPUpdates &result) {
|
||||||
if (App::main()) App::main()->sentUpdatesReceived(result);
|
if (App::main()) App::main()->sentUpdatesReceived(result);
|
||||||
|
@ -101,6 +104,7 @@ void GroupMembersWidget::restrictUser(gsl::not_null<UserData*> user) {
|
||||||
|
|
||||||
void GroupMembersWidget::removePeer(PeerData *selectedPeer) {
|
void GroupMembersWidget::removePeer(PeerData *selectedPeer) {
|
||||||
auto user = selectedPeer->asUser();
|
auto user = selectedPeer->asUser();
|
||||||
|
t_assert(user != nullptr);
|
||||||
auto text = lng_profile_sure_kick(lt_user, user->firstName);
|
auto text = lng_profile_sure_kick(lt_user, user->firstName);
|
||||||
Ui::show(Box<ConfirmBox>(text, lang(lng_box_remove), base::lambda_guarded(this, [user, peer = peer()] {
|
Ui::show(Box<ConfirmBox>(text, lang(lng_box_remove), base::lambda_guarded(this, [user, peer = peer()] {
|
||||||
Ui::hideLayer();
|
Ui::hideLayer();
|
||||||
|
@ -246,7 +250,7 @@ void GroupMembersWidget::updateItemStatusText(Item *item) {
|
||||||
auto user = member->user();
|
auto user = member->user();
|
||||||
if (member->statusText.isEmpty() || (member->onlineTextTill <= _now)) {
|
if (member->statusText.isEmpty() || (member->onlineTextTill <= _now)) {
|
||||||
if (user->botInfo) {
|
if (user->botInfo) {
|
||||||
bool seesAllMessages = (user->botInfo->readsAllHistory || member->hasAdminStar);
|
auto seesAllMessages = (user->botInfo->readsAllHistory || member->hasAdminStar);
|
||||||
member->statusText = lang(seesAllMessages ? lng_status_bot_reads_all : lng_status_bot_not_reads_all);
|
member->statusText = lang(seesAllMessages ? lng_status_bot_reads_all : lng_status_bot_not_reads_all);
|
||||||
member->onlineTextTill = _now + 86400;
|
member->onlineTextTill = _now + 86400;
|
||||||
} else {
|
} else {
|
||||||
|
@ -461,7 +465,17 @@ void GroupMembersWidget::setItemFlags(Item *item, ChannelData *megagroup) {
|
||||||
auto isAdmin = (adminIt != megagroup->mgInfo->lastAdmins.cend());
|
auto isAdmin = (adminIt != megagroup->mgInfo->lastAdmins.cend());
|
||||||
auto isCreator = megagroup->mgInfo->creator == item->peer;
|
auto isCreator = megagroup->mgInfo->creator == item->peer;
|
||||||
auto adminCanEdit = isAdmin && adminIt->canEdit;
|
auto adminCanEdit = isAdmin && adminIt->canEdit;
|
||||||
item->hasAdminStar = amCreatorOrAdmin || isAdmin || isCreator;
|
auto hasAdminStar = amCreatorOrAdmin || isAdmin || isCreator;
|
||||||
|
if (item->hasAdminStar != hasAdminStar) {
|
||||||
|
item->hasAdminStar = hasAdminStar;
|
||||||
|
auto user = item->peer->asUser();
|
||||||
|
t_assert(user != nullptr);
|
||||||
|
if (user->botInfo) {
|
||||||
|
// Update "has access to messages" status.
|
||||||
|
item->statusText = QString();
|
||||||
|
updateItemStatusText(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (item->peer->isSelf()) {
|
if (item->peer->isSelf()) {
|
||||||
item->hasRemoveLink = false;
|
item->hasRemoveLink = false;
|
||||||
} else if (megagroup->amCreator() || (megagroup->canBanMembers() && (!item->hasAdminStar || adminCanEdit))) {
|
} else if (megagroup->amCreator() || (megagroup->canBanMembers() && (!item->hasAdminStar || adminCanEdit))) {
|
||||||
|
|
|
@ -230,7 +230,8 @@ void ParticipantsBoxController::editAdmin(gsl::not_null<UserData*> user) {
|
||||||
auto it = _additional.adminRights.find(user);
|
auto it = _additional.adminRights.find(user);
|
||||||
t_assert(it != _additional.adminRights.cend());
|
t_assert(it != _additional.adminRights.cend());
|
||||||
auto weak = base::weak_unique_ptr<ParticipantsBoxController>(this);
|
auto weak = base::weak_unique_ptr<ParticipantsBoxController>(this);
|
||||||
_editBox = Ui::show(Box<EditAdminBox>(_channel, user, it->second, [megagroup = _channel.get(), user, weak](const MTPChannelAdminRights &rights) {
|
auto hasAdminRights = true;
|
||||||
|
_editBox = Ui::show(Box<EditAdminBox>(_channel, user, hasAdminRights, it->second, [megagroup = _channel.get(), user, weak](const MTPChannelAdminRights &rights) {
|
||||||
MTP::send(MTPchannels_EditAdmin(megagroup->inputChannel, user->inputUser, rights), rpcDone([megagroup, user, weak, rights](const MTPUpdates &result) {
|
MTP::send(MTPchannels_EditAdmin(megagroup->inputChannel, user->inputUser, rights), rpcDone([megagroup, user, weak, rights](const MTPUpdates &result) {
|
||||||
AuthSession::Current().api().applyUpdates(result);
|
AuthSession::Current().api().applyUpdates(result);
|
||||||
megagroup->applyEditAdmin(user, rights);
|
megagroup->applyEditAdmin(user, rights);
|
||||||
|
@ -276,7 +277,8 @@ void ParticipantsBoxController::editRestricted(gsl::not_null<UserData*> user) {
|
||||||
auto it = _additional.restrictedRights.find(user);
|
auto it = _additional.restrictedRights.find(user);
|
||||||
t_assert(it != _additional.restrictedRights.cend());
|
t_assert(it != _additional.restrictedRights.cend());
|
||||||
auto weak = base::weak_unique_ptr<ParticipantsBoxController>(this);
|
auto weak = base::weak_unique_ptr<ParticipantsBoxController>(this);
|
||||||
_editBox = Ui::show(Box<EditRestrictedBox>(_channel, user, it->second, [megagroup = _channel.get(), user, weak](const MTPChannelBannedRights &rights) {
|
auto hasAdminRights = false;
|
||||||
|
_editBox = Ui::show(Box<EditRestrictedBox>(_channel, user, hasAdminRights, it->second, [megagroup = _channel.get(), user, weak](const MTPChannelBannedRights &rights) {
|
||||||
MTP::send(MTPchannels_EditBanned(megagroup->inputChannel, user->inputUser, rights), rpcDone([megagroup, user, weak, rights](const MTPUpdates &result) {
|
MTP::send(MTPchannels_EditBanned(megagroup->inputChannel, user->inputUser, rights), rpcDone([megagroup, user, weak, rights](const MTPUpdates &result) {
|
||||||
AuthSession::Current().api().applyUpdates(result);
|
AuthSession::Current().api().applyUpdates(result);
|
||||||
megagroup->applyEditBanned(user, rights);
|
megagroup->applyEditBanned(user, rights);
|
||||||
|
@ -614,6 +616,7 @@ void AddParticipantBoxController::editAdmin(gsl::not_null<UserData*> user, bool
|
||||||
// Check restrictions.
|
// Check restrictions.
|
||||||
auto weak = base::weak_unique_ptr<AddParticipantBoxController>(this);
|
auto weak = base::weak_unique_ptr<AddParticipantBoxController>(this);
|
||||||
auto alreadyIt = _additional.adminRights.find(user);
|
auto alreadyIt = _additional.adminRights.find(user);
|
||||||
|
auto hasAdminRights = false;
|
||||||
auto currentRights = EditAdminBox::DefaultRights(_channel);
|
auto currentRights = EditAdminBox::DefaultRights(_channel);
|
||||||
if (alreadyIt != _additional.adminRights.end() || _additional.creator == user) {
|
if (alreadyIt != _additional.adminRights.end() || _additional.creator == user) {
|
||||||
// The user is already an admin.
|
// The user is already an admin.
|
||||||
|
@ -621,6 +624,7 @@ void AddParticipantBoxController::editAdmin(gsl::not_null<UserData*> user, bool
|
||||||
Ui::show(Box<InformBox>(lang(lng_error_cant_edit_admin)), KeepOtherLayers);
|
Ui::show(Box<InformBox>(lang(lng_error_cant_edit_admin)), KeepOtherLayers);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
hasAdminRights = true;
|
||||||
currentRights = alreadyIt->second;
|
currentRights = alreadyIt->second;
|
||||||
} else if (_additional.kicked.find(user) != _additional.kicked.end()) {
|
} else if (_additional.kicked.find(user) != _additional.kicked.end()) {
|
||||||
// The user is banned.
|
// The user is banned.
|
||||||
|
@ -663,7 +667,7 @@ void AddParticipantBoxController::editAdmin(gsl::not_null<UserData*> user, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally edit the admin.
|
// Finally edit the admin.
|
||||||
_editBox = Ui::show(Box<EditAdminBox>(_channel, user, currentRights, [channel = _channel.get(), user, weak](const MTPChannelAdminRights &rights) {
|
_editBox = Ui::show(Box<EditAdminBox>(_channel, user, hasAdminRights, currentRights, [channel = _channel.get(), user, weak](const MTPChannelAdminRights &rights) {
|
||||||
MTP::send(MTPchannels_EditAdmin(channel->inputChannel, user->inputUser, rights), rpcDone([channel, user, weak, rights](const MTPUpdates &result) {
|
MTP::send(MTPchannels_EditAdmin(channel->inputChannel, user->inputUser, rights), rpcDone([channel, user, weak, rights](const MTPUpdates &result) {
|
||||||
AuthSession::Current().api().applyUpdates(result);
|
AuthSession::Current().api().applyUpdates(result);
|
||||||
channel->applyEditAdmin(user, rights);
|
channel->applyEditAdmin(user, rights);
|
||||||
|
@ -718,12 +722,14 @@ void AddParticipantBoxController::editRestricted(gsl::not_null<UserData*> user,
|
||||||
auto weak = base::weak_unique_ptr<AddParticipantBoxController>(this);
|
auto weak = base::weak_unique_ptr<AddParticipantBoxController>(this);
|
||||||
auto alreadyIt = _additional.restrictedRights.find(user);
|
auto alreadyIt = _additional.restrictedRights.find(user);
|
||||||
auto currentRights = EditRestrictedBox::DefaultRights(_channel);
|
auto currentRights = EditRestrictedBox::DefaultRights(_channel);
|
||||||
|
auto hasAdminRights = false;
|
||||||
if (alreadyIt != _additional.restrictedRights.end()) {
|
if (alreadyIt != _additional.restrictedRights.end()) {
|
||||||
// The user is already banned or restricted.
|
// The user is already banned or restricted.
|
||||||
currentRights = alreadyIt->second;
|
currentRights = alreadyIt->second;
|
||||||
} else if (_additional.adminRights.find(user) != _additional.adminRights.end() || _additional.creator == user) {
|
} else if (_additional.adminRights.find(user) != _additional.adminRights.end() || _additional.creator == user) {
|
||||||
// The user is an admin or creator.
|
// The user is an admin or creator.
|
||||||
if (_additional.adminCanEdit.find(user) != _additional.adminCanEdit.end()) {
|
if (_additional.adminCanEdit.find(user) != _additional.adminCanEdit.end()) {
|
||||||
|
hasAdminRights = true;
|
||||||
if (!sure) {
|
if (!sure) {
|
||||||
_editBox = Ui::show(Box<ConfirmBox>(lang(lng_sure_ban_admin), [weak, user] { weak->editRestricted(user, true); }), KeepOtherLayers);
|
_editBox = Ui::show(Box<ConfirmBox>(lang(lng_sure_ban_admin), [weak, user] { weak->editRestricted(user, true); }), KeepOtherLayers);
|
||||||
return;
|
return;
|
||||||
|
@ -735,7 +741,7 @@ void AddParticipantBoxController::editRestricted(gsl::not_null<UserData*> user,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally edit the restricted.
|
// Finally edit the restricted.
|
||||||
_editBox = Ui::show(Box<EditRestrictedBox>(_channel, user, currentRights, [user, weak](const MTPChannelBannedRights &rights) {
|
_editBox = Ui::show(Box<EditRestrictedBox>(_channel, user, hasAdminRights, currentRights, [user, weak](const MTPChannelBannedRights &rights) {
|
||||||
if (weak) {
|
if (weak) {
|
||||||
weak->restrictUserSure(user, rights);
|
weak->restrictUserSure(user, rights);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue