mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Update API
This commit is contained in:
parent
af4062ac2a
commit
9adbb61a02
@ -20,7 +20,7 @@ public extension Message {
|
||||
public extension RestrictedContentMessageAttribute {
|
||||
func platformText(platform: String, contentSettings: ContentSettings) -> String? {
|
||||
for rule in self.rules {
|
||||
if rule.isSensitive {
|
||||
if rule.reason == "sensitive" {
|
||||
continue
|
||||
}
|
||||
if rule.platform == "all" || rule.platform == "ios" || contentSettings.addContentRestrictionReasons.contains(rule.platform) {
|
||||
|
@ -451,7 +451,7 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
||||
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
|
||||
case let .sensitiveContent(text, value):
|
||||
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { value in
|
||||
arguments.toggleSensitiveContent(value)
|
||||
arguments.toggleOtherSensitiveContent(value)
|
||||
}, tag: DataAndStorageEntryTag.sensitiveContent)
|
||||
case let .sensitiveContentInfo(text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section)
|
||||
@ -674,7 +674,7 @@ private func dataAndStorageControllerEntries(state: DataAndStorageControllerStat
|
||||
entries.append(.raiseToListen(presentationData.theme, presentationData.strings.Settings_RaiseToListen, data.mediaInputSettings.enableRaiseToSpeak))
|
||||
entries.append(.raiseToListenInfo(presentationData.theme, presentationData.strings.Settings_RaiseToListenInfo))
|
||||
|
||||
entries.append(.sensitiveContent(presentationData.strings.Settings_SensitiveContent, mediaSettings.showSensitiveContent))
|
||||
entries.append(.sensitiveContent(presentationData.strings.Settings_SensitiveContent, contentSettingsConfiguration?.sensitiveContentEnabled ?? false))
|
||||
entries.append(.sensitiveContentInfo(presentationData.strings.Settings_SensitiveContentInfo))
|
||||
|
||||
let proxyValue: String
|
||||
@ -691,11 +691,11 @@ private func dataAndStorageControllerEntries(state: DataAndStorageControllerStat
|
||||
entries.append(.connectionHeader(presentationData.theme, presentationData.strings.ChatSettings_ConnectionType_Title.uppercased()))
|
||||
entries.append(.connectionProxy(presentationData.theme, presentationData.strings.SocksProxySetup_Title, proxyValue))
|
||||
|
||||
#if DEBUG
|
||||
if let contentSettingsConfiguration = contentSettingsConfiguration, contentSettingsConfiguration.canAdjustSensitiveContent {
|
||||
entries.append(.otherSensitiveContent("Display Sensitive Content", contentSettingsConfiguration.sensitiveContentEnabled))
|
||||
}
|
||||
#endif
|
||||
// #if DEBUG
|
||||
// if let contentSettingsConfiguration = contentSettingsConfiguration, contentSettingsConfiguration.canAdjustSensitiveContent {
|
||||
// entries.append(.otherSensitiveContent("Display Sensitive Content", contentSettingsConfiguration.sensitiveContentEnabled))
|
||||
// }
|
||||
// #endif
|
||||
|
||||
return entries
|
||||
}
|
||||
|
@ -803,7 +803,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1929860175] = { return Api.RequestedPeer.parse_requestedPeerChat($0) }
|
||||
dict[-701500310] = { return Api.RequestedPeer.parse_requestedPeerUser($0) }
|
||||
dict[-797791052] = { return Api.RestrictionReason.parse_restrictionReason($0) }
|
||||
dict[2007669447] = { return Api.RestrictionReason.parse_restrictionReasonSensitive($0) }
|
||||
dict[894777186] = { return Api.RichText.parse_textAnchor($0) }
|
||||
dict[1730456516] = { return Api.RichText.parse_textBold($0) }
|
||||
dict[2120376535] = { return Api.RichText.parse_textConcat($0) }
|
||||
|
@ -397,7 +397,6 @@ public extension Api {
|
||||
public extension Api {
|
||||
enum RestrictionReason: TypeConstructorDescription {
|
||||
case restrictionReason(platform: String, reason: String, text: String)
|
||||
case restrictionReasonSensitive(platform: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -409,12 +408,6 @@ public extension Api {
|
||||
serializeString(reason, buffer: buffer, boxed: false)
|
||||
serializeString(text, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .restrictionReasonSensitive(let platform):
|
||||
if boxed {
|
||||
buffer.appendInt32(2007669447)
|
||||
}
|
||||
serializeString(platform, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,8 +415,6 @@ public extension Api {
|
||||
switch self {
|
||||
case .restrictionReason(let platform, let reason, let text):
|
||||
return ("restrictionReason", [("platform", platform as Any), ("reason", reason as Any), ("text", text as Any)])
|
||||
case .restrictionReasonSensitive(let platform):
|
||||
return ("restrictionReasonSensitive", [("platform", platform as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,17 +435,6 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_restrictionReasonSensitive(_ reader: BufferReader) -> RestrictionReason? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.RestrictionReason.restrictionReasonSensitive(platform: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,6 @@ extension RestrictionRule {
|
||||
switch apiReason {
|
||||
case let .restrictionReason(platform, reason, text):
|
||||
self.init(platform: platform, reason: reason, text: text)
|
||||
case let .restrictionReasonSensitive(platform):
|
||||
self.init(platform: platform)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,34 +4,29 @@ public final class RestrictionRule: PostboxCoding, Equatable {
|
||||
public let platform: String
|
||||
public let reason: String
|
||||
public let text: String
|
||||
public let isSensitive: Bool
|
||||
|
||||
public init(platform: String, reason: String, text: String) {
|
||||
self.platform = platform
|
||||
self.reason = reason
|
||||
self.text = text
|
||||
self.isSensitive = false
|
||||
}
|
||||
|
||||
public init(platform: String) {
|
||||
self.platform = platform
|
||||
self.reason = ""
|
||||
self.text = ""
|
||||
self.isSensitive = true
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.platform = decoder.decodeStringForKey("p", orElse: "all")
|
||||
self.reason = decoder.decodeStringForKey("r", orElse: "")
|
||||
self.text = decoder.decodeStringForKey("t", orElse: "")
|
||||
self.isSensitive = decoder.decodeBoolForKey("s", orElse: false)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.platform, forKey: "p")
|
||||
encoder.encodeString(self.reason, forKey: "r")
|
||||
encoder.encodeString(self.text, forKey: "t")
|
||||
encoder.encodeBool(self.isSensitive, forKey: "s")
|
||||
}
|
||||
|
||||
public static func ==(lhs: RestrictionRule, rhs: RestrictionRule) -> Bool {
|
||||
@ -44,9 +39,6 @@ public final class RestrictionRule: PostboxCoding, Equatable {
|
||||
if lhs.text != rhs.text {
|
||||
return false
|
||||
}
|
||||
if lhs.isSensitive != rhs.isSensitive {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ public extension Message {
|
||||
}
|
||||
|
||||
func isSensitiveContent(platform: String) -> Bool {
|
||||
if let rule = self.restrictedContentAttribute?.rules.first(where: { $0.isSensitive }) {
|
||||
if let rule = self.restrictedContentAttribute?.rules.first(where: { $0.reason == "sensitive" }) {
|
||||
if rule.platform == "all" || rule.platform == platform {
|
||||
return true
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public extension Peer {
|
||||
|
||||
if let restrictionInfo = restrictionInfo {
|
||||
for rule in restrictionInfo.rules {
|
||||
if rule.isSensitive {
|
||||
if rule.reason == "sensitive" {
|
||||
continue
|
||||
}
|
||||
if rule.platform == "all" || rule.platform == platform || contentSettings.addContentRestrictionReasons.contains(rule.platform) {
|
||||
@ -234,7 +234,7 @@ public extension Peer {
|
||||
break
|
||||
}
|
||||
|
||||
if let restrictionInfo, let rule = restrictionInfo.rules.first(where: { $0.isSensitive }) {
|
||||
if let restrictionInfo, let rule = restrictionInfo.rules.first(where: { $0.reason == "sensitive" }) {
|
||||
if rule.platform == "all" || rule.platform == platform {
|
||||
return true
|
||||
}
|
||||
|
@ -4423,9 +4423,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return
|
||||
}
|
||||
if alwaysShow {
|
||||
let _ = updateMediaDisplaySettingsInteractively(accountManager: context.sharedContext.accountManager, {
|
||||
$0.withUpdatedShowSensitiveContent(true)
|
||||
}).startStandalone()
|
||||
let _ = updateRemoteContentSettingsConfiguration(postbox: context.account.postbox, network: context.account.network, sensitiveContentEnabled: true).start()
|
||||
|
||||
self.present(UndoOverlayController(presentationData: self.presentationData, content: .info(title: nil, text: self.presentationData.strings.SensitiveContent_SettingsInfo, timeout: nil, customUndoText: nil), elevatedLayout: false, position: .top, action: { [weak self] action in
|
||||
if case .info = action, let self {
|
||||
|
@ -1558,7 +1558,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
self.allAdMessagesPromise.get()
|
||||
)
|
||||
|
||||
let sharedData = self.context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.mediaDisplaySettings])
|
||||
let contentSettings = self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.Configuration.ContentSettings())
|
||||
|
||||
let maxReadStoryId: Signal<Int32?, NoError>
|
||||
if let peerId = self.chatLocation.peerId, peerId.namespace == Namespaces.Peer.CloudUser {
|
||||
@ -1636,10 +1636,9 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
audioTranscriptionTrial,
|
||||
chatThemes,
|
||||
deviceContactsNumbers,
|
||||
sharedData
|
||||
).startStrict(next: { [weak self] update, chatPresentationData, selectedMessages, updatingMedia, networkType, preferredStoryHighQuality, animatedEmojiStickers, additionalAnimatedEmojiStickers, customChannelDiscussionReadState, customThreadOutgoingReadState, availableReactions, availableMessageEffects, savedMessageTags, defaultReaction, accountPeer, suggestAudioTranscription, promises, topicAuthorId, translationState, maxReadStoryId, recommendedChannels, audioTranscriptionTrial, chatThemes, deviceContactsNumbers, sharedData in
|
||||
contentSettings
|
||||
).startStrict(next: { [weak self] update, chatPresentationData, selectedMessages, updatingMedia, networkType, preferredStoryHighQuality, animatedEmojiStickers, additionalAnimatedEmojiStickers, customChannelDiscussionReadState, customThreadOutgoingReadState, availableReactions, availableMessageEffects, savedMessageTags, defaultReaction, accountPeer, suggestAudioTranscription, promises, topicAuthorId, translationState, maxReadStoryId, recommendedChannels, audioTranscriptionTrial, chatThemes, deviceContactsNumbers, contentSettings in
|
||||
let (historyAppearsCleared, pendingUnpinnedAllMessages, pendingRemovedMessages, currentlyPlayingMessageIdAndType, scrollToMessageId, chatHasBots, allAdMessages) = promises
|
||||
let mediaSettings = sharedData.entries[ApplicationSpecificSharedDataKeys.mediaDisplaySettings]?.get(MediaDisplaySettings.self) ?? MediaDisplaySettings.defaultSettings
|
||||
|
||||
func applyHole() {
|
||||
Queue.mainQueue().async {
|
||||
@ -1857,7 +1856,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
|
||||
translateToLanguage = languageCode
|
||||
}
|
||||
|
||||
let associatedData = extractAssociatedData(chatLocation: chatLocation, view: view, automaticDownloadNetworkType: networkType, preferredStoryHighQuality: preferredStoryHighQuality, animatedEmojiStickers: animatedEmojiStickers, additionalAnimatedEmojiStickers: additionalAnimatedEmojiStickers, subject: subject, currentlyPlayingMessageId: currentlyPlayingMessageIdAndType?.0, isCopyProtectionEnabled: isCopyProtectionEnabled, availableReactions: availableReactions, availableMessageEffects: availableMessageEffects, savedMessageTags: savedMessageTags, defaultReaction: defaultReaction, isPremium: isPremium, alwaysDisplayTranscribeButton: alwaysDisplayTranscribeButton, accountPeer: accountPeer, topicAuthorId: topicAuthorId, hasBots: chatHasBots, translateToLanguage: translateToLanguage, maxReadStoryId: maxReadStoryId, recommendedChannels: recommendedChannels, audioTranscriptionTrial: audioTranscriptionTrial, chatThemes: chatThemes, deviceContactsNumbers: deviceContactsNumbers, isInline: !rotated, showSensitiveContent: mediaSettings.showSensitiveContent)
|
||||
let associatedData = extractAssociatedData(chatLocation: chatLocation, view: view, automaticDownloadNetworkType: networkType, preferredStoryHighQuality: preferredStoryHighQuality, animatedEmojiStickers: animatedEmojiStickers, additionalAnimatedEmojiStickers: additionalAnimatedEmojiStickers, subject: subject, currentlyPlayingMessageId: currentlyPlayingMessageIdAndType?.0, isCopyProtectionEnabled: isCopyProtectionEnabled, availableReactions: availableReactions, availableMessageEffects: availableMessageEffects, savedMessageTags: savedMessageTags, defaultReaction: defaultReaction, isPremium: isPremium, alwaysDisplayTranscribeButton: alwaysDisplayTranscribeButton, accountPeer: accountPeer, topicAuthorId: topicAuthorId, hasBots: chatHasBots, translateToLanguage: translateToLanguage, maxReadStoryId: maxReadStoryId, recommendedChannels: recommendedChannels, audioTranscriptionTrial: audioTranscriptionTrial, chatThemes: chatThemes, deviceContactsNumbers: deviceContactsNumbers, isInline: !rotated, showSensitiveContent: contentSettings.ignoreContentRestrictionReasons.contains("sensitive"))
|
||||
|
||||
var includeEmbeddedSavedChatInfo = false
|
||||
if case let .replyThread(message) = chatLocation, message.peerId == context.account.peerId, !rotated {
|
||||
|
@ -4,41 +4,33 @@ import SwiftSignalKit
|
||||
|
||||
public struct MediaDisplaySettings: Codable, Equatable {
|
||||
public let showNextMediaOnTap: Bool
|
||||
public let showSensitiveContent: Bool
|
||||
|
||||
public static var defaultSettings: MediaDisplaySettings {
|
||||
return MediaDisplaySettings(showNextMediaOnTap: true, showSensitiveContent: false)
|
||||
return MediaDisplaySettings(showNextMediaOnTap: true)
|
||||
}
|
||||
|
||||
public init(showNextMediaOnTap: Bool, showSensitiveContent: Bool) {
|
||||
public init(showNextMediaOnTap: Bool) {
|
||||
self.showNextMediaOnTap = showNextMediaOnTap
|
||||
self.showSensitiveContent = showSensitiveContent
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
self.showNextMediaOnTap = (try container.decode(Int32.self, forKey: "showNextMediaOnTap")) != 0
|
||||
self.showSensitiveContent = (try container.decode(Int32.self, forKey: "showSensitiveContent")) != 0
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
try container.encode((self.showNextMediaOnTap ? 1 : 0) as Int32, forKey: "showNextMediaOnTap")
|
||||
try container.encode((self.showSensitiveContent ? 1 : 0) as Int32, forKey: "showSensitiveContent")
|
||||
}
|
||||
|
||||
public static func ==(lhs: MediaDisplaySettings, rhs: MediaDisplaySettings) -> Bool {
|
||||
return lhs.showNextMediaOnTap == rhs.showNextMediaOnTap && lhs.showSensitiveContent == rhs.showSensitiveContent
|
||||
return lhs.showNextMediaOnTap == rhs.showNextMediaOnTap
|
||||
}
|
||||
|
||||
public func withUpdatedShowNextMediaOnTap(_ showNextMediaOnTap: Bool) -> MediaDisplaySettings {
|
||||
return MediaDisplaySettings(showNextMediaOnTap: showNextMediaOnTap, showSensitiveContent: self.showSensitiveContent)
|
||||
}
|
||||
|
||||
public func withUpdatedShowSensitiveContent(_ showSensitiveContent: Bool) -> MediaDisplaySettings {
|
||||
return MediaDisplaySettings(showNextMediaOnTap: self.showNextMediaOnTap, showSensitiveContent: showSensitiveContent)
|
||||
return MediaDisplaySettings(showNextMediaOnTap: showNextMediaOnTap)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user