2019-01-07 12:55:49 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#include "boxes/peers/edit_participant_box.h"
|
|
|
|
|
|
|
|
#include "lang/lang_keys.h"
|
2019-01-08 10:54:18 +00:00
|
|
|
#include "ui/wrap/vertical_layout.h"
|
|
|
|
#include "ui/wrap/padding_wrap.h"
|
2019-06-14 12:01:35 +00:00
|
|
|
#include "ui/wrap/slide_wrap.h"
|
2019-01-07 12:55:49 +00:00
|
|
|
#include "ui/widgets/checkbox.h"
|
|
|
|
#include "ui/widgets/labels.h"
|
|
|
|
#include "ui/widgets/buttons.h"
|
2019-06-15 15:17:22 +00:00
|
|
|
#include "ui/toast/toast.h"
|
2019-06-14 12:01:35 +00:00
|
|
|
#include "ui/text/text_utilities.h"
|
2019-01-07 12:55:49 +00:00
|
|
|
#include "ui/text_options.h"
|
|
|
|
#include "ui/special_buttons.h"
|
2019-06-14 12:01:35 +00:00
|
|
|
#include "info/profile/info_profile_button.h"
|
|
|
|
#include "settings/settings_privacy_security.h"
|
2019-01-07 12:55:49 +00:00
|
|
|
#include "boxes/calendar_box.h"
|
2019-06-14 12:01:35 +00:00
|
|
|
#include "boxes/generic_box.h"
|
2019-06-14 14:04:30 +00:00
|
|
|
#include "boxes/confirm_box.h"
|
|
|
|
#include "boxes/passcode_box.h"
|
2019-01-07 12:55:49 +00:00
|
|
|
#include "boxes/peers/edit_peer_permissions_box.h"
|
2019-06-14 12:01:35 +00:00
|
|
|
#include "boxes/peers/edit_peer_info_box.h"
|
2019-01-07 12:55:49 +00:00
|
|
|
#include "data/data_peer_values.h"
|
|
|
|
#include "data/data_channel.h"
|
2019-01-10 06:26:08 +00:00
|
|
|
#include "data/data_chat.h"
|
2019-01-07 12:55:49 +00:00
|
|
|
#include "data/data_user.h"
|
2019-06-14 12:01:35 +00:00
|
|
|
#include "core/core_cloud_password.h"
|
|
|
|
#include "apiwrap.h"
|
|
|
|
#include "auth_session.h"
|
2019-01-07 12:55:49 +00:00
|
|
|
#include "styles/style_boxes.h"
|
2019-06-14 12:01:35 +00:00
|
|
|
#include "styles/style_info.h"
|
2019-01-07 12:55:49 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr auto kMaxRestrictDelayDays = 366;
|
|
|
|
constexpr auto kSecondsInDay = 24 * 60 * 60;
|
|
|
|
constexpr auto kSecondsInWeek = 7 * kSecondsInDay;
|
|
|
|
|
2019-06-14 12:01:35 +00:00
|
|
|
enum class PasswordErrorType {
|
|
|
|
None,
|
|
|
|
NoPassword,
|
|
|
|
Later,
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetCloudPassword(not_null<GenericBox*> box, not_null<UserData*> user) {
|
|
|
|
user->session().api().passwordState(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
using namespace Settings;
|
|
|
|
const auto weak = make_weak(box);
|
|
|
|
if (CheckEditCloudPassword()) {
|
|
|
|
box->getDelegate()->show(
|
|
|
|
EditCloudPasswordBox(&user->session()));
|
|
|
|
} else {
|
|
|
|
box->getDelegate()->show(CloudPasswordAppOutdatedBox());
|
|
|
|
}
|
|
|
|
if (weak) {
|
|
|
|
weak->closeBox();
|
|
|
|
}
|
|
|
|
}, box->lifetime());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransferPasswordError(
|
|
|
|
not_null<GenericBox*> box,
|
|
|
|
not_null<UserData*> user,
|
|
|
|
PasswordErrorType error) {
|
2019-06-18 15:00:55 +00:00
|
|
|
box->setTitle(tr::lng_rights_transfer_check());
|
2019-06-14 12:01:35 +00:00
|
|
|
box->setWidth(st::transferCheckWidth);
|
|
|
|
|
2019-06-18 16:53:27 +00:00
|
|
|
auto text = tr::lng_rights_transfer_check_about(
|
|
|
|
tr::now,
|
2019-06-14 12:01:35 +00:00
|
|
|
lt_user,
|
2019-06-18 16:53:27 +00:00
|
|
|
Ui::Text::Bold(user->shortName()),
|
|
|
|
Ui::Text::WithEntities
|
2019-06-14 12:01:35 +00:00
|
|
|
).append('\n').append('\n').append(
|
2019-06-18 16:53:27 +00:00
|
|
|
tr::lng_rights_transfer_check_password(
|
|
|
|
tr::now,
|
|
|
|
Ui::Text::RichLangValue)
|
2019-06-14 12:01:35 +00:00
|
|
|
).append('\n').append('\n').append(
|
2019-06-18 16:53:27 +00:00
|
|
|
tr::lng_rights_transfer_check_session(
|
|
|
|
tr::now,
|
|
|
|
Ui::Text::RichLangValue)
|
2019-06-14 12:01:35 +00:00
|
|
|
);
|
|
|
|
if (error == PasswordErrorType::Later) {
|
|
|
|
text.append('\n').append('\n').append(
|
2019-06-18 16:53:27 +00:00
|
|
|
tr::lng_rights_transfer_check_later(
|
|
|
|
tr::now,
|
|
|
|
Ui::Text::RichLangValue));
|
2019-06-14 12:01:35 +00:00
|
|
|
}
|
|
|
|
box->addRow(object_ptr<Ui::FlatLabel>(
|
|
|
|
box,
|
|
|
|
rpl::single(text),
|
|
|
|
st::boxLabel));
|
|
|
|
if (error == PasswordErrorType::Later) {
|
2019-06-18 16:53:27 +00:00
|
|
|
box->addButton(tr::lng_box_ok(), [=] { box->closeBox(); });
|
2019-06-14 12:01:35 +00:00
|
|
|
} else {
|
2019-06-18 16:53:27 +00:00
|
|
|
box->addButton(tr::lng_rights_transfer_set_password(), [=] {
|
2019-06-14 12:01:35 +00:00
|
|
|
SetCloudPassword(box, user);
|
|
|
|
});
|
2019-06-18 16:53:27 +00:00
|
|
|
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
2019-06-14 12:01:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-07 12:55:49 +00:00
|
|
|
} // namespace
|
|
|
|
|
2019-01-08 10:54:18 +00:00
|
|
|
class EditParticipantBox::Inner : public Ui::RpWidget {
|
2019-01-07 12:55:49 +00:00
|
|
|
public:
|
|
|
|
Inner(
|
|
|
|
QWidget *parent,
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> peer,
|
2019-01-07 12:55:49 +00:00
|
|
|
not_null<UserData*> user,
|
|
|
|
bool hasAdminRights);
|
|
|
|
|
|
|
|
template <typename Widget>
|
2019-01-08 10:54:18 +00:00
|
|
|
Widget *addControl(object_ptr<Widget> widget, QMargins margin);
|
2019-01-07 12:55:49 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
int resizeGetHeight(int newWidth) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> _peer;
|
2019-01-07 12:55:49 +00:00
|
|
|
not_null<UserData*> _user;
|
|
|
|
object_ptr<Ui::UserpicButton> _userPhoto;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _userName;
|
2019-01-07 12:55:49 +00:00
|
|
|
bool _hasAdminRights = false;
|
2019-01-08 10:54:18 +00:00
|
|
|
object_ptr<Ui::VerticalLayout> _rows;
|
2019-01-07 12:55:49 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
EditParticipantBox::Inner::Inner(
|
|
|
|
QWidget *parent,
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> peer,
|
2019-01-07 12:55:49 +00:00
|
|
|
not_null<UserData*> user,
|
|
|
|
bool hasAdminRights)
|
2019-01-08 10:54:18 +00:00
|
|
|
: RpWidget(parent)
|
2019-01-10 06:26:08 +00:00
|
|
|
, _peer(peer)
|
2019-01-07 12:55:49 +00:00
|
|
|
, _user(user)
|
|
|
|
, _userPhoto(
|
|
|
|
this,
|
|
|
|
_user,
|
|
|
|
Ui::UserpicButton::Role::Custom,
|
|
|
|
st::rightsPhotoButton)
|
2019-01-08 10:54:18 +00:00
|
|
|
, _hasAdminRights(hasAdminRights)
|
|
|
|
, _rows(this) {
|
|
|
|
_rows->heightValue(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
resizeToWidth(width());
|
|
|
|
}, lifetime());
|
|
|
|
|
2019-01-07 12:55:49 +00:00
|
|
|
_userPhoto->setPointerCursor(false);
|
|
|
|
_userName.setText(
|
|
|
|
st::rightsNameStyle,
|
|
|
|
App::peerName(_user),
|
|
|
|
Ui::NameTextOptions());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Widget>
|
2019-01-08 10:54:18 +00:00
|
|
|
Widget *EditParticipantBox::Inner::addControl(
|
2019-01-07 12:55:49 +00:00
|
|
|
object_ptr<Widget> widget,
|
|
|
|
QMargins margin) {
|
2019-01-08 10:54:18 +00:00
|
|
|
return _rows->add(std::move(widget), margin);
|
2019-01-07 12:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int EditParticipantBox::Inner::resizeGetHeight(int newWidth) {
|
|
|
|
_userPhoto->moveToLeft(
|
|
|
|
st::rightsPhotoMargin.left(),
|
|
|
|
st::rightsPhotoMargin.top());
|
2019-01-08 10:54:18 +00:00
|
|
|
const auto rowsTop = st::rightsPhotoMargin.top()
|
2019-01-07 12:55:49 +00:00
|
|
|
+ st::rightsPhotoButton.size.height()
|
|
|
|
+ st::rightsPhotoMargin.bottom();
|
2019-01-08 10:54:18 +00:00
|
|
|
_rows->resizeToWidth(newWidth);
|
|
|
|
_rows->moveToLeft(0, rowsTop, newWidth);
|
|
|
|
return rowsTop + _rows->heightNoMargins();
|
2019-01-07 12:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditParticipantBox::Inner::paintEvent(QPaintEvent *e) {
|
|
|
|
Painter p(this);
|
|
|
|
|
|
|
|
p.fillRect(e->rect(), st::boxBg);
|
|
|
|
|
|
|
|
p.setPen(st::contactsNameFg);
|
|
|
|
auto namex = st::rightsPhotoMargin.left()
|
|
|
|
+ st::rightsPhotoButton.size .width()
|
|
|
|
+ st::rightsPhotoMargin.right();
|
|
|
|
auto namew = width() - namex - st::rightsPhotoMargin.right();
|
|
|
|
_userName.drawLeftElided(
|
|
|
|
p,
|
|
|
|
namex,
|
|
|
|
st::rightsPhotoMargin.top() + st::rightsNameTop,
|
|
|
|
namew,
|
|
|
|
width());
|
|
|
|
auto statusText = [this] {
|
|
|
|
if (_user->botInfo) {
|
|
|
|
const auto seesAllMessages = _user->botInfo->readsAllHistory
|
|
|
|
|| _hasAdminRights;
|
2019-06-19 15:09:03 +00:00
|
|
|
return (seesAllMessages
|
|
|
|
? tr::lng_status_bot_reads_all
|
|
|
|
: tr::lng_status_bot_not_reads_all)(tr::now);
|
2019-01-07 12:55:49 +00:00
|
|
|
}
|
|
|
|
return Data::OnlineText(_user->onlineTill, unixtime());
|
|
|
|
};
|
|
|
|
p.setFont(st::contactsStatusFont);
|
|
|
|
p.setPen(st::contactsStatusFg);
|
|
|
|
p.drawTextLeft(
|
|
|
|
namex,
|
|
|
|
st::rightsPhotoMargin.top() + st::rightsStatusTop,
|
|
|
|
width(),
|
|
|
|
statusText());
|
|
|
|
}
|
|
|
|
|
|
|
|
EditParticipantBox::EditParticipantBox(
|
|
|
|
QWidget*,
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> peer,
|
2019-01-07 12:55:49 +00:00
|
|
|
not_null<UserData*> user,
|
|
|
|
bool hasAdminRights)
|
2019-01-10 06:26:08 +00:00
|
|
|
: _peer(peer)
|
2019-01-07 12:55:49 +00:00
|
|
|
, _user(user)
|
|
|
|
, _hasAdminRights(hasAdminRights) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditParticipantBox::prepare() {
|
|
|
|
_inner = setInnerWidget(object_ptr<Inner>(
|
|
|
|
this,
|
2019-01-10 06:26:08 +00:00
|
|
|
_peer,
|
2019-01-07 12:55:49 +00:00
|
|
|
_user,
|
|
|
|
hasAdminRights()));
|
2019-01-08 10:54:18 +00:00
|
|
|
setDimensionsToContent(st::boxWideWidth, _inner);
|
2019-01-07 12:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Widget>
|
2019-01-08 10:54:18 +00:00
|
|
|
Widget *EditParticipantBox::addControl(
|
2019-01-07 12:55:49 +00:00
|
|
|
object_ptr<Widget> widget,
|
|
|
|
QMargins margin) {
|
|
|
|
Expects(_inner != nullptr);
|
|
|
|
|
|
|
|
return _inner->addControl(std::move(widget), margin);
|
|
|
|
}
|
|
|
|
|
|
|
|
EditAdminBox::EditAdminBox(
|
|
|
|
QWidget*,
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> peer,
|
2019-01-07 12:55:49 +00:00
|
|
|
not_null<UserData*> user,
|
|
|
|
const MTPChatAdminRights &rights)
|
|
|
|
: EditParticipantBox(
|
|
|
|
nullptr,
|
2019-01-10 06:26:08 +00:00
|
|
|
peer,
|
2019-01-07 12:55:49 +00:00
|
|
|
user,
|
|
|
|
(rights.c_chatAdminRights().vflags.v != 0))
|
|
|
|
, _oldRights(rights) {
|
|
|
|
}
|
|
|
|
|
2019-01-10 06:26:08 +00:00
|
|
|
MTPChatAdminRights EditAdminBox::Defaults(not_null<PeerData*> peer) {
|
|
|
|
const auto defaultRights = peer->isChat()
|
|
|
|
? ChatData::DefaultAdminRights()
|
|
|
|
: peer->isMegagroup()
|
2019-01-07 12:55:49 +00:00
|
|
|
? (Flag::f_change_info
|
|
|
|
| Flag::f_delete_messages
|
|
|
|
| Flag::f_ban_users
|
|
|
|
| Flag::f_invite_users
|
|
|
|
| Flag::f_pin_messages)
|
|
|
|
: (Flag::f_change_info
|
|
|
|
| Flag::f_post_messages
|
|
|
|
| Flag::f_edit_messages
|
|
|
|
| Flag::f_delete_messages
|
|
|
|
| Flag::f_invite_users);
|
|
|
|
return MTP_chatAdminRights(MTP_flags(defaultRights));
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditAdminBox::prepare() {
|
|
|
|
using namespace rpl::mappers;
|
|
|
|
|
|
|
|
EditParticipantBox::prepare();
|
|
|
|
|
|
|
|
auto hadRights = _oldRights.c_chatAdminRights().vflags.v;
|
2019-06-18 15:00:55 +00:00
|
|
|
setTitle(hadRights
|
|
|
|
? tr::lng_rights_edit_admin()
|
|
|
|
: tr::lng_channel_add_admin());
|
2019-01-07 12:55:49 +00:00
|
|
|
|
2019-01-08 10:54:18 +00:00
|
|
|
addControl(
|
|
|
|
object_ptr<BoxContentDivider>(this),
|
|
|
|
st::rightsDividerMargin);
|
2019-01-07 12:55:49 +00:00
|
|
|
|
2019-01-10 06:26:08 +00:00
|
|
|
const auto chat = peer()->asChat();
|
|
|
|
const auto channel = peer()->asChannel();
|
|
|
|
const auto prepareRights = hadRights ? _oldRights : Defaults(peer());
|
2019-02-01 12:50:57 +00:00
|
|
|
const auto disabledByDefaults = (channel && !channel->isMegagroup())
|
|
|
|
? MTPDchatAdminRights::Flags(0)
|
|
|
|
: DisabledByDefaultRestrictions(peer());
|
2019-01-07 12:55:49 +00:00
|
|
|
const auto filterByMyRights = canSave()
|
|
|
|
&& !hadRights
|
2019-01-10 06:26:08 +00:00
|
|
|
&& channel
|
|
|
|
&& !channel->amCreator();
|
2019-01-14 06:34:51 +00:00
|
|
|
const auto prepareFlags = disabledByDefaults
|
|
|
|
| (prepareRights.c_chatAdminRights().vflags.v
|
|
|
|
& (filterByMyRights ? channel->adminRights() : ~Flag(0)));
|
2019-01-07 12:55:49 +00:00
|
|
|
|
2019-01-21 10:22:18 +00:00
|
|
|
const auto disabledMessages = [&] {
|
|
|
|
auto result = std::map<Flags, QString>();
|
|
|
|
if (!canSave()) {
|
|
|
|
result.emplace(
|
|
|
|
~Flags(0),
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_rights_about_admin_cant_edit(tr::now));
|
2019-01-21 10:22:18 +00:00
|
|
|
} else {
|
|
|
|
result.emplace(
|
|
|
|
disabledByDefaults,
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_rights_permission_for_all(tr::now));
|
2019-01-21 10:22:18 +00:00
|
|
|
if (const auto channel = peer()->asChannel()) {
|
|
|
|
if (!channel->amCreator()) {
|
|
|
|
result.emplace(
|
|
|
|
~channel->adminRights(),
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_rights_permission_cant_edit(tr::now));
|
2019-01-21 10:22:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}();
|
2019-01-07 12:55:49 +00:00
|
|
|
|
2019-06-14 12:01:35 +00:00
|
|
|
const auto isGroup = chat || channel->isMegagroup();
|
2019-01-10 06:26:08 +00:00
|
|
|
const auto anyoneCanAddMembers = chat
|
|
|
|
? chat->anyoneCanAddMembers()
|
|
|
|
: channel->anyoneCanAddMembers();
|
2019-01-07 12:55:49 +00:00
|
|
|
auto [checkboxes, getChecked, changes] = CreateEditAdminRights(
|
|
|
|
this,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_rights_edit_admin_header(),
|
2019-01-07 12:55:49 +00:00
|
|
|
prepareFlags,
|
2019-01-21 10:22:18 +00:00
|
|
|
disabledMessages,
|
2019-06-14 12:01:35 +00:00
|
|
|
isGroup,
|
2019-01-10 06:26:08 +00:00
|
|
|
anyoneCanAddMembers);
|
2019-01-07 12:55:49 +00:00
|
|
|
addControl(std::move(checkboxes), QMargins());
|
|
|
|
|
2019-06-14 12:01:35 +00:00
|
|
|
auto selectedFlags = rpl::single(
|
2019-01-07 12:55:49 +00:00
|
|
|
getChecked()
|
|
|
|
) | rpl::then(std::move(
|
|
|
|
changes
|
2019-06-14 12:01:35 +00:00
|
|
|
));
|
|
|
|
if (canTransferOwnership()) {
|
|
|
|
const auto allFlags = FullAdminRights(isGroup);
|
|
|
|
setupTransferButton(
|
|
|
|
isGroup
|
|
|
|
)->toggleOn(rpl::duplicate(
|
|
|
|
selectedFlags
|
|
|
|
) | rpl::map(
|
|
|
|
((_1 & allFlags) == allFlags)
|
|
|
|
))->setDuration(0);
|
|
|
|
}
|
|
|
|
_aboutAddAdmins = addControl(
|
|
|
|
object_ptr<Ui::FlatLabel>(this, st::boxLabel),
|
|
|
|
st::rightsAboutMargin);
|
|
|
|
std::move(
|
|
|
|
selectedFlags
|
|
|
|
) | rpl::map(
|
2019-01-07 12:55:49 +00:00
|
|
|
(_1 & Flag::f_add_admins) != 0
|
|
|
|
) | rpl::distinct_until_changed(
|
|
|
|
) | rpl::start_with_next([=](bool checked) {
|
|
|
|
refreshAboutAddAdminsText(checked);
|
|
|
|
}, lifetime());
|
|
|
|
|
|
|
|
if (canSave()) {
|
2019-06-18 16:53:27 +00:00
|
|
|
addButton(tr::lng_settings_save(), [=, value = getChecked] {
|
2019-01-07 12:55:49 +00:00
|
|
|
if (!_saveCallback) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto newFlags = value()
|
2019-01-10 06:26:08 +00:00
|
|
|
& ((!channel || channel->amCreator())
|
2019-01-07 12:55:49 +00:00
|
|
|
? ~Flags(0)
|
2019-01-10 06:26:08 +00:00
|
|
|
: channel->adminRights());
|
2019-01-07 12:55:49 +00:00
|
|
|
_saveCallback(
|
|
|
|
_oldRights,
|
|
|
|
MTP_chatAdminRights(MTP_flags(newFlags)));
|
|
|
|
});
|
2019-06-18 16:53:27 +00:00
|
|
|
addButton(tr::lng_cancel(), [this] { closeBox(); });
|
2019-01-07 12:55:49 +00:00
|
|
|
} else {
|
2019-06-18 16:53:27 +00:00
|
|
|
addButton(tr::lng_box_ok(), [this] { closeBox(); });
|
2019-01-07 12:55:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-14 12:01:35 +00:00
|
|
|
bool EditAdminBox::canTransferOwnership() const {
|
2019-07-04 12:02:25 +00:00
|
|
|
if (user()->isInaccessible() || user()->isBot() || user()->isSelf()) {
|
2019-06-14 12:01:35 +00:00
|
|
|
return false;
|
|
|
|
} else if (const auto chat = peer()->asChat()) {
|
|
|
|
return chat->amCreator();
|
|
|
|
} else if (const auto channel = peer()->asChannel()) {
|
|
|
|
return channel->amCreator();
|
|
|
|
}
|
|
|
|
Unexpected("Chat type in EditAdminBox::canTransferOwnership.");
|
|
|
|
}
|
|
|
|
|
|
|
|
not_null<Ui::SlideWrap<Ui::RpWidget>*> EditAdminBox::setupTransferButton(
|
|
|
|
bool isGroup) {
|
|
|
|
const auto wrap = addControl(
|
|
|
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
|
|
|
this,
|
|
|
|
object_ptr<Ui::VerticalLayout>(this)));
|
|
|
|
|
|
|
|
const auto container = wrap->entity();
|
|
|
|
const auto addDivider = [&] {
|
|
|
|
container->add(
|
|
|
|
object_ptr<BoxContentDivider>(container),
|
|
|
|
{ 0, st::infoProfileSkip, 0, st::infoProfileSkip });
|
|
|
|
};
|
|
|
|
|
|
|
|
addDivider();
|
|
|
|
container->add(EditPeerInfoBox::CreateButton(
|
|
|
|
this,
|
2019-06-18 12:16:43 +00:00
|
|
|
(isGroup
|
|
|
|
? tr::lng_rights_transfer_group
|
|
|
|
: tr::lng_rights_transfer_channel)(),
|
2019-06-14 12:01:35 +00:00
|
|
|
rpl::single(QString()),
|
|
|
|
[=] { transferOwnership(); },
|
|
|
|
st::peerPermissionsButton));
|
|
|
|
addDivider();
|
|
|
|
|
|
|
|
return wrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditAdminBox::transferOwnership() {
|
|
|
|
if (_checkTransferRequestId) {
|
|
|
|
return;
|
|
|
|
}
|
2019-06-14 14:04:30 +00:00
|
|
|
|
2019-06-14 12:01:35 +00:00
|
|
|
const auto channel = peer()->isChannel()
|
|
|
|
? peer()->asChannel()->inputChannel
|
|
|
|
: MTP_inputChannelEmpty();
|
|
|
|
const auto api = &peer()->session().api();
|
2019-06-14 14:04:30 +00:00
|
|
|
api->reloadPasswordState();
|
2019-06-14 12:01:35 +00:00
|
|
|
_checkTransferRequestId = api->request(MTPchannels_EditCreator(
|
|
|
|
channel,
|
|
|
|
MTP_inputUserEmpty(),
|
|
|
|
MTP_inputCheckPasswordEmpty()
|
|
|
|
)).fail([=](const RPCError &error) {
|
|
|
|
_checkTransferRequestId = 0;
|
|
|
|
if (!handleTransferPasswordError(error)) {
|
2019-06-17 11:40:40 +00:00
|
|
|
getDelegate()->show(Box<ConfirmBox>(
|
|
|
|
tr::lng_rights_transfer_about(
|
|
|
|
tr::now,
|
|
|
|
lt_group,
|
|
|
|
Ui::Text::Bold(peer()->name),
|
|
|
|
lt_user,
|
|
|
|
Ui::Text::Bold(user()->shortName()),
|
|
|
|
Ui::Text::RichLangValue),
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_rights_transfer_sure(tr::now),
|
2019-06-17 11:40:40 +00:00
|
|
|
crl::guard(this, [=] { transferOwnershipChecked(); })));
|
2019-06-14 12:01:35 +00:00
|
|
|
}
|
|
|
|
}).send();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EditAdminBox::handleTransferPasswordError(const RPCError &error) {
|
|
|
|
const auto type = [&] {
|
|
|
|
const auto &type = error.type();
|
|
|
|
if (type == qstr("PASSWORD_MISSING")) {
|
|
|
|
return PasswordErrorType::NoPassword;
|
|
|
|
} else if (type.startsWith(qstr("PASSWORD_TOO_FRESH_"))
|
|
|
|
|| type.startsWith(qstr("SESSION_TOO_FRESH_"))) {
|
|
|
|
return PasswordErrorType::Later;
|
|
|
|
}
|
|
|
|
return PasswordErrorType::None;
|
|
|
|
}();
|
|
|
|
if (type == PasswordErrorType::None) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
getDelegate()->show(Box(TransferPasswordError, user(), type));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-06-14 14:04:30 +00:00
|
|
|
void EditAdminBox::transferOwnershipChecked() {
|
|
|
|
if (const auto chat = peer()->asChatNotMigrated()) {
|
|
|
|
peer()->session().api().migrateChat(chat, crl::guard(this, [=](
|
|
|
|
not_null<ChannelData*> channel) {
|
|
|
|
requestTransferPassword(channel);
|
|
|
|
}));
|
|
|
|
} else if (const auto channel = peer()->asChannelOrMigrated()) {
|
|
|
|
requestTransferPassword(channel);
|
|
|
|
} else {
|
|
|
|
Unexpected("Peer in SaveAdminCallback.");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditAdminBox::requestTransferPassword(not_null<ChannelData*> channel) {
|
|
|
|
peer()->session().api().passwordState(
|
|
|
|
) | rpl::take(
|
|
|
|
1
|
|
|
|
) | rpl::start_with_next([=](const Core::CloudPasswordState &state) {
|
|
|
|
const auto box = std::make_shared<QPointer<PasscodeBox>>();
|
|
|
|
auto fields = PasscodeBox::CloudFields::From(state);
|
2019-06-19 11:22:25 +00:00
|
|
|
fields.customTitle = tr::lng_rights_transfer_password_title();
|
2019-06-14 14:04:30 +00:00
|
|
|
fields.customDescription
|
2019-06-19 15:09:03 +00:00
|
|
|
= tr::lng_rights_transfer_password_description(tr::now);
|
2019-06-19 11:22:25 +00:00
|
|
|
fields.customSubmitButton = tr::lng_passcode_submit();
|
2019-06-14 14:04:30 +00:00
|
|
|
fields.customCheckCallback = crl::guard(this, [=](
|
|
|
|
const Core::CloudPasswordResult &result) {
|
|
|
|
sendTransferRequestFrom(*box, channel, result);
|
|
|
|
});
|
|
|
|
*box = getDelegate()->show(Box<PasscodeBox>(fields));
|
|
|
|
}, lifetime());
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditAdminBox::sendTransferRequestFrom(
|
|
|
|
QPointer<PasscodeBox> box,
|
|
|
|
not_null<ChannelData*> channel,
|
|
|
|
const Core::CloudPasswordResult &result) {
|
2019-06-15 15:17:22 +00:00
|
|
|
if (_transferRequestId) {
|
|
|
|
return;
|
|
|
|
}
|
2019-06-14 14:04:30 +00:00
|
|
|
const auto weak = make_weak(this);
|
2019-06-15 15:17:22 +00:00
|
|
|
const auto user = this->user();
|
|
|
|
const auto api = &channel->session().api();
|
|
|
|
_transferRequestId = api->request(MTPchannels_EditCreator(
|
2019-06-14 14:04:30 +00:00
|
|
|
channel->inputChannel,
|
2019-06-15 15:17:22 +00:00
|
|
|
user->inputUser,
|
2019-06-14 14:04:30 +00:00
|
|
|
result.result
|
|
|
|
)).done([=](const MTPUpdates &result) {
|
2019-06-15 15:17:22 +00:00
|
|
|
api->applyUpdates(result);
|
|
|
|
Ui::Toast::Show((channel->isBroadcast()
|
2019-06-19 16:39:25 +00:00
|
|
|
? tr::lng_rights_transfer_done_channel
|
|
|
|
: tr::lng_rights_transfer_done_group)(
|
|
|
|
tr::now,
|
|
|
|
lt_user,
|
|
|
|
user->shortName()));
|
2019-06-15 15:17:22 +00:00
|
|
|
Ui::hideLayer();
|
|
|
|
}).fail(crl::guard(this, [=](const RPCError &error) {
|
2019-06-14 14:04:30 +00:00
|
|
|
if (weak) {
|
2019-06-15 15:17:22 +00:00
|
|
|
_transferRequestId = 0;
|
2019-06-14 14:04:30 +00:00
|
|
|
}
|
|
|
|
if (box && box->handleCustomCheckError(error)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &type = error.type();
|
|
|
|
const auto problem = [&] {
|
|
|
|
if (type == qstr("CHANNELS_ADMIN_PUBLIC_TOO_MUCH")) {
|
2019-06-19 15:09:03 +00:00
|
|
|
return tr::lng_channels_too_much_public_other(tr::now);
|
2019-06-21 12:27:46 +00:00
|
|
|
} else if (type == qstr("CHANNELS_ADMIN_LOCATED_TOO_MUCH")) {
|
|
|
|
return tr::lng_channels_too_much_located_other(tr::now);
|
2019-06-14 14:04:30 +00:00
|
|
|
} else if (type == qstr("ADMINS_TOO_MUCH")) {
|
2019-06-19 15:09:03 +00:00
|
|
|
return (channel->isBroadcast()
|
|
|
|
? tr::lng_error_admin_limit_channel
|
|
|
|
: tr::lng_error_admin_limit)(tr::now);
|
2019-06-14 14:04:30 +00:00
|
|
|
} else if (type == qstr("CHANNEL_INVALID")) {
|
2019-06-19 15:09:03 +00:00
|
|
|
return (channel->isBroadcast()
|
|
|
|
? tr::lng_channel_not_accessible
|
|
|
|
: tr::lng_group_not_accessible)(tr::now);
|
2019-06-14 14:04:30 +00:00
|
|
|
}
|
|
|
|
return Lang::Hard::ServerError();
|
|
|
|
}();
|
|
|
|
const auto recoverable = [&] {
|
|
|
|
return (type == qstr("PASSWORD_MISSING"))
|
|
|
|
|| (type == qstr("PASSWORD_TOO_FRESH_XXX"))
|
|
|
|
|| (type == qstr("SESSION_TOO_FRESH_XXX"));
|
|
|
|
}();
|
|
|
|
const auto weak = make_weak(this);
|
|
|
|
getDelegate()->show(Box<InformBox>(problem));
|
|
|
|
if (box) {
|
|
|
|
box->closeBox();
|
|
|
|
}
|
|
|
|
if (weak && !recoverable) {
|
|
|
|
closeBox();
|
|
|
|
}
|
2019-06-24 13:14:07 +00:00
|
|
|
})).handleFloodErrors().send();
|
2019-06-14 12:01:35 +00:00
|
|
|
}
|
|
|
|
|
2019-01-07 12:55:49 +00:00
|
|
|
void EditAdminBox::refreshAboutAddAdminsText(bool canAddAdmins) {
|
|
|
|
_aboutAddAdmins->setText([&] {
|
|
|
|
if (!canSave()) {
|
2019-06-19 15:09:03 +00:00
|
|
|
return tr::lng_rights_about_admin_cant_edit(tr::now);
|
2019-01-07 12:55:49 +00:00
|
|
|
} else if (canAddAdmins) {
|
2019-06-19 15:09:03 +00:00
|
|
|
return tr::lng_rights_about_add_admins_yes(tr::now);
|
2019-01-07 12:55:49 +00:00
|
|
|
}
|
2019-06-19 15:09:03 +00:00
|
|
|
return tr::lng_rights_about_add_admins_no(tr::now);
|
2019-01-07 12:55:49 +00:00
|
|
|
}());
|
|
|
|
}
|
|
|
|
|
|
|
|
EditRestrictedBox::EditRestrictedBox(
|
|
|
|
QWidget*,
|
2019-01-10 06:26:08 +00:00
|
|
|
not_null<PeerData*> peer,
|
2019-01-07 12:55:49 +00:00
|
|
|
not_null<UserData*> user,
|
|
|
|
bool hasAdminRights,
|
|
|
|
const MTPChatBannedRights &rights)
|
2019-01-10 06:26:08 +00:00
|
|
|
: EditParticipantBox(nullptr, peer, user, hasAdminRights)
|
2019-01-07 12:55:49 +00:00
|
|
|
, _oldRights(rights) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditRestrictedBox::prepare() {
|
|
|
|
EditParticipantBox::prepare();
|
|
|
|
|
2019-06-18 15:00:55 +00:00
|
|
|
setTitle(tr::lng_rights_user_restrictions());
|
2019-01-07 12:55:49 +00:00
|
|
|
|
2019-01-08 10:54:18 +00:00
|
|
|
addControl(
|
|
|
|
object_ptr<BoxContentDivider>(this),
|
|
|
|
st::rightsDividerMargin);
|
2019-01-07 12:55:49 +00:00
|
|
|
|
2019-01-10 06:26:08 +00:00
|
|
|
const auto chat = peer()->asChat();
|
|
|
|
const auto channel = peer()->asChannel();
|
|
|
|
const auto defaultRestrictions = chat
|
|
|
|
? chat->defaultRestrictions()
|
|
|
|
: channel->defaultRestrictions();
|
2019-01-08 13:57:22 +00:00
|
|
|
const auto prepareRights = (_oldRights.c_chatBannedRights().vflags.v
|
2019-01-07 12:55:49 +00:00
|
|
|
? _oldRights
|
2019-01-10 06:26:08 +00:00
|
|
|
: Defaults(peer()));
|
2019-02-13 12:18:03 +00:00
|
|
|
const auto prepareFlags = FixDependentRestrictions(
|
|
|
|
prepareRights.c_chatBannedRights().vflags.v
|
2019-01-10 06:26:08 +00:00
|
|
|
| defaultRestrictions
|
|
|
|
| ((channel && channel->isPublic())
|
|
|
|
? (Flag::f_change_info | Flag::f_pin_messages)
|
2019-02-13 12:18:03 +00:00
|
|
|
: Flags(0)));
|
2019-01-21 10:22:18 +00:00
|
|
|
const auto disabledMessages = [&] {
|
|
|
|
auto result = std::map<Flags, QString>();
|
|
|
|
if (!canSave()) {
|
|
|
|
result.emplace(
|
|
|
|
~Flags(0),
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_rights_about_restriction_cant_edit(tr::now));
|
2019-01-21 10:22:18 +00:00
|
|
|
} else {
|
2019-02-13 12:18:03 +00:00
|
|
|
const auto disabled = FixDependentRestrictions(
|
|
|
|
defaultRestrictions
|
2019-01-21 10:22:18 +00:00
|
|
|
| ((channel && channel->isPublic())
|
|
|
|
? (Flag::f_change_info | Flag::f_pin_messages)
|
2019-02-13 12:18:03 +00:00
|
|
|
: Flags(0)));
|
2019-01-21 10:22:18 +00:00
|
|
|
result.emplace(
|
|
|
|
disabled,
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_rights_restriction_for_all(tr::now));
|
2019-01-21 10:22:18 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}();
|
2019-01-07 12:55:49 +00:00
|
|
|
|
2019-01-08 10:54:18 +00:00
|
|
|
auto [checkboxes, getRestrictions, changes] = CreateEditRestrictions(
|
2019-01-07 12:55:49 +00:00
|
|
|
this,
|
2019-06-18 12:16:43 +00:00
|
|
|
tr::lng_rights_user_restrictions_header(),
|
2019-01-08 13:57:22 +00:00
|
|
|
prepareFlags,
|
2019-01-21 10:22:18 +00:00
|
|
|
disabledMessages);
|
2019-01-07 12:55:49 +00:00
|
|
|
addControl(std::move(checkboxes), QMargins());
|
|
|
|
|
|
|
|
_until = prepareRights.c_chatBannedRights().vuntil_date.v;
|
|
|
|
addControl(object_ptr<BoxContentDivider>(this), st::rightsUntilMargin);
|
|
|
|
addControl(
|
|
|
|
object_ptr<Ui::FlatLabel>(
|
|
|
|
this,
|
2019-06-19 15:09:03 +00:00
|
|
|
tr::lng_rights_chat_banned_until_header(tr::now),
|
2019-01-07 12:55:49 +00:00
|
|
|
st::rightsHeaderLabel),
|
|
|
|
st::rightsHeaderMargin);
|
|
|
|
setRestrictUntil(_until);
|
|
|
|
|
|
|
|
//addControl(
|
|
|
|
// object_ptr<Ui::LinkButton>(
|
|
|
|
// this,
|
2019-06-19 15:09:03 +00:00
|
|
|
// tr::lng_rights_chat_banned_block(tr::now),
|
2019-01-07 12:55:49 +00:00
|
|
|
// st::boxLinkButton));
|
|
|
|
|
|
|
|
if (canSave()) {
|
2019-01-08 10:54:18 +00:00
|
|
|
const auto save = [=, value = getRestrictions] {
|
2019-01-07 12:55:49 +00:00
|
|
|
if (!_saveCallback) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_saveCallback(
|
|
|
|
_oldRights,
|
|
|
|
MTP_chatBannedRights(
|
|
|
|
MTP_flags(value()),
|
|
|
|
MTP_int(getRealUntilValue())));
|
2019-01-08 10:54:18 +00:00
|
|
|
};
|
2019-06-18 16:53:27 +00:00
|
|
|
addButton(tr::lng_settings_save(), save);
|
|
|
|
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
2019-01-07 12:55:49 +00:00
|
|
|
} else {
|
2019-06-18 16:53:27 +00:00
|
|
|
addButton(tr::lng_box_ok(), [=] { closeBox(); });
|
2019-01-07 12:55:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-10 06:26:08 +00:00
|
|
|
MTPChatBannedRights EditRestrictedBox::Defaults(not_null<PeerData*> peer) {
|
2019-01-08 13:57:22 +00:00
|
|
|
return MTP_chatBannedRights(MTP_flags(0), MTP_int(0));
|
2019-01-07 12:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditRestrictedBox::showRestrictUntil() {
|
|
|
|
auto tomorrow = QDate::currentDate().addDays(1);
|
|
|
|
auto highlighted = isUntilForever()
|
|
|
|
? tomorrow
|
|
|
|
: ParseDateTime(getRealUntilValue()).date();
|
|
|
|
auto month = highlighted;
|
|
|
|
_restrictUntilBox = Ui::show(
|
|
|
|
Box<CalendarBox>(
|
|
|
|
month,
|
|
|
|
highlighted,
|
|
|
|
[this](const QDate &date) {
|
|
|
|
setRestrictUntil(
|
|
|
|
static_cast<int>(QDateTime(date).toTime_t()));
|
|
|
|
}),
|
|
|
|
LayerOption::KeepOther);
|
|
|
|
_restrictUntilBox->setMaxDate(
|
|
|
|
QDate::currentDate().addDays(kMaxRestrictDelayDays));
|
|
|
|
_restrictUntilBox->setMinDate(tomorrow);
|
|
|
|
_restrictUntilBox->addLeftButton(
|
2019-06-18 16:53:27 +00:00
|
|
|
tr::lng_rights_chat_banned_forever(),
|
2019-01-07 12:55:49 +00:00
|
|
|
[=] { setRestrictUntil(0); });
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditRestrictedBox::setRestrictUntil(TimeId until) {
|
|
|
|
_until = until;
|
|
|
|
if (_restrictUntilBox) {
|
|
|
|
_restrictUntilBox->closeBox();
|
|
|
|
}
|
2019-01-08 10:54:18 +00:00
|
|
|
_untilVariants.clear();
|
2019-01-07 12:55:49 +00:00
|
|
|
createUntilGroup();
|
|
|
|
createUntilVariants();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EditRestrictedBox::isUntilForever() const {
|
|
|
|
return ChannelData::IsRestrictedForever(_until);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditRestrictedBox::createUntilGroup() {
|
|
|
|
_untilGroup = std::make_shared<Ui::RadiobuttonGroup>(
|
|
|
|
isUntilForever() ? 0 : _until);
|
|
|
|
_untilGroup->setChangedCallback([this](int value) {
|
|
|
|
if (value == kUntilCustom) {
|
|
|
|
_untilGroup->setValue(_until);
|
|
|
|
showRestrictUntil();
|
|
|
|
} else if (_until != value) {
|
|
|
|
_until = value;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditRestrictedBox::createUntilVariants() {
|
|
|
|
auto addVariant = [&](int value, const QString &text) {
|
|
|
|
if (!canSave() && _untilGroup->value() != value) {
|
|
|
|
return;
|
|
|
|
}
|
2019-01-21 10:22:18 +00:00
|
|
|
_untilVariants.emplace_back(
|
2019-01-08 10:54:18 +00:00
|
|
|
addControl(
|
|
|
|
object_ptr<Ui::Radiobutton>(
|
|
|
|
this,
|
|
|
|
_untilGroup,
|
|
|
|
value,
|
|
|
|
text,
|
2019-05-01 11:31:06 +00:00
|
|
|
st::defaultCheckbox),
|
2019-01-21 10:22:18 +00:00
|
|
|
st::rightsToggleMargin));
|
2019-01-07 12:55:49 +00:00
|
|
|
if (!canSave()) {
|
|
|
|
_untilVariants.back()->setDisabled(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
auto addCustomVariant = [&](TimeId until, TimeId from, TimeId to) {
|
|
|
|
if (!ChannelData::IsRestrictedForever(until)
|
|
|
|
&& until > from
|
|
|
|
&& until <= to) {
|
|
|
|
addVariant(
|
|
|
|
until,
|
2019-06-19 16:39:25 +00:00
|
|
|
tr::lng_rights_chat_banned_custom_date(
|
|
|
|
tr::now,
|
2019-01-07 12:55:49 +00:00
|
|
|
lt_date,
|
|
|
|
langDayOfMonthFull(ParseDateTime(until).date())));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
auto addCurrentVariant = [&](TimeId from, TimeId to) {
|
|
|
|
auto oldUntil = _oldRights.c_chatBannedRights().vuntil_date.v;
|
|
|
|
if (oldUntil < _until) {
|
|
|
|
addCustomVariant(oldUntil, from, to);
|
|
|
|
}
|
|
|
|
addCustomVariant(_until, from, to);
|
|
|
|
if (oldUntil > _until) {
|
|
|
|
addCustomVariant(oldUntil, from, to);
|
|
|
|
}
|
|
|
|
};
|
2019-06-19 15:09:03 +00:00
|
|
|
addVariant(0, tr::lng_rights_chat_banned_forever(tr::now));
|
2019-01-07 12:55:49 +00:00
|
|
|
|
|
|
|
auto now = unixtime();
|
|
|
|
auto nextDay = now + kSecondsInDay;
|
|
|
|
auto nextWeek = now + kSecondsInWeek;
|
|
|
|
addCurrentVariant(0, nextDay);
|
2019-06-19 16:39:25 +00:00
|
|
|
addVariant(kUntilOneDay, tr::lng_rights_chat_banned_day(tr::now, lt_count, 1));
|
2019-01-07 12:55:49 +00:00
|
|
|
addCurrentVariant(nextDay, nextWeek);
|
2019-06-19 16:39:25 +00:00
|
|
|
addVariant(kUntilOneWeek, tr::lng_rights_chat_banned_week(tr::now, lt_count, 1));
|
2019-01-07 12:55:49 +00:00
|
|
|
addCurrentVariant(nextWeek, INT_MAX);
|
2019-06-19 15:09:03 +00:00
|
|
|
addVariant(kUntilCustom, tr::lng_rights_chat_banned_custom(tr::now));
|
2019-01-07 12:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TimeId EditRestrictedBox::getRealUntilValue() const {
|
|
|
|
Expects(_until != kUntilCustom);
|
|
|
|
if (_until == kUntilOneDay) {
|
|
|
|
return unixtime() + kSecondsInDay;
|
|
|
|
} else if (_until == kUntilOneWeek) {
|
|
|
|
return unixtime() + kSecondsInWeek;
|
|
|
|
}
|
|
|
|
Assert(_until >= 0);
|
|
|
|
return _until;
|
|
|
|
}
|