mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
26 lines
878 B
Swift
26 lines
878 B
Swift
import Foundation
|
|
import TelegramCore
|
|
import Postbox
|
|
|
|
public extension Message {
|
|
func isRestricted(platform: String, contentSettings: ContentSettings) -> Bool {
|
|
if let attribute = self.restrictedContentAttribute {
|
|
return attribute.platformText(platform: platform, contentSettings: contentSettings) != nil
|
|
}
|
|
return false
|
|
}
|
|
}
|
|
|
|
public extension RestrictedContentMessageAttribute {
|
|
func platformText(platform: String, contentSettings: ContentSettings) -> String? {
|
|
for rule in self.rules {
|
|
if rule.platform == "all" || rule.platform == "ios" || contentSettings.addContentRestrictionReasons.contains(rule.platform) {
|
|
if !contentSettings.ignoreContentRestrictionReasons.contains(rule.reason) {
|
|
return rule.text
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
}
|