mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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
|
const auto settings = bot->botInfo
|
||||||
? bot->botInfo->verifierSettings.get()
|
? bot->botInfo->verifierSettings.get()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
const auto modify = settings && settings->canModifyDescription;
|
||||||
const auto state = std::make_shared<State>(State{
|
const auto state = std::make_shared<State>(State{
|
||||||
.description = settings ? settings->customDescription : QString()
|
.description = settings ? settings->customDescription : QString()
|
||||||
});
|
});
|
||||||
|
@ -119,7 +120,7 @@ void Controller::confirmAdd(not_null<PeerData*> peer) {
|
||||||
u"bot_verification_description_length_limit"_q,
|
u"bot_verification_description_length_limit"_q,
|
||||||
70);
|
70);
|
||||||
const auto send = [=] {
|
const auto send = [=] {
|
||||||
if (state->description.size() > limit) {
|
if (modify && state->description.size() > limit) {
|
||||||
state->field->showError();
|
state->field->showError();
|
||||||
return;
|
return;
|
||||||
} else if (state->sent) {
|
} else if (state->sent) {
|
||||||
|
@ -127,7 +128,8 @@ void Controller::confirmAdd(not_null<PeerData*> peer) {
|
||||||
}
|
}
|
||||||
state->sent = true;
|
state->sent = true;
|
||||||
const auto weak = Ui::MakeWeak(box);
|
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 (error.isEmpty()) {
|
||||||
if (const auto strong = weak.data()) {
|
if (const auto strong = weak.data()) {
|
||||||
strong->closeBox();
|
strong->closeBox();
|
||||||
|
@ -157,6 +159,9 @@ void Controller::confirmAdd(not_null<PeerData*> peer) {
|
||||||
.confirmText = phrases.submit(),
|
.confirmText = phrases.submit(),
|
||||||
.title = phrases.title(),
|
.title = phrases.title(),
|
||||||
});
|
});
|
||||||
|
if (!modify) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Ui::AddSubsectionTitle(
|
Ui::AddSubsectionTitle(
|
||||||
box->verticalLayout(),
|
box->verticalLayout(),
|
||||||
|
|
|
@ -48,6 +48,7 @@ bool ApplyBotVerifierSettings(
|
||||||
.iconId = DocumentId(data.vicon().v),
|
.iconId = DocumentId(data.vicon().v),
|
||||||
.company = qs(data.vcompany()),
|
.company = qs(data.vcompany()),
|
||||||
.customDescription = qs(data.vcustom_description().value_or_empty()),
|
.customDescription = qs(data.vcustom_description().value_or_empty()),
|
||||||
|
.canModifyDescription = data.is_can_modify_custom_description(),
|
||||||
};
|
};
|
||||||
if (!info->verifierSettings) {
|
if (!info->verifierSettings) {
|
||||||
info->verifierSettings = std::make_unique<BotVerifierSettings>(
|
info->verifierSettings = std::make_unique<BotVerifierSettings>(
|
||||||
|
|
|
@ -35,6 +35,7 @@ struct BotVerifierSettings {
|
||||||
DocumentId iconId = 0;
|
DocumentId iconId = 0;
|
||||||
QString company;
|
QString company;
|
||||||
QString customDescription;
|
QString customDescription;
|
||||||
|
bool canModifyDescription = false;
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return iconId != 0;
|
return iconId != 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue