From 04e10f81b57993a99d54f1289b4d35d5f22c7366 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 20 Mar 2025 10:38:16 +0400 Subject: [PATCH] Send sponsored peers view requests. --- Telegram/CMakeLists.txt | 2 ++ .../SourceFiles/data/components/sponsored_messages.cpp | 5 ++++- Telegram/SourceFiles/data/components/sponsored_messages.h | 1 + Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp | 7 +++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 2e669d6324..7fa9bb9361 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -149,6 +149,8 @@ PRIVATE api/api_peer_colors.h api/api_peer_photo.cpp api/api_peer_photo.h + api/api_peer_search.cpp + api/api_peer_search.h api/api_polls.cpp api/api_polls.h api/api_premium.cpp diff --git a/Telegram/SourceFiles/data/components/sponsored_messages.cpp b/Telegram/SourceFiles/data/components/sponsored_messages.cpp index 6a1d3385b3..376a8bc693 100644 --- a/Telegram/SourceFiles/data/components/sponsored_messages.cpp +++ b/Telegram/SourceFiles/data/components/sponsored_messages.cpp @@ -509,7 +509,10 @@ void SponsoredMessages::view(const FullMsgId &fullId) { if (!entryPtr) { return; } - const auto randomId = entryPtr->sponsored.randomId; + view(entryPtr->sponsored.randomId); +} + +void SponsoredMessages::view(const QByteArray &randomId) { auto &request = _viewRequests[randomId]; if (request.requestId || TooEarlyForRequest(request.lastReceived)) { return; diff --git a/Telegram/SourceFiles/data/components/sponsored_messages.h b/Telegram/SourceFiles/data/components/sponsored_messages.h index ebcefb9e20..8edd08619c 100644 --- a/Telegram/SourceFiles/data/components/sponsored_messages.h +++ b/Telegram/SourceFiles/data/components/sponsored_messages.h @@ -117,6 +117,7 @@ public: int fallbackWidth); void view(const FullMsgId &fullId); + void view(const QByteArray &randomId); [[nodiscard]] State state(not_null history) const; diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 5b2a201379..3543b13cbd 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/painter.h" #include "ui/rect.h" #include "ui/ui_utility.h" +#include "data/components/sponsored_messages.h" #include "data/data_drafts.h" #include "data/data_folder.h" #include "data/data_forum.h" @@ -1134,6 +1135,12 @@ void InnerWidget::paintEvent(QPaintEvent *e) { const auto activePeer = activeEntry.key.peer(); for (; from < to; ++from) { const auto &result = _peerSearchResults[from]; + if (result->sponsored + && r.y() <= (skip + from * st::dialogsRowHeight) + && r.y() + r.height() >= (skip + (from + 1) * st::dialogsRowHeight)) { + session().sponsoredMessages().view( + result->sponsored->randomId); + } const auto peer = result->peer; const auto active = !activeEntry.fullId && activePeer