Skip to content

Commit

Permalink
Bail early on !requirePremiun
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac committed Jan 17, 2024
1 parent 3fc919e commit d0e0f30
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
}

Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit d0e0f30

Please sign in to comment.