mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Support bot verifications without modify access.
This commit is contained in:
parent
6ddf241293
commit
a87d19998e
3 changed files with 9 additions and 2 deletions
|
@ -111,6 +111,7 @@ void Controller::confirmAdd(not_null<PeerData*> peer) {
|
|||
const auto settings = bot->botInfo
|
||||
? bot->botInfo->verifierSettings.get()
|
||||
: nullptr;
|
||||
const auto modify = settings && settings->canModifyDescription;
|
||||
const auto state = std::make_shared<State>(State{
|
||||
.description = settings ? settings->customDescription : QString()
|
||||
});
|
||||
|
@ -119,7 +120,7 @@ void Controller::confirmAdd(not_null<PeerData*> peer) {
|
|||
u"bot_verification_description_length_limit"_q,
|
||||
70);
|
||||
const auto send = [=] {
|
||||
if (state->description.size() > limit) {
|
||||
if (modify && state->description.size() > limit) {
|
||||
state->field->showError();
|
||||
return;
|
||||
} else if (state->sent) {
|
||||
|
@ -127,7 +128,8 @@ void Controller::confirmAdd(not_null<PeerData*> peer) {
|
|||
}
|
||||
state->sent = true;
|
||||
const auto weak = Ui::MakeWeak(box);
|
||||
Setup(bot, peer, state->description, [=](QString error) {
|
||||
const auto description = modify ? state->description : QString();
|
||||
Setup(bot, peer, description, [=](QString error) {
|
||||
if (error.isEmpty()) {
|
||||
if (const auto strong = weak.data()) {
|
||||
strong->closeBox();
|
||||
|
@ -157,6 +159,9 @@ void Controller::confirmAdd(not_null<PeerData*> peer) {
|
|||
.confirmText = phrases.submit(),
|
||||
.title = phrases.title(),
|
||||
});
|
||||
if (!modify) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ui::AddSubsectionTitle(
|
||||
box->verticalLayout(),
|
||||
|
|
|
@ -48,6 +48,7 @@ bool ApplyBotVerifierSettings(
|
|||
.iconId = DocumentId(data.vicon().v),
|
||||
.company = qs(data.vcompany()),
|
||||
.customDescription = qs(data.vcustom_description().value_or_empty()),
|
||||
.canModifyDescription = data.is_can_modify_custom_description(),
|
||||
};
|
||||
if (!info->verifierSettings) {
|
||||
info->verifierSettings = std::make_unique<BotVerifierSettings>(
|
||||
|
|
|
@ -35,6 +35,7 @@ struct BotVerifierSettings {
|
|||
DocumentId iconId = 0;
|
||||
QString company;
|
||||
QString customDescription;
|
||||
bool canModifyDescription = false;
|
||||
|
||||
explicit operator bool() const {
|
||||
return iconId != 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue