mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Show all premium limits boxes.
This commit is contained in:
parent
63940ea557
commit
26c99cea7c
Telegram
@ -214,6 +214,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_saved_gif_limit_more#other" = "An older GIF was replaced with this one.\nYou can {link} to {count} GIFs.";
|
||||
"lng_saved_gif_limit_link" = "increase the limit";
|
||||
|
||||
"lng_caption_limit_title" = "Limit Reached";
|
||||
"lng_caption_limit1#one" = "Sorry, you can't use more than **{count}** character in media captions.";
|
||||
"lng_caption_limit1#other" = "Sorry, you can't use more than **{count}** characters in media captions.";
|
||||
"lng_caption_limit2#one" = "Make the caption shorter or subscribe to **Telegram Premium** to double the limit to **{count}** character.";
|
||||
"lng_caption_limit2#other" = "Make the caption shorter or subscribe to **Telegram Premium** to double the limit to **{count}** characters.";
|
||||
"lng_caption_limit_reached#one" = "You've reached the media caption limit. Please make the caption shorter by {count} character.";
|
||||
"lng_caption_limit_reached#other" = "You've reached the media caption limit. Please make the caption shorter by {count} characters.";
|
||||
|
||||
"lng_limits_increase" = "Increase Limit";
|
||||
|
||||
"lng_flood_error" = "Too many tries. Please try again later.";
|
||||
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "api/api_text_entities.h"
|
||||
#include "apiwrap.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "boxes/premium_limits_box.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
#include "chat_helpers/message_field.h"
|
||||
#include "chat_helpers/tabbed_panel.h"
|
||||
@ -33,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "platform/platform_specific.h"
|
||||
#include "storage/localimageloader.h" // SendMediaType
|
||||
#include "storage/storage_media_prepare.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/chat/attach/attach_item_single_file_preview.h"
|
||||
#include "ui/chat/attach/attach_item_single_media_preview.h"
|
||||
#include "ui/chat/attach/attach_single_file_preview.h"
|
||||
@ -240,8 +242,6 @@ void EditCaptionBox::rebuildPreview() {
|
||||
void EditCaptionBox::setupField() {
|
||||
const auto show = std::make_shared<Window::Show>(_controller);
|
||||
const auto session = &_controller->session();
|
||||
_field->setMaxLength(
|
||||
_controller->session().serverConfig().captionLengthMax);
|
||||
_field->setSubmitSettings(
|
||||
Core::App().settings().sendSubmitWay());
|
||||
_field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||
@ -648,6 +648,22 @@ void EditCaptionBox::setInnerFocus() {
|
||||
_field->setFocusFast();
|
||||
}
|
||||
|
||||
bool EditCaptionBox::validateLength(const QString &text) const {
|
||||
const auto session = &_controller->session();
|
||||
const auto limit = CurrentPremiumLimit(
|
||||
session,
|
||||
"caption_length_limit_default",
|
||||
1024,
|
||||
"caption_length_limit_premium",
|
||||
2048);
|
||||
const auto remove = int(text.size()) - limit;
|
||||
if (remove <= 0) {
|
||||
return true;
|
||||
}
|
||||
_controller->show(Box(CaptionLimitReachedBox, session, remove));
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditCaptionBox::save() {
|
||||
if (_saveRequestId) {
|
||||
return;
|
||||
@ -662,6 +678,9 @@ void EditCaptionBox::save() {
|
||||
}
|
||||
|
||||
const auto textWithTags = _field->getTextWithAppliedMarkdown();
|
||||
if (!validateLength(textWithTags.text)) {
|
||||
return;
|
||||
}
|
||||
const auto sending = TextWithEntities{
|
||||
textWithTags.text,
|
||||
TextUtilities::ConvertTextTagsToEntities(textWithTags.tags)
|
||||
|
@ -62,6 +62,7 @@ private:
|
||||
|
||||
void setupDragArea();
|
||||
|
||||
bool validateLength(const QString &text) const;
|
||||
void save();
|
||||
|
||||
bool fileFromClipboard(not_null<const QMimeData*> data);
|
||||
|
@ -626,6 +626,7 @@ void Controller::showEditPeerTypeBox(
|
||||
= (_linkedChatSavedValue.value_or(nullptr) != nullptr);
|
||||
_navigation->parentController()->show(
|
||||
Box<EditPeerTypeBox>(
|
||||
_navigation,
|
||||
_peer,
|
||||
_channelHasLocationOriginalValue,
|
||||
boxCallback,
|
||||
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "main/main_session.h"
|
||||
#include "boxes/add_contact_box.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "boxes/premium_limits_box.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
#include "boxes/peers/edit_peer_common.h"
|
||||
@ -48,6 +49,7 @@ namespace {
|
||||
class Controller : public base::has_weak_ptr {
|
||||
public:
|
||||
Controller(
|
||||
Window::SessionNavigation *navigation,
|
||||
std::shared_ptr<Ui::BoxShow> show,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<PeerData*> peer,
|
||||
@ -131,6 +133,7 @@ private:
|
||||
const QString &text,
|
||||
rpl::producer<QString> about);
|
||||
|
||||
Window::SessionNavigation *_navigation = nullptr;
|
||||
std::shared_ptr<Ui::BoxShow> _show;
|
||||
|
||||
not_null<PeerData*> _peer;
|
||||
@ -154,12 +157,14 @@ private:
|
||||
};
|
||||
|
||||
Controller::Controller(
|
||||
Window::SessionNavigation *navigation,
|
||||
std::shared_ptr<Ui::BoxShow> show,
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
not_null<PeerData*> peer,
|
||||
bool useLocationPhrases,
|
||||
std::optional<EditPeerTypeData> dataSavedValue)
|
||||
: _show(show)
|
||||
: _navigation(navigation)
|
||||
, _show(show)
|
||||
, _peer(peer)
|
||||
, _linkOnly(!dataSavedValue.has_value())
|
||||
, _api(&_peer->session().mtp())
|
||||
@ -249,7 +254,7 @@ void Controller::createContent() {
|
||||
tr::lng_manage_peer_send_approve_members(),
|
||||
rpl::single(QString()),
|
||||
[=] {},
|
||||
st::manageGroupTopButtonWithText,
|
||||
st::peerPermissionsButton,
|
||||
{})))->setDuration(0);
|
||||
requestToJoinWrap->toggleOn(rpl::duplicate(joinToWrite));
|
||||
_controls.requestToJoin = requestToJoinWrap->entity();
|
||||
@ -574,9 +579,7 @@ void Controller::askUsernameRevoke() {
|
||||
checkUsernameAvailability();
|
||||
});
|
||||
_show->showBox(
|
||||
Box<RevokePublicLinkBox>(
|
||||
&_peer->session(),
|
||||
std::move(revokeCallback)),
|
||||
Box(PublicLinksLimitBox, _navigation),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}
|
||||
|
||||
@ -676,12 +679,14 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkBlock() {
|
||||
|
||||
EditPeerTypeBox::EditPeerTypeBox(
|
||||
QWidget*,
|
||||
Window::SessionNavigation *navigation,
|
||||
not_null<PeerData*> peer,
|
||||
bool useLocationPhrases,
|
||||
std::optional<FnMut<void(EditPeerTypeData)>> savedCallback,
|
||||
std::optional<EditPeerTypeData> dataSaved,
|
||||
std::optional<rpl::producer<QString>> usernameError)
|
||||
: _peer(peer)
|
||||
: _navigation(navigation)
|
||||
, _peer(peer)
|
||||
, _useLocationPhrases(useLocationPhrases)
|
||||
, _savedCallback(std::move(savedCallback))
|
||||
, _dataSavedValue(dataSaved)
|
||||
@ -691,7 +696,7 @@ EditPeerTypeBox::EditPeerTypeBox(
|
||||
EditPeerTypeBox::EditPeerTypeBox(
|
||||
QWidget*,
|
||||
not_null<PeerData*> peer)
|
||||
: EditPeerTypeBox(nullptr, peer, {}, {}, {}) {
|
||||
: EditPeerTypeBox(nullptr, nullptr, peer, {}, {}, {}) {
|
||||
}
|
||||
|
||||
void EditPeerTypeBox::setInnerFocus() {
|
||||
@ -705,6 +710,7 @@ void EditPeerTypeBox::prepare() {
|
||||
|
||||
const auto controller = Ui::CreateChild<Controller>(
|
||||
this,
|
||||
_navigation,
|
||||
std::make_shared<Ui::BoxShow>(this),
|
||||
content.data(),
|
||||
_peer,
|
||||
|
@ -18,6 +18,10 @@ class VerticalLayout;
|
||||
class SettingsButton;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
class SessionNavigation;
|
||||
} // namespace Window
|
||||
|
||||
enum class Privacy {
|
||||
HasUsername,
|
||||
NoUsername,
|
||||
@ -42,6 +46,7 @@ class EditPeerTypeBox : public Ui::BoxContent {
|
||||
public:
|
||||
EditPeerTypeBox(
|
||||
QWidget*,
|
||||
Window::SessionNavigation *navigation,
|
||||
not_null<PeerData*> peer,
|
||||
bool useLocationPhrases,
|
||||
std::optional<FnMut<void(EditPeerTypeData)>> savedCallback,
|
||||
@ -58,7 +63,8 @@ protected:
|
||||
void setInnerFocus() override;
|
||||
|
||||
private:
|
||||
not_null<PeerData*> _peer;
|
||||
Window::SessionNavigation *_navigation = nullptr;
|
||||
const not_null<PeerData*> _peer;
|
||||
bool _useLocationPhrases = false;
|
||||
std::optional<FnMut<void(EditPeerTypeData)>> _savedCallback;
|
||||
|
||||
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "boxes/premium_limits_box.h"
|
||||
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/controls/peer_list_dummy.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
@ -16,7 +17,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "main/main_account.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
#include "boxes/peers/prepare_short_info_box.h" // PrepareShortInfoBox
|
||||
#include "window/window_session_controller.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_session.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "base/unixtime.h"
|
||||
@ -47,6 +51,29 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class PublicsController final : public PeerListController {
|
||||
public:
|
||||
PublicsController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
Fn<void()> closeBox);
|
||||
~PublicsController();
|
||||
|
||||
Main::Session &session() const override;
|
||||
void prepare() override;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
void rowRightActionClicked(not_null<PeerListRow*> row) override;
|
||||
|
||||
private:
|
||||
void appendRow(not_null<PeerData*> peer);
|
||||
[[nodiscard]] std::unique_ptr<PeerListRow> createRow(
|
||||
not_null<PeerData*> peer) const;
|
||||
|
||||
const not_null<Window::SessionNavigation*> _navigation;
|
||||
Fn<void()> _closeBox;
|
||||
mtpRequestId _requestId = 0;
|
||||
|
||||
};
|
||||
|
||||
class InactiveDelegate final : public PeerListContentDelegate {
|
||||
public:
|
||||
void peerListSetTitle(rpl::producer<QString> title) override;
|
||||
@ -149,7 +176,6 @@ const base::flat_set<PeerListRowId> &InactiveDelegate::selected() const {
|
||||
return _selectedIds;
|
||||
}
|
||||
|
||||
|
||||
InactiveController::InactiveController(not_null<Main::Session*> session)
|
||||
: _session(session) {
|
||||
}
|
||||
@ -165,10 +191,6 @@ Main::Session &InactiveController::session() const {
|
||||
}
|
||||
|
||||
void InactiveController::prepare() {
|
||||
delegate()->peerListSetTitle(tr::lng_blocked_list_title());
|
||||
setDescriptionText(tr::lng_contacts_loading(tr::now));
|
||||
delegate()->peerListRefreshRows();
|
||||
|
||||
_requestId = _session->api().request(MTPchannels_GetInactiveChannels(
|
||||
)).done([=](const MTPmessages_InactiveChats &result) {
|
||||
_requestId = 0;
|
||||
@ -241,6 +263,102 @@ std::unique_ptr<PeerListRow> InactiveController::createRow(
|
||||
return result;
|
||||
}
|
||||
|
||||
PublicsController::PublicsController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
Fn<void()> closeBox)
|
||||
: _navigation(navigation)
|
||||
, _closeBox(std::move(closeBox)) {
|
||||
}
|
||||
|
||||
PublicsController::~PublicsController() {
|
||||
if (_requestId) {
|
||||
_navigation->session().api().request(_requestId).cancel();
|
||||
}
|
||||
}
|
||||
|
||||
Main::Session &PublicsController::session() const {
|
||||
return _navigation->session();
|
||||
}
|
||||
|
||||
void PublicsController::prepare() {
|
||||
_requestId = _navigation->session().api().request(
|
||||
MTPchannels_GetAdminedPublicChannels(MTP_flags(0))
|
||||
).done([=](const MTPmessages_Chats &result) {
|
||||
_requestId = 0;
|
||||
|
||||
const auto &chats = result.match([](const auto &data) {
|
||||
return data.vchats().v;
|
||||
});
|
||||
auto &owner = _navigation->session().data();
|
||||
for (const auto &chat : chats) {
|
||||
if (const auto peer = owner.processChat(chat)) {
|
||||
if (!peer->isChannel() || peer->userName().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
appendRow(peer);
|
||||
}
|
||||
delegate()->peerListRefreshRows();
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
|
||||
void PublicsController::rowClicked(not_null<PeerListRow*> row) {
|
||||
_navigation->parentController()->show(
|
||||
PrepareShortInfoBox(row->peer(), _navigation));
|
||||
}
|
||||
|
||||
void PublicsController::rowRightActionClicked(not_null<PeerListRow*> row) {
|
||||
const auto peer = row->peer();
|
||||
const auto textMethod = peer->isMegagroup()
|
||||
? tr::lng_channels_too_much_public_revoke_confirm_group
|
||||
: tr::lng_channels_too_much_public_revoke_confirm_channel;
|
||||
const auto text = textMethod(
|
||||
tr::now,
|
||||
lt_link,
|
||||
peer->session().createInternalLink(peer->userName()),
|
||||
lt_group,
|
||||
peer->name);
|
||||
const auto confirmText = tr::lng_channels_too_much_public_revoke(
|
||||
tr::now);
|
||||
const auto closeBox = _closeBox;
|
||||
const auto once = std::make_shared<bool>(false);
|
||||
auto callback = crl::guard(_navigation, [=](Fn<void()> &&close) {
|
||||
if (*once) {
|
||||
return;
|
||||
}
|
||||
*once = true;
|
||||
peer->session().api().request(MTPchannels_UpdateUsername(
|
||||
peer->asChannel()->inputChannel,
|
||||
MTP_string()
|
||||
)).done([=, close = std::move(close)] {
|
||||
closeBox();
|
||||
close();
|
||||
}).send();
|
||||
});
|
||||
_navigation->parentController()->show(
|
||||
Ui::MakeConfirmBox({
|
||||
.text = text,
|
||||
.confirmed = std::move(callback),
|
||||
.confirmText = confirmText,
|
||||
}),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}
|
||||
|
||||
void PublicsController::appendRow(not_null<PeerData*> participant) {
|
||||
if (!delegate()->peerListFindRow(participant->id.value)) {
|
||||
delegate()->peerListAppendRow(createRow(participant));
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<PeerListRow> PublicsController::createRow(
|
||||
not_null<PeerData*> peer) const {
|
||||
auto result = std::make_unique<PeerListRowWithLink>(peer);
|
||||
result->setActionLink(tr::lng_channels_too_much_public_revoke(tr::now));
|
||||
result->setCustomStatus(
|
||||
_navigation->session().createInternalLink(peer->userName()));
|
||||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] float64 Limit(
|
||||
not_null<Main::Session*> session,
|
||||
const QString &key,
|
||||
@ -385,7 +503,7 @@ void ChannelsLimitBox(
|
||||
delegate->setContent(content);
|
||||
controller->setDelegate(delegate);
|
||||
|
||||
const auto count = 50;
|
||||
const auto count = 100;
|
||||
const auto placeholder = box->addRow(
|
||||
object_ptr<PeerListDummy>(box, count, st::defaultPeerList),
|
||||
{});
|
||||
@ -431,7 +549,8 @@ void ChannelsLimitBox(
|
||||
|
||||
void PublicLinksLimitBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session) {
|
||||
not_null<Window::SessionNavigation*> navigation) {
|
||||
const auto session = &navigation->session();
|
||||
const auto premium = session->user()->isPremium();
|
||||
|
||||
auto text = rpl::combine(
|
||||
@ -462,7 +581,30 @@ void PublicLinksLimitBox(
|
||||
session,
|
||||
tr::lng_links_limit_title(),
|
||||
std::move(text),
|
||||
premium);
|
||||
premium,
|
||||
true);
|
||||
|
||||
const auto delegate = box->lifetime().make_state<InactiveDelegate>();
|
||||
const auto controller = box->lifetime().make_state<PublicsController>(
|
||||
navigation,
|
||||
crl::guard(box, [=] { box->closeBox(); }));
|
||||
|
||||
const auto content = box->addRow(
|
||||
object_ptr<PeerListContent>(box, controller),
|
||||
{});
|
||||
delegate->setContent(content);
|
||||
controller->setDelegate(delegate);
|
||||
|
||||
const auto count = Limit(session, "channels_public_limit_default", 10);
|
||||
const auto placeholder = box->addRow(
|
||||
object_ptr<PeerListDummy>(box, count, st::defaultPeerList),
|
||||
{});
|
||||
|
||||
using namespace rpl::mappers;
|
||||
content->heightValue(
|
||||
) | rpl::filter(_1 > 0) | rpl::start_with_next([=] {
|
||||
delete placeholder;
|
||||
}, placeholder->lifetime());
|
||||
}
|
||||
|
||||
void FilterChatsLimitBox(
|
||||
@ -575,6 +717,58 @@ void PinsLimitBox(
|
||||
10);
|
||||
}
|
||||
|
||||
void CaptionLimitBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session) {
|
||||
const auto premium = session->user()->isPremium();
|
||||
|
||||
auto text = rpl::combine(
|
||||
tr::lng_caption_limit1(
|
||||
lt_count,
|
||||
rpl::single(Limit(
|
||||
session,
|
||||
(premium
|
||||
? "caption_length_limit_premium"
|
||||
: "caption_length_limit_default"),
|
||||
premium ? 2048 : 1024)),
|
||||
Ui::Text::RichLangValue),
|
||||
tr::lng_caption_limit2(
|
||||
lt_count,
|
||||
rpl::single(
|
||||
Limit(session, "caption_length_limit_premium", 2048)),
|
||||
Ui::Text::RichLangValue)
|
||||
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
||||
return a.append(QChar(' ')).append(std::move(b));
|
||||
});
|
||||
|
||||
SimpleLimitBox(
|
||||
box,
|
||||
session,
|
||||
tr::lng_caption_limit_title(),
|
||||
std::move(text),
|
||||
premium);
|
||||
}
|
||||
|
||||
void CaptionLimitReachedBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session,
|
||||
int remove) {
|
||||
Ui::ConfirmBox(box, Ui::ConfirmBoxArgs{
|
||||
.text = tr::lng_caption_limit_reached(tr::now, lt_count, remove),
|
||||
.inform = true,
|
||||
});
|
||||
if (!session->user()->isPremium()) {
|
||||
box->addLeftButton(tr::lng_limits_increase(), [=] {
|
||||
box->getDelegate()->showBox(
|
||||
Box(CaptionLimitBox, session),
|
||||
Ui::LayerOption::KeepOther,
|
||||
anim::type::normal);
|
||||
box->closeBox();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int AppConfigLimit(
|
||||
not_null<Main::Session*> session,
|
||||
const QString &key,
|
||||
|
@ -13,12 +13,16 @@ namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Window {
|
||||
class SessionNavigation;
|
||||
} // namespace Window
|
||||
|
||||
void ChannelsLimitBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session);
|
||||
void PublicLinksLimitBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session);
|
||||
not_null<Window::SessionNavigation*> navigation);
|
||||
void FilterChatsLimitBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session);
|
||||
@ -34,6 +38,13 @@ void FolderPinsLimitBox(
|
||||
void PinsLimitBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session);
|
||||
void CaptionLimitBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session);
|
||||
void CaptionLimitReachedBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session,
|
||||
int remove);
|
||||
|
||||
[[nodiscard]] int AppConfigLimit(
|
||||
not_null<Main::Session*> session,
|
||||
|
@ -25,6 +25,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "core/file_utilities.h"
|
||||
#include "core/mime_type.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "boxes/premium_limits_box.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/effects/animations.h"
|
||||
#include "ui/effects/scroll_content_shadow.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
@ -60,6 +62,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto kMaxMessageLength = 4096;
|
||||
|
||||
using Ui::SendFilesWay;
|
||||
|
||||
inline bool CanAddUrls(const QList<QUrl> &urls) {
|
||||
@ -660,8 +664,7 @@ void SendFilesBox::updateSendWayControlsVisibility() {
|
||||
}
|
||||
|
||||
void SendFilesBox::setupCaption() {
|
||||
_caption->setMaxLength(
|
||||
_controller->session().serverConfig().captionLengthMax);
|
||||
_caption->setMaxLength(kMaxMessageLength);
|
||||
_caption->setSubmitSettings(
|
||||
Core::App().settings().sendSubmitWay());
|
||||
connect(_caption, &Ui::InputField::resized, [=] {
|
||||
@ -973,6 +976,25 @@ void SendFilesBox::saveSendWaySettings() {
|
||||
}
|
||||
}
|
||||
|
||||
bool SendFilesBox::validateLength(const QString &text) const {
|
||||
const auto session = &_controller->session();
|
||||
const auto limit = CurrentPremiumLimit(
|
||||
session,
|
||||
"caption_length_limit_default",
|
||||
1024,
|
||||
"caption_length_limit_premium",
|
||||
2048);
|
||||
const auto remove = int(text.size()) - limit;
|
||||
const auto way = _sendWay.current();
|
||||
if (remove <= 0
|
||||
|| !_list.canAddCaption(
|
||||
way.groupFiles() && way.sendImagesAsPhotos())) {
|
||||
return true;
|
||||
}
|
||||
_controller->show(Box(CaptionLimitReachedBox, session, remove));
|
||||
return false;
|
||||
}
|
||||
|
||||
void SendFilesBox::send(
|
||||
Api::SendOptions options,
|
||||
bool ctrlShiftEnter) {
|
||||
@ -1001,6 +1023,9 @@ void SendFilesBox::send(
|
||||
auto caption = (_caption && !_caption->isHidden())
|
||||
? _caption->getTextWithAppliedMarkdown()
|
||||
: TextWithTags();
|
||||
if (!validateLength(caption.text)) {
|
||||
return;
|
||||
}
|
||||
_confirmedCallback(
|
||||
std::move(_list),
|
||||
_sendWay.current(),
|
||||
|
@ -120,6 +120,7 @@ private:
|
||||
void initSendWay();
|
||||
void initPreview();
|
||||
|
||||
bool validateLength(const QString &text) const;
|
||||
void refreshControls();
|
||||
void setupSendWayControls();
|
||||
void setupCaption();
|
||||
|
@ -392,7 +392,6 @@ void Form::processDetails(const MTPDpayments_paymentForm &data) {
|
||||
.canSaveCredentials = data.is_can_save_credentials(),
|
||||
.passwordMissing = data.is_password_missing(),
|
||||
};
|
||||
//_invoice.isTest = data.is_test();
|
||||
_invoice.cover.title = qs(data.vtitle());
|
||||
_invoice.cover.description = qs(data.vdescription());
|
||||
if (_invoice.cover.thumbnail.isNull() && !_thumbnailLoadProcess) {
|
||||
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "api/api_sending.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "core/mime_type.h"
|
||||
#include "base/unixtime.h"
|
||||
@ -1042,6 +1043,11 @@ void FileLoadTask::process(Args &&args) {
|
||||
}
|
||||
|
||||
void FileLoadTask::finish() {
|
||||
const auto session = _session.get();
|
||||
if (!session) {
|
||||
return;
|
||||
}
|
||||
const auto premium = session->user()->isPremium();
|
||||
if (!_result || !_result->filesize || _result->filesize < 0) {
|
||||
Ui::show(
|
||||
Ui::MakeInformBox(
|
||||
@ -1054,13 +1060,13 @@ void FileLoadTask::finish() {
|
||||
tr::lng_send_image_too_large(tr::now, lt_name, _filepath)),
|
||||
Ui::LayerOption::KeepOther);
|
||||
removeFromAlbum();
|
||||
} else if (_result->filesize > kFileSizeLimit) {
|
||||
} else if (_result->filesize > kFileSizeLimit && !premium) {
|
||||
Ui::show(
|
||||
Ui::MakeInformBox(
|
||||
tr::lng_send_image_too_large(tr::now, lt_name, _filepath)),
|
||||
Ui::LayerOption::KeepOther);
|
||||
removeFromAlbum();
|
||||
} else if (const auto session = _session.get()) {
|
||||
} else {
|
||||
Api::SendConfirmedFile(session, _result);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user