mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-02 23:45:44 +00:00
Warn admins about commission and stars.
This commit is contained in:
@@ -4451,8 +4451,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
"lng_suggest_options_date_any" = "Anytime";
|
"lng_suggest_options_date_any" = "Anytime";
|
||||||
"lng_suggest_options_date_publish" = "Publish";
|
"lng_suggest_options_date_publish" = "Publish";
|
||||||
"lng_suggest_options_date_now" = "Publish Now";
|
"lng_suggest_options_date_now" = "Publish Now";
|
||||||
"lng_suggest_options_date_about" = "Select the date and time you want the message to be published.";
|
"lng_suggest_options_date_about" = "Select the date and time you want the message to be published. The post will remain available for at least 24 hours from this date.";
|
||||||
"lng_suggest_options_you_get" = "You will receive {amount} ({percent}) for publishing this post.";
|
"lng_suggest_options_you_get" = "You will receive {amount} ({percent}) for publishing this post.";
|
||||||
|
"lng_suggest_options_stars_warning" = "Transactions in **Stars** may be reversed by the payment provider within **21** days. Only accept Stars from people you trust.";
|
||||||
"lng_suggest_options_offer" = "Offer {amount}";
|
"lng_suggest_options_offer" = "Offer {amount}";
|
||||||
"lng_suggest_options_offer_free" = "Offer for Free";
|
"lng_suggest_options_offer_free" = "Offer for Free";
|
||||||
"lng_suggest_options_update" = "Update Terms";
|
"lng_suggest_options_update" = "Update Terms";
|
||||||
@@ -4494,14 +4495,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
"lng_suggest_decline_text" = "Do you want to decline publishing this post from {from}?";
|
"lng_suggest_decline_text" = "Do you want to decline publishing this post from {from}?";
|
||||||
"lng_suggest_decline_text_to" = "Do you want to decline publishing this post to {channel}?";
|
"lng_suggest_decline_text_to" = "Do you want to decline publishing this post to {channel}?";
|
||||||
"lng_suggest_decline_reason" = "Add a reason (optional)";
|
"lng_suggest_decline_reason" = "Add a reason (optional)";
|
||||||
"lng_suggest_accept_title" = "Accept";
|
"lng_suggest_accept_title" = "Accept Terms";
|
||||||
"lng_suggest_accept_text" = "Do you want to publish this post from {from}?";
|
"lng_suggest_accept_text" = "Do you want to publish this post from {from}?";
|
||||||
"lng_suggest_accept_text_to" = "Do you want to publish this post to {channel}?";
|
"lng_suggest_accept_text_to" = "Do you want to publish this post to {channel}?";
|
||||||
"lng_suggest_accept_receive" = "{channel} will receive {amount} for publishing {date}.";
|
"lng_suggest_accept_receive" = "{channel} will receive {amount} ({percent}) for publishing {date}.";
|
||||||
"lng_suggest_accept_receive_now" = "{channel} will receive {amount} for publishing right now.";
|
"lng_suggest_accept_receive_now" = "{channel} will receive {amount} ({percent}) for publishing right now.";
|
||||||
|
"lng_suggest_accept_receive_if" = "It must remain visible for at least **24** hours after publication.";
|
||||||
"lng_suggest_accept_pay" = "You will pay {amount} for publishing {date}.";
|
"lng_suggest_accept_pay" = "You will pay {amount} for publishing {date}.";
|
||||||
"lng_suggest_accept_pay_now" = "You will pay {amount} for publishing right now.";
|
"lng_suggest_accept_pay_now" = "You will pay {amount} for publishing right now.";
|
||||||
"lng_suggest_accept_send" = "Send";
|
"lng_suggest_accept_send" = "Publish";
|
||||||
"lng_suggest_ton_amount#one" = "{count} TON";
|
"lng_suggest_ton_amount#one" = "{count} TON";
|
||||||
"lng_suggest_ton_amount#other" = "{count} TON";
|
"lng_suggest_ton_amount#other" = "{count} TON";
|
||||||
"lng_suggest_warn_title_stars" = "Stars will be lost";
|
"lng_suggest_warn_title_stars" = "Stars will be lost";
|
||||||
|
@@ -137,9 +137,15 @@ void ConfirmApproval(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto peer = item->history()->peer;
|
const auto peer = item->history()->peer;
|
||||||
|
const auto session = &peer->session();
|
||||||
const auto broadcast = peer->monoforumBroadcast();
|
const auto broadcast = peer->monoforumBroadcast();
|
||||||
const auto channelName = (broadcast ? broadcast : peer)->name();
|
const auto channelName = (broadcast ? broadcast : peer)->name();
|
||||||
const auto amount = Lang::FormatCreditsAmountWithCurrency(price);
|
const auto amount = admin
|
||||||
|
? HistoryView::FormatPriceAfterCommission(session, price)
|
||||||
|
: Lang::FormatCreditsAmountWithCurrency(price);
|
||||||
|
const auto commission = HistoryView::FormatAfterCommissionPercent(
|
||||||
|
session,
|
||||||
|
price);
|
||||||
const auto date = langDateTime(base::unixtime::parse(scheduleDate));
|
const auto date = langDateTime(base::unixtime::parse(scheduleDate));
|
||||||
show->show(Box([=](not_null<Ui::GenericBox*> box) {
|
show->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||||
const auto callback = std::make_shared<Fn<void()>>();
|
const auto callback = std::make_shared<Fn<void()>>();
|
||||||
@@ -163,16 +169,20 @@ void ConfirmApproval(
|
|||||||
Ui::Text::Bold(channelName),
|
Ui::Text::Bold(channelName),
|
||||||
lt_amount,
|
lt_amount,
|
||||||
Ui::Text::Bold(amount),
|
Ui::Text::Bold(amount),
|
||||||
|
lt_percent,
|
||||||
|
TextWithEntities{ commission },
|
||||||
lt_date,
|
lt_date,
|
||||||
Ui::Text::Bold(date),
|
Ui::Text::Bold(date),
|
||||||
Ui::Text::WithEntities)
|
Ui::Text::RichLangValue)
|
||||||
: tr::lng_suggest_accept_receive_now(
|
: tr::lng_suggest_accept_receive_now(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_channel,
|
lt_channel,
|
||||||
Ui::Text::Bold(channelName),
|
Ui::Text::Bold(channelName),
|
||||||
lt_amount,
|
lt_amount,
|
||||||
Ui::Text::Bold(amount),
|
Ui::Text::Bold(amount),
|
||||||
Ui::Text::WithEntities))
|
lt_percent,
|
||||||
|
TextWithEntities{ commission },
|
||||||
|
Ui::Text::RichLangValue))
|
||||||
: (scheduleDate
|
: (scheduleDate
|
||||||
? tr::lng_suggest_accept_pay(
|
? tr::lng_suggest_accept_pay(
|
||||||
tr::now,
|
tr::now,
|
||||||
@@ -180,12 +190,24 @@ void ConfirmApproval(
|
|||||||
Ui::Text::Bold(amount),
|
Ui::Text::Bold(amount),
|
||||||
lt_date,
|
lt_date,
|
||||||
Ui::Text::Bold(date),
|
Ui::Text::Bold(date),
|
||||||
Ui::Text::WithEntities)
|
Ui::Text::RichLangValue)
|
||||||
: tr::lng_suggest_accept_pay_now(
|
: tr::lng_suggest_accept_pay_now(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_amount,
|
lt_amount,
|
||||||
Ui::Text::Bold(amount),
|
Ui::Text::Bold(amount),
|
||||||
Ui::Text::WithEntities)));
|
Ui::Text::RichLangValue)));
|
||||||
|
if (admin) {
|
||||||
|
text.append(' ').append(
|
||||||
|
tr::lng_suggest_accept_receive_if(
|
||||||
|
tr::now,
|
||||||
|
Ui::Text::RichLangValue));
|
||||||
|
if (price.stars()) {
|
||||||
|
text.append("\n\n").append(
|
||||||
|
tr::lng_suggest_options_stars_warning(
|
||||||
|
tr::now,
|
||||||
|
Ui::Text::RichLangValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ui::ConfirmBox(box, {
|
Ui::ConfirmBox(box, {
|
||||||
.text = text,
|
.text = text,
|
||||||
|
@@ -109,10 +109,6 @@ void ChooseSuggestPriceBox(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto appConfig = &args.peer->session().appConfig();
|
|
||||||
const auto starsMul = appConfig->suggestedPostCommissionStars();
|
|
||||||
const auto tonMul = appConfig->suggestedPostCommissionTon();
|
|
||||||
|
|
||||||
const auto starsPrice = [=] {
|
const auto starsPrice = [=] {
|
||||||
return rpl::single(
|
return rpl::single(
|
||||||
CreditsAmount()
|
CreditsAmount()
|
||||||
@@ -129,17 +125,6 @@ void ChooseSuggestPriceBox(
|
|||||||
return amount.ton();
|
return amount.ton();
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
const auto formatPrice = [=](int mul) {
|
|
||||||
return [=](CreditsAmount amount) {
|
|
||||||
const auto value = (amount.value() * mul / 1000.);
|
|
||||||
const auto whole = int(std::floor(value));
|
|
||||||
//const auto nano = int(base::SafeRound(
|
|
||||||
// (value - whole) * Ui::kNanosInOne));
|
|
||||||
const auto nano = 0;
|
|
||||||
return Lang::FormatCreditsAmountWithCurrency(
|
|
||||||
CreditsAmount(whole, nano, amount.type()));
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto peer = args.peer;
|
const auto peer = args.peer;
|
||||||
const auto admin = peer->amMonoforumAdmin();
|
const auto admin = peer->amMonoforumAdmin();
|
||||||
@@ -331,20 +316,26 @@ void ChooseSuggestPriceBox(
|
|||||||
starsFieldWrap->resize(width, starsField->height());
|
starsFieldWrap->resize(width, starsField->height());
|
||||||
}, starsFieldWrap->lifetime());
|
}, starsFieldWrap->lifetime());
|
||||||
|
|
||||||
const auto starsCommission = QString::number(starsMul / 10.) + '%';
|
|
||||||
const auto tonCommission = QString::number(tonMul / 10.) + '%';
|
|
||||||
|
|
||||||
Ui::AddSkip(starsInner);
|
Ui::AddSkip(starsInner);
|
||||||
Ui::AddSkip(starsInner);
|
Ui::AddSkip(starsInner);
|
||||||
Ui::AddDividerText(
|
const auto formatPrice = [peer = args.peer](CreditsAmount amount) {
|
||||||
starsInner,
|
return FormatPriceAfterCommission(&peer->session(), amount);
|
||||||
(admin
|
};
|
||||||
? tr::lng_suggest_options_you_get(
|
const auto formatCommission = [peer = args.peer](CreditsAmount amount) {
|
||||||
|
return FormatAfterCommissionPercent(&peer->session(), amount);
|
||||||
|
};
|
||||||
|
Ui::AddDividerText(starsInner, admin
|
||||||
|
? rpl::combine(
|
||||||
|
tr::lng_suggest_options_you_get(
|
||||||
lt_amount,
|
lt_amount,
|
||||||
starsPrice() | rpl::map(formatPrice(starsMul)),
|
starsPrice() | rpl::map(formatPrice),
|
||||||
lt_percent,
|
lt_percent,
|
||||||
rpl::single(starsCommission))
|
starsPrice() | rpl::map(formatCommission)),
|
||||||
: tr::lng_suggest_options_stars_price_about()));
|
tr::lng_suggest_options_stars_warning(Ui::Text::RichLangValue)
|
||||||
|
) | rpl::map([=](const QString &t1, const TextWithEntities &t2) {
|
||||||
|
return TextWithEntities{ t1 }.append("\n\n").append(t2);
|
||||||
|
})
|
||||||
|
: tr::lng_suggest_options_stars_price_about(Ui::Text::WithEntities));
|
||||||
|
|
||||||
const auto tonWrap = container->add(
|
const auto tonWrap = container->add(
|
||||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
@@ -396,9 +387,9 @@ void ChooseSuggestPriceBox(
|
|||||||
(admin
|
(admin
|
||||||
? tr::lng_suggest_options_you_get(
|
? tr::lng_suggest_options_you_get(
|
||||||
lt_amount,
|
lt_amount,
|
||||||
tonPrice() | rpl::map(formatPrice(tonMul)),
|
tonPrice() | rpl::map(formatPrice),
|
||||||
lt_percent,
|
lt_percent,
|
||||||
rpl::single(tonCommission))
|
tonPrice() | rpl::map(formatCommission))
|
||||||
: tr::lng_suggest_options_ton_price_about()));
|
: tr::lng_suggest_options_ton_price_about()));
|
||||||
|
|
||||||
tonWrap->toggleOn(state->ton.value(), anim::type::instant);
|
tonWrap->toggleOn(state->ton.value(), anim::type::instant);
|
||||||
@@ -642,6 +633,33 @@ bool CanAddOfferToMessage(not_null<HistoryItem*> item) {
|
|||||||
history->owner().history(broadcast)).has_value();
|
history->owner().history(broadcast)).has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString FormatPriceAfterCommission(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
CreditsAmount price) {
|
||||||
|
const auto appConfig = &session->appConfig();
|
||||||
|
const auto mul = price.stars()
|
||||||
|
? appConfig->suggestedPostCommissionStars()
|
||||||
|
: appConfig->suggestedPostCommissionTon();
|
||||||
|
|
||||||
|
const auto value = (price.value() * mul / 1000.);
|
||||||
|
const auto whole = int(std::floor(value));
|
||||||
|
//const auto nano = int(base::SafeRound(
|
||||||
|
// (value - whole) * Ui::kNanosInOne));
|
||||||
|
const auto nano = 0;
|
||||||
|
return Lang::FormatCreditsAmountWithCurrency(
|
||||||
|
CreditsAmount(whole, nano, price.type()));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FormatAfterCommissionPercent(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
CreditsAmount price) {
|
||||||
|
const auto appConfig = &session->appConfig();
|
||||||
|
const auto mul = price.stars()
|
||||||
|
? appConfig->suggestedPostCommissionStars()
|
||||||
|
: appConfig->suggestedPostCommissionTon();
|
||||||
|
return QString::number(mul / 10.) + '%';
|
||||||
|
}
|
||||||
|
|
||||||
void InsufficientTonBox(
|
void InsufficientTonBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
@@ -755,6 +773,7 @@ void SuggestOptions::edit() {
|
|||||||
.peer = _peer,
|
.peer = _peer,
|
||||||
.done = apply,
|
.done = apply,
|
||||||
.value = _values,
|
.value = _values,
|
||||||
|
.mode = _mode,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,6 +58,13 @@ void ChooseSuggestPriceBox(
|
|||||||
|
|
||||||
[[nodiscard]] bool CanAddOfferToMessage(not_null<HistoryItem*> item);
|
[[nodiscard]] bool CanAddOfferToMessage(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
|
[[nodiscard]] QString FormatPriceAfterCommission(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
CreditsAmount price);
|
||||||
|
[[nodiscard]] QString FormatAfterCommissionPercent(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
CreditsAmount price);
|
||||||
|
|
||||||
void InsufficientTonBox(
|
void InsufficientTonBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
|
Reference in New Issue
Block a user