From d0e0f302ddf24dc783de7ca44de4edcb68b49864 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Wed, 17 Jan 2024 23:53:28 +0400 Subject: [PATCH] Bail early on !requirePremiun --- .../Sources/TelegramEngine/Data/PeersData.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Data/PeersData.swift b/submodules/TelegramCore/Sources/TelegramEngine/Data/PeersData.swift index 842e7d34c6f..eacb8de5a24 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Data/PeersData.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Data/PeersData.swift @@ -1037,7 +1037,8 @@ public extension TelegramEngine.EngineData.Item { func keys(data: TelegramEngine.EngineData) -> [PostboxViewKey] { return [ .cachedPeerData(peerId: self.id), - .basicPeer(data.accountPeerId) + .basicPeer(data.accountPeerId), + .basicPeer(self.id) ] } @@ -1046,6 +1047,10 @@ public extension TelegramEngine.EngineData.Item { assertionFailure() return false } + guard let basicTargetPeerView = views[.basicPeer(self.id)] as? BasicPeerView else { + assertionFailure() + return false + } guard let view = views[.cachedPeerData(peerId: self.id)] as? CachedPeerDataView else { assertionFailure() return false @@ -1055,6 +1060,13 @@ public extension TelegramEngine.EngineData.Item { return false } + guard let targetPeer = basicTargetPeerView.peer as? TelegramUser else { + return false + } + if !targetPeer.flags.contains(.requirePremium) { + return false + } + if self.id.namespace == Namespaces.Peer.CloudUser { if let cachedData = view.cachedPeerData as? CachedUserData { return cachedData.flags.contains(.premiumRequired)