diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/AdMessages.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/AdMessages.swift index c558333abc..acc75aa7db 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/AdMessages.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/AdMessages.swift @@ -532,21 +532,7 @@ private class AdMessagesHistoryContextImpl { } func markAction(opaqueId: Data) { - let account = self.account - let signal: Signal = account.postbox.transaction { transaction -> Api.InputChannel? in - return transaction.getPeer(self.peerId).flatMap(apiInputChannel) - } - |> mapToSignal { inputChannel -> Signal in - guard let inputChannel = inputChannel else { - return .complete() - } - return account.network.request(Api.functions.channels.clickSponsoredMessage(channel: inputChannel, randomId: Buffer(data: opaqueId))) - |> `catch` { _ -> Signal in - return .single(.boolFalse) - } - |> ignoreValues - } - let _ = signal.start() + _internal_markAdAction(account: self.account, peerId: self.peerId, opaqueId: opaqueId) } func remove(opaqueId: Data) { @@ -619,3 +605,21 @@ public class AdMessagesHistoryContext { } } } + + +func _internal_markAdAction(account: Account, peerId: EnginePeer.Id, opaqueId: Data) { + let signal: Signal = account.postbox.transaction { transaction -> Api.InputChannel? in + return transaction.getPeer(peerId).flatMap(apiInputChannel) + } + |> mapToSignal { inputChannel -> Signal in + guard let inputChannel = inputChannel else { + return .complete() + } + return account.network.request(Api.functions.channels.clickSponsoredMessage(channel: inputChannel, randomId: Buffer(data: opaqueId))) + |> `catch` { _ -> Signal in + return .single(.boolFalse) + } + |> ignoreValues + } + let _ = signal.start() +} diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift index 8979290338..a85b0c656c 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift @@ -1466,6 +1466,9 @@ public extension TelegramEngine { public func updateExtendedMedia(messageIds: [EngineMessage.Id]) -> Signal { return _internal_updateExtendedMedia(account: self.account, messageIds: messageIds) } + public func markAdAction(peerId: EnginePeer.Id, opaqueId: Data) { + _internal_markAdAction(account: self.account, peerId: peerId, opaqueId: opaqueId) + } public func getAllLocalChannels(count: Int) -> Signal<[EnginePeer.Id], NoError> { return self.account.postbox.transaction { transaction -> [EnginePeer.Id] in