Server-side star gift message length limit.

This commit is contained in:
John Preston 2024-09-30 10:36:27 +04:00
parent c5139ed06a
commit 3e63b40564

View File

@ -34,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "lottie/lottie_common.h" #include "lottie/lottie_common.h"
#include "lottie/lottie_single_player.h" #include "lottie/lottie_single_player.h"
#include "main/main_app_config.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "payments/payments_form.h" #include "payments/payments_form.h"
#include "payments/payments_checkout_process.h" #include "payments/payments_checkout_process.h"
@ -714,6 +715,12 @@ struct GiftPriceTabs {
}; };
} }
[[nodiscard]] int StarGiftMessageLimit(not_null<Main::Session*> session) {
return session->appConfig().get<int>(
u"stargifts_message_length_max"_q,
255);
}
[[nodiscard]] not_null<Ui::InputField*> AddPartInput( [[nodiscard]] not_null<Ui::InputField*> AddPartInput(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
@ -848,13 +855,14 @@ void SendGiftBox(
session, session,
state->details.value())); state->details.value()));
const auto limit = StarGiftMessageLimit(&window->session());
const auto text = AddPartInput( const auto text = AddPartInput(
window, window,
container, container,
box->getDelegate()->outerContainer(), box->getDelegate()->outerContainer(),
tr::lng_gift_send_message(), tr::lng_gift_send_message(),
QString(), QString(),
kGiftMessageLimit); limit);
text->changes() | rpl::start_with_next([=] { text->changes() | rpl::start_with_next([=] {
auto now = state->details.current(); auto now = state->details.current();
auto textWithTags = text->getTextWithAppliedMarkdown(); auto textWithTags = text->getTextWithAppliedMarkdown();