mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Track all sponsored messages clicks.
This commit is contained in:
parent
7ad5520b82
commit
3c44cf0251
6 changed files with 35 additions and 2 deletions
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/click_handler_types.h"
|
||||
#include "data/stickers/data_custom_emoji.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_sponsored_messages.h"
|
||||
#include "ui/text/text_custom_emoji.h"
|
||||
#include "ui/basic_click_handlers.h"
|
||||
#include "ui/emoji_config.h"
|
||||
|
@ -26,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_app_config.h"
|
||||
#include "mtproto/mtproto_config.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
namespace Core {
|
||||
|
@ -264,6 +266,16 @@ Fn<void()> UiIntegration::createSpoilerRepaint(const std::any &context) {
|
|||
return my ? my->customEmojiRepaint : nullptr;
|
||||
}
|
||||
|
||||
bool UiIntegration::allowClickHandlerActivation(
|
||||
const std::shared_ptr<ClickHandler> &handler,
|
||||
const ClickContext &context) {
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
if (const auto window = my.sessionWindow.get()) {
|
||||
window->session().data().sponsoredMessages().clicked(my.itemId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
rpl::producer<> UiIntegration::forcePopupMenuHideRequests() {
|
||||
return Core::App().passcodeLockChanges() | rpl::to_empty;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,9 @@ public:
|
|||
const QString &data,
|
||||
const std::any &context) override;
|
||||
Fn<void()> createSpoilerRepaint(const std::any &context) override;
|
||||
bool allowClickHandlerActivation(
|
||||
const std::shared_ptr<ClickHandler> &handler,
|
||||
const ClickContext &context) override;
|
||||
|
||||
QString phraseContextCopyText() override;
|
||||
QString phraseContextCopyEmail() override;
|
||||
|
|
|
@ -445,6 +445,20 @@ SponsoredMessages::Details SponsoredMessages::lookupDetails(
|
|||
};
|
||||
}
|
||||
|
||||
void SponsoredMessages::clicked(const FullMsgId &fullId) {
|
||||
const auto entryPtr = find(fullId);
|
||||
if (!entryPtr) {
|
||||
return;
|
||||
}
|
||||
const auto randomId = entryPtr->sponsored.randomId;
|
||||
const auto channel = entryPtr->item->history()->peer->asChannel();
|
||||
Assert(channel != nullptr);
|
||||
_session->api().request(MTPchannels_ClickSponsoredMessage(
|
||||
channel->inputChannel,
|
||||
MTP_bytes(randomId)
|
||||
)).send();
|
||||
}
|
||||
|
||||
SponsoredMessages::State SponsoredMessages::state(
|
||||
not_null<History*> history) const {
|
||||
const auto it = _data.find(history);
|
||||
|
|
|
@ -72,6 +72,7 @@ public:
|
|||
void request(not_null<History*> history, Fn<void()> done);
|
||||
void clearItems(not_null<History*> history);
|
||||
[[nodiscard]] Details lookupDetails(const FullMsgId &fullId) const;
|
||||
void clicked(const FullMsgId &fullId);
|
||||
|
||||
[[nodiscard]] bool append(not_null<History*> history);
|
||||
void inject(
|
||||
|
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_domain.h"
|
||||
|
@ -992,7 +993,9 @@ ClickHandlerPtr Element::fromLink() const {
|
|||
auto &sponsored = session->data().sponsoredMessages();
|
||||
const auto itemId = my.itemId ? my.itemId : item->fullId();
|
||||
const auto details = sponsored.lookupDetails(itemId);
|
||||
if (const auto &hash = details.hash) {
|
||||
if (!details.externalLink.isEmpty()) {
|
||||
File::OpenUrl(details.externalLink);
|
||||
} else if (const auto &hash = details.hash) {
|
||||
Api::CheckChatInvite(window, *hash);
|
||||
} else if (const auto peer = details.peer) {
|
||||
window->showPeerInfo(peer);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8a560488011f833b7ba534999f878d20d5152e6c
|
||||
Subproject commit fc8d4d25dee6e3ded99749c06fd870e6df4615f8
|
Loading…
Add table
Reference in a new issue