mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Handle bot callback buttons with password.
This commit is contained in:
@@ -47,70 +47,6 @@ constexpr auto kSecondsInDay = 24 * 60 * 60;
|
||||
constexpr auto kSecondsInWeek = 7 * kSecondsInDay;
|
||||
constexpr auto kAdminRoleLimit = 16;
|
||||
|
||||
enum class PasswordErrorType {
|
||||
None,
|
||||
NoPassword,
|
||||
Later,
|
||||
};
|
||||
|
||||
void SetCloudPassword(not_null<Ui::GenericBox*> box, not_null<UserData*> user) {
|
||||
user->session().api().passwordState(
|
||||
) | rpl::start_with_next([=] {
|
||||
using namespace Settings;
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
if (CheckEditCloudPassword(&user->session())) {
|
||||
box->getDelegate()->show(
|
||||
EditCloudPasswordBox(&user->session()));
|
||||
} else {
|
||||
box->getDelegate()->show(CloudPasswordAppOutdatedBox());
|
||||
}
|
||||
if (weak) {
|
||||
weak->closeBox();
|
||||
}
|
||||
}, box->lifetime());
|
||||
}
|
||||
|
||||
void TransferPasswordError(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<UserData*> user,
|
||||
PasswordErrorType error) {
|
||||
box->setTitle(tr::lng_rights_transfer_check());
|
||||
box->setWidth(st::transferCheckWidth);
|
||||
|
||||
auto text = tr::lng_rights_transfer_check_about(
|
||||
tr::now,
|
||||
lt_user,
|
||||
Ui::Text::Bold(user->shortName()),
|
||||
Ui::Text::WithEntities
|
||||
).append('\n').append('\n').append(
|
||||
tr::lng_rights_transfer_check_password(
|
||||
tr::now,
|
||||
Ui::Text::RichLangValue)
|
||||
).append('\n').append('\n').append(
|
||||
tr::lng_rights_transfer_check_session(
|
||||
tr::now,
|
||||
Ui::Text::RichLangValue)
|
||||
);
|
||||
if (error == PasswordErrorType::Later) {
|
||||
text.append('\n').append('\n').append(
|
||||
tr::lng_rights_transfer_check_later(
|
||||
tr::now,
|
||||
Ui::Text::RichLangValue));
|
||||
}
|
||||
box->addRow(object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
rpl::single(text),
|
||||
st::boxLabel));
|
||||
if (error == PasswordErrorType::Later) {
|
||||
box->addButton(tr::lng_box_ok(), [=] { box->closeBox(); });
|
||||
} else {
|
||||
box->addButton(tr::lng_rights_transfer_set_password(), [=] {
|
||||
SetCloudPassword(box, user);
|
||||
});
|
||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class EditParticipantBox::Inner : public Ui::RpWidget {
|
||||
@@ -520,22 +456,17 @@ void EditAdminBox::transferOwnership() {
|
||||
}
|
||||
|
||||
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;
|
||||
const auto session = &user()->session();
|
||||
auto about = tr::lng_rights_transfer_check_about(
|
||||
tr::now,
|
||||
lt_user,
|
||||
Ui::Text::Bold(user()->shortName()),
|
||||
Ui::Text::WithEntities);
|
||||
if (auto box = PrePasswordErrorBox(error, session, std::move(about))) {
|
||||
getDelegate()->show(std::move(box));
|
||||
return true;
|
||||
}
|
||||
|
||||
getDelegate()->show(Box(TransferPasswordError, user(), type));
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditAdminBox::transferOwnershipChecked() {
|
||||
|
Reference in New Issue
Block a user