mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Support API [skip ci]
This commit is contained in:
parent
c0aa075f2e
commit
35d93e91b7
@ -5623,3 +5623,7 @@ Any member of this group will be able to see messages in the channel.";
|
||||
|
||||
"Stats.GroupTopInviter.History" = "History";
|
||||
"Stats.GroupTopInviter.Promote" = "Promote";
|
||||
|
||||
"PrivacySettings.AutoArchiveTitle" = "NEW CHATS FROM UNKNOWN USERS";
|
||||
"PrivacySettings.AutoArchive" = "Archive and Mute";
|
||||
"PrivacySettings.AutoArchiveInfo" = "Automatically archive and mute new chats, groups and channels from non-contacts.";
|
||||
|
@ -28,10 +28,11 @@ private final class PrivacyAndSecurityControllerArguments {
|
||||
let openPasscode: () -> Void
|
||||
let openTwoStepVerification: (TwoStepVerificationAccessConfiguration?) -> Void
|
||||
let openActiveSessions: () -> Void
|
||||
let toggleArchiveAndMuteNonContacts: (Bool) -> Void
|
||||
let setupAccountAutoremove: () -> Void
|
||||
let openDataSettings: () -> Void
|
||||
|
||||
init(account: Account, openBlockedUsers: @escaping () -> Void, openLastSeenPrivacy: @escaping () -> Void, openGroupsPrivacy: @escaping () -> Void, openVoiceCallPrivacy: @escaping () -> Void, openProfilePhotoPrivacy: @escaping () -> Void, openForwardPrivacy: @escaping () -> Void, openPhoneNumberPrivacy: @escaping () -> Void, openPasscode: @escaping () -> Void, openTwoStepVerification: @escaping (TwoStepVerificationAccessConfiguration?) -> Void, openActiveSessions: @escaping () -> Void, setupAccountAutoremove: @escaping () -> Void, openDataSettings: @escaping () -> Void) {
|
||||
init(account: Account, openBlockedUsers: @escaping () -> Void, openLastSeenPrivacy: @escaping () -> Void, openGroupsPrivacy: @escaping () -> Void, openVoiceCallPrivacy: @escaping () -> Void, openProfilePhotoPrivacy: @escaping () -> Void, openForwardPrivacy: @escaping () -> Void, openPhoneNumberPrivacy: @escaping () -> Void, openPasscode: @escaping () -> Void, openTwoStepVerification: @escaping (TwoStepVerificationAccessConfiguration?) -> Void, openActiveSessions: @escaping () -> Void, toggleArchiveAndMuteNonContacts: @escaping (Bool) -> Void, setupAccountAutoremove: @escaping () -> Void, openDataSettings: @escaping () -> Void) {
|
||||
self.account = account
|
||||
self.openBlockedUsers = openBlockedUsers
|
||||
self.openLastSeenPrivacy = openLastSeenPrivacy
|
||||
@ -43,6 +44,7 @@ private final class PrivacyAndSecurityControllerArguments {
|
||||
self.openPasscode = openPasscode
|
||||
self.openTwoStepVerification = openTwoStepVerification
|
||||
self.openActiveSessions = openActiveSessions
|
||||
self.toggleArchiveAndMuteNonContacts = toggleArchiveAndMuteNonContacts
|
||||
self.setupAccountAutoremove = setupAccountAutoremove
|
||||
self.openDataSettings = openDataSettings
|
||||
}
|
||||
@ -51,6 +53,7 @@ private final class PrivacyAndSecurityControllerArguments {
|
||||
private enum PrivacyAndSecuritySection: Int32 {
|
||||
case general
|
||||
case privacy
|
||||
case autoArchive
|
||||
case account
|
||||
case dataSettings
|
||||
}
|
||||
@ -80,6 +83,9 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
case passcode(PresentationTheme, String, Bool, String)
|
||||
case twoStepVerification(PresentationTheme, String, String, TwoStepVerificationAccessConfiguration?)
|
||||
case activeSessions(PresentationTheme, String, String)
|
||||
case autoArchiveHeader(String)
|
||||
case autoArchive(String, Bool)
|
||||
case autoArchiveInfo(String)
|
||||
case accountHeader(PresentationTheme, String)
|
||||
case accountTimeout(PresentationTheme, String, String)
|
||||
case accountInfo(PresentationTheme, String)
|
||||
@ -92,6 +98,8 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
return PrivacyAndSecuritySection.general.rawValue
|
||||
case .privacyHeader, .phoneNumberPrivacy, .lastSeenPrivacy, .profilePhotoPrivacy, .forwardPrivacy, .groupPrivacy, .selectivePrivacyInfo, .voiceCallPrivacy:
|
||||
return PrivacyAndSecuritySection.privacy.rawValue
|
||||
case .autoArchiveHeader, .autoArchive, .autoArchiveInfo:
|
||||
return PrivacyAndSecuritySection.autoArchive.rawValue
|
||||
case .accountHeader, .accountTimeout, .accountInfo:
|
||||
return PrivacyAndSecuritySection.account.rawValue
|
||||
case .dataSettings, .dataSettingsInfo:
|
||||
@ -125,16 +133,22 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
return 11
|
||||
case .selectivePrivacyInfo:
|
||||
return 12
|
||||
case .accountHeader:
|
||||
case .autoArchiveHeader:
|
||||
return 13
|
||||
case .accountTimeout:
|
||||
case .autoArchive:
|
||||
return 14
|
||||
case .accountInfo:
|
||||
case .autoArchiveInfo:
|
||||
return 15
|
||||
case .dataSettings:
|
||||
case .accountHeader:
|
||||
return 16
|
||||
case .dataSettingsInfo:
|
||||
case .accountTimeout:
|
||||
return 17
|
||||
case .accountInfo:
|
||||
return 18
|
||||
case .dataSettings:
|
||||
return 19
|
||||
case .dataSettingsInfo:
|
||||
return 20
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,6 +226,24 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .autoArchiveHeader(text):
|
||||
if case .autoArchiveHeader(text) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .autoArchive(text, value):
|
||||
if case .autoArchive(text, value) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .autoArchiveInfo(text):
|
||||
if case .autoArchiveInfo(text) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .accountHeader(lhsTheme, lhsText):
|
||||
if case let .accountHeader(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||
return true
|
||||
@ -296,6 +328,14 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
return ItemListDisclosureItem(presentationData: presentationData, icon: UIImage(bundleImageName: "Settings/MenuIcons/Websites")?.precomposed(), title: text, label: value, sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openActiveSessions()
|
||||
})
|
||||
case let .autoArchiveHeader(text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .autoArchive(text, value):
|
||||
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { value in
|
||||
arguments.toggleArchiveAndMuteNonContacts(value)
|
||||
})
|
||||
case let .autoArchiveInfo(text):
|
||||
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
|
||||
case let .accountHeader(theme, text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .accountTimeout(theme, text, value):
|
||||
@ -316,6 +356,7 @@ private enum PrivacyAndSecurityEntry: ItemListNodeEntry {
|
||||
|
||||
private struct PrivacyAndSecurityControllerState: Equatable {
|
||||
var updatingAccountTimeoutValue: Int32? = nil
|
||||
var updatingAutomaticallyArchiveAndMuteNonContacts: Bool? = nil
|
||||
}
|
||||
|
||||
private func countForSelectivePeers(_ peers: [PeerId: SelectivePrivacyPeer]) -> Int {
|
||||
@ -404,6 +445,21 @@ private func privacyAndSecurityControllerEntries(presentationData: PresentationD
|
||||
entries.append(.selectivePrivacyInfo(presentationData.theme, presentationData.strings.PrivacyLastSeenSettings_GroupsAndChannelsHelp))
|
||||
}
|
||||
|
||||
entries.append(.autoArchiveHeader(presentationData.strings.PrivacySettings_AutoArchiveTitle.uppercased()))
|
||||
if let privacySettings = privacySettings {
|
||||
let automaticallyArchiveAndMuteNonContactsValue: Bool
|
||||
if let automaticallyArchiveAndMuteNonContacts = state.updatingAutomaticallyArchiveAndMuteNonContacts {
|
||||
automaticallyArchiveAndMuteNonContactsValue = automaticallyArchiveAndMuteNonContacts
|
||||
} else {
|
||||
automaticallyArchiveAndMuteNonContactsValue = privacySettings.automaticallyArchiveAndMuteNonContacts
|
||||
}
|
||||
|
||||
entries.append(.autoArchive(presentationData.strings.PrivacySettings_AutoArchive, automaticallyArchiveAndMuteNonContactsValue))
|
||||
} else {
|
||||
entries.append(.autoArchive(presentationData.strings.PrivacySettings_AutoArchive, false))
|
||||
}
|
||||
entries.append(.autoArchiveInfo(presentationData.strings.PrivacySettings_AutoArchiveInfo))
|
||||
|
||||
entries.append(.accountHeader(presentationData.theme, presentationData.strings.PrivacySettings_DeleteAccountTitle.uppercased()))
|
||||
if let privacySettings = privacySettings {
|
||||
let value: Int32
|
||||
@ -443,6 +499,9 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
||||
let updateAccountTimeoutDisposable = MetaDisposable()
|
||||
actionsDisposable.add(updateAccountTimeoutDisposable)
|
||||
|
||||
let updateAutoArchiveDisposable = MetaDisposable()
|
||||
actionsDisposable.add(updateAutoArchiveDisposable)
|
||||
|
||||
let privacySettingsPromise = Promise<AccountPrivacySettings?>()
|
||||
privacySettingsPromise.set(.single(initialSettings) |> then(requestAccountPrivacySettings(account: context.account) |> map(Optional.init)))
|
||||
|
||||
@ -516,7 +575,7 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: updated, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: updated, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, automaticallyArchiveAndMuteNonContacts: value.automaticallyArchiveAndMuteNonContacts, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -539,7 +598,7 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: updated, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: updated, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, automaticallyArchiveAndMuteNonContacts: value.automaticallyArchiveAndMuteNonContacts, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -576,7 +635,7 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: updated, voiceCallsP2P: updatedCallsPrivacy, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: updated, voiceCallsP2P: updatedCallsPrivacy, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, automaticallyArchiveAndMuteNonContacts: value.automaticallyArchiveAndMuteNonContacts, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -599,7 +658,7 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: updated, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: updated, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, automaticallyArchiveAndMuteNonContacts: value.automaticallyArchiveAndMuteNonContacts, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -622,7 +681,7 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: updated, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: updated, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, automaticallyArchiveAndMuteNonContacts: value.automaticallyArchiveAndMuteNonContacts, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -645,7 +704,7 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: updated, phoneDiscoveryEnabled: updatedDiscoveryEnabled ?? value.phoneDiscoveryEnabled, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: updated, phoneDiscoveryEnabled: updatedDiscoveryEnabled ?? value.phoneDiscoveryEnabled, automaticallyArchiveAndMuteNonContacts: value.automaticallyArchiveAndMuteNonContacts, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
@ -700,6 +759,33 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
||||
}
|
||||
}, openActiveSessions: {
|
||||
pushControllerImpl?(recentSessionsController(context: context, activeSessionsContext: activeSessionsContext, webSessionsContext: webSessionsContext, websitesOnly: true), true)
|
||||
}, toggleArchiveAndMuteNonContacts: { archiveValue in
|
||||
updateState { state in
|
||||
var state = state
|
||||
state.updatingAutomaticallyArchiveAndMuteNonContacts = archiveValue
|
||||
return state
|
||||
}
|
||||
let applyTimeout: Signal<Void, NoError> = privacySettingsPromise.get()
|
||||
|> filter { $0 != nil }
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, automaticallyArchiveAndMuteNonContacts: archiveValue, accountRemovalTimeout: value.accountRemovalTimeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
|
||||
updateAutoArchiveDisposable.set((updateAccountAutoArchiveChats(account: context.account, value: archiveValue)
|
||||
|> mapToSignal { _ -> Signal<Void, NoError> in }
|
||||
|> then(applyTimeout)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
updateState { state in
|
||||
var state = state
|
||||
state.updatingAutomaticallyArchiveAndMuteNonContacts = nil
|
||||
return state
|
||||
}
|
||||
}))
|
||||
}, setupAccountAutoremove: {
|
||||
let signal = privacySettingsPromise.get()
|
||||
|> take(1)
|
||||
@ -724,7 +810,7 @@ public func privacyAndSecurityController(context: AccountContext, initialSetting
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { value -> Signal<Void, NoError> in
|
||||
if let value = value {
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, accountRemovalTimeout: timeout)))
|
||||
privacySettingsPromise.set(.single(AccountPrivacySettings(presence: value.presence, groupInvitations: value.groupInvitations, voiceCalls: value.voiceCalls, voiceCallsP2P: value.voiceCallsP2P, profilePhoto: value.profilePhoto, forwards: value.forwards, phoneNumber: value.phoneNumber, phoneDiscoveryEnabled: value.phoneDiscoveryEnabled, automaticallyArchiveAndMuteNonContacts: value.automaticallyArchiveAndMuteNonContacts, accountRemovalTimeout: timeout)))
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
|
@ -292,6 +292,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-525288402] = { return Api.PhotoSize.parse_photoStrippedSize($0) }
|
||||
dict[-244016606] = { return Api.messages.Stickers.parse_stickersNotModified($0) }
|
||||
dict[-463889475] = { return Api.messages.Stickers.parse_stickers($0) }
|
||||
dict[-1096616924] = { return Api.GlobalPrivacySettings.parse_globalPrivacySettings($0) }
|
||||
dict[1008755359] = { return Api.InlineBotSwitchPM.parse_inlineBotSwitchPM($0) }
|
||||
dict[223655517] = { return Api.messages.FoundStickerSets.parse_foundStickerSetsNotModified($0) }
|
||||
dict[1359533640] = { return Api.messages.FoundStickerSets.parse_foundStickerSets($0) }
|
||||
@ -1024,6 +1025,8 @@ public struct Api {
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.messages.Stickers:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.GlobalPrivacySettings:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.InlineBotSwitchPM:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.messages.FoundStickerSets:
|
||||
|
@ -9210,6 +9210,46 @@ public extension Api {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum GlobalPrivacySettings: TypeConstructorDescription {
|
||||
case globalPrivacySettings(flags: Int32, archiveAndMuteNewNoncontactPeers: Api.Bool?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .globalPrivacySettings(let flags, let archiveAndMuteNewNoncontactPeers):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1096616924)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {archiveAndMuteNewNoncontactPeers!.serialize(buffer, true)}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .globalPrivacySettings(let flags, let archiveAndMuteNewNoncontactPeers):
|
||||
return ("globalPrivacySettings", [("flags", flags), ("archiveAndMuteNewNoncontactPeers", archiveAndMuteNewNoncontactPeers)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_globalPrivacySettings(_ reader: BufferReader) -> GlobalPrivacySettings? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.Bool?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.GlobalPrivacySettings.globalPrivacySettings(flags: _1!, archiveAndMuteNewNoncontactPeers: _2)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum InlineBotSwitchPM: TypeConstructorDescription {
|
||||
case inlineBotSwitchPM(text: String, startParam: String)
|
||||
|
@ -4421,12 +4421,13 @@ public extension Api {
|
||||
})
|
||||
}
|
||||
|
||||
public static func getBroadcastStats(flags: Int32, channel: Api.InputChannel) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stats.BroadcastStats>) {
|
||||
public static func getBroadcastStats(flags: Int32, channel: Api.InputChannel, tzOffset: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.stats.BroadcastStats>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-1421720550)
|
||||
buffer.appendInt32(-433058374)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
channel.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "stats.getBroadcastStats", parameters: [("flags", flags), ("channel", channel)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.stats.BroadcastStats? in
|
||||
serializeInt32(tzOffset, buffer: buffer, boxed: false)
|
||||
return (FunctionDescription(name: "stats.getBroadcastStats", parameters: [("flags", flags), ("channel", channel), ("tzOffset", tzOffset)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.stats.BroadcastStats? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.stats.BroadcastStats?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -6614,6 +6615,34 @@ public extension Api {
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func getGlobalPrivacySettings() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.GlobalPrivacySettings>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-349483786)
|
||||
|
||||
return (FunctionDescription(name: "account.getGlobalPrivacySettings", parameters: []), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.GlobalPrivacySettings? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.GlobalPrivacySettings?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.GlobalPrivacySettings
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
public static func setGlobalPrivacySettings(settings: Api.GlobalPrivacySettings) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.GlobalPrivacySettings>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(517647042)
|
||||
settings.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "account.setGlobalPrivacySettings", parameters: [("settings", settings)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.GlobalPrivacySettings? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.GlobalPrivacySettings?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.GlobalPrivacySettings
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public struct wallet {
|
||||
public static func sendLiteRequest(body: Buffer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.wallet.LiteResponse>) {
|
||||
|
@ -198,10 +198,10 @@ private func requestChannelStats(postbox: Postbox, network: Network, datacenterI
|
||||
signal = network.download(datacenterId: Int(datacenterId), isMedia: false, tag: nil)
|
||||
|> castError(MTRpcError.self)
|
||||
|> mapToSignal { worker in
|
||||
return worker.request(Api.functions.stats.getBroadcastStats(flags: flags, channel: inputChannel))
|
||||
return worker.request(Api.functions.stats.getBroadcastStats(flags: flags, channel: inputChannel, tzOffset: 0))
|
||||
}
|
||||
} else {
|
||||
signal = network.request(Api.functions.stats.getBroadcastStats(flags: flags, channel: inputChannel))
|
||||
signal = network.request(Api.functions.stats.getBroadcastStats(flags: flags, channel: inputChannel, tzOffset: 0))
|
||||
}
|
||||
|
||||
return signal
|
||||
|
@ -95,9 +95,10 @@ public struct AccountPrivacySettings: Equatable {
|
||||
public let phoneNumber: SelectivePrivacySettings
|
||||
public let phoneDiscoveryEnabled: Bool
|
||||
|
||||
public let automaticallyArchiveAndMuteNonContacts: Bool
|
||||
public let accountRemovalTimeout: Int32
|
||||
|
||||
public init(presence: SelectivePrivacySettings, groupInvitations: SelectivePrivacySettings, voiceCalls: SelectivePrivacySettings, voiceCallsP2P: SelectivePrivacySettings, profilePhoto: SelectivePrivacySettings, forwards: SelectivePrivacySettings, phoneNumber: SelectivePrivacySettings, phoneDiscoveryEnabled: Bool, accountRemovalTimeout: Int32) {
|
||||
public init(presence: SelectivePrivacySettings, groupInvitations: SelectivePrivacySettings, voiceCalls: SelectivePrivacySettings, voiceCallsP2P: SelectivePrivacySettings, profilePhoto: SelectivePrivacySettings, forwards: SelectivePrivacySettings, phoneNumber: SelectivePrivacySettings, phoneDiscoveryEnabled: Bool, automaticallyArchiveAndMuteNonContacts: Bool, accountRemovalTimeout: Int32) {
|
||||
self.presence = presence
|
||||
self.groupInvitations = groupInvitations
|
||||
self.voiceCalls = voiceCalls
|
||||
@ -106,6 +107,7 @@ public struct AccountPrivacySettings: Equatable {
|
||||
self.forwards = forwards
|
||||
self.phoneNumber = phoneNumber
|
||||
self.phoneDiscoveryEnabled = phoneDiscoveryEnabled
|
||||
self.automaticallyArchiveAndMuteNonContacts = automaticallyArchiveAndMuteNonContacts
|
||||
self.accountRemovalTimeout = accountRemovalTimeout
|
||||
}
|
||||
|
||||
@ -134,6 +136,9 @@ public struct AccountPrivacySettings: Equatable {
|
||||
if lhs.phoneDiscoveryEnabled != rhs.phoneDiscoveryEnabled {
|
||||
return false
|
||||
}
|
||||
if lhs.automaticallyArchiveAndMuteNonContacts != rhs.automaticallyArchiveAndMuteNonContacts {
|
||||
return false
|
||||
}
|
||||
if lhs.accountRemovalTimeout != rhs.accountRemovalTimeout {
|
||||
return false
|
||||
}
|
||||
|
@ -15,11 +15,12 @@ public func requestAccountPrivacySettings(account: Account) -> Signal<AccountPri
|
||||
let phoneNumberPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyPhoneNumber))
|
||||
let phoneDiscoveryPrivacy = account.network.request(Api.functions.account.getPrivacy(key: .inputPrivacyKeyAddedByPhone))
|
||||
let autoremoveTimeout = account.network.request(Api.functions.account.getAccountTTL())
|
||||
return combineLatest(lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, phoneNumberPrivacy, phoneDiscoveryPrivacy, autoremoveTimeout)
|
||||
let globalPrivacySettings = account.network.request(Api.functions.account.getGlobalPrivacySettings())
|
||||
return combineLatest(lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, phoneNumberPrivacy, phoneDiscoveryPrivacy, autoremoveTimeout, globalPrivacySettings)
|
||||
|> `catch` { _ in
|
||||
return .complete()
|
||||
}
|
||||
|> mapToSignal { lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, phoneNumberPrivacy, phoneDiscoveryPrivacy, autoremoveTimeout -> Signal<AccountPrivacySettings, NoError> in
|
||||
|> mapToSignal { lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, phoneNumberPrivacy, phoneDiscoveryPrivacy, autoremoveTimeout, globalPrivacySettings -> Signal<AccountPrivacySettings, NoError> in
|
||||
let accountTimeoutSeconds: Int32
|
||||
switch autoremoveTimeout {
|
||||
case let .accountDaysTTL(days):
|
||||
@ -119,16 +120,35 @@ public func requestAccountPrivacySettings(account: Account) -> Signal<AccountPri
|
||||
peerMap[peer.peer.id] = peer
|
||||
}
|
||||
|
||||
let automaticallyArchiveAndMuteNonContacts: Bool
|
||||
switch globalPrivacySettings {
|
||||
case let .globalPrivacySettings(_, archiveAndMuteNewNoncontactPeers):
|
||||
if let archiveAndMuteNewNoncontactPeers = archiveAndMuteNewNoncontactPeers {
|
||||
automaticallyArchiveAndMuteNonContacts = archiveAndMuteNewNoncontactPeers == .boolTrue
|
||||
} else {
|
||||
automaticallyArchiveAndMuteNonContacts = false
|
||||
}
|
||||
}
|
||||
|
||||
return account.postbox.transaction { transaction -> AccountPrivacySettings in
|
||||
updatePeers(transaction: transaction, peers: peers.map { $0.peer }, update: { _, updated in
|
||||
return updated
|
||||
})
|
||||
|
||||
return AccountPrivacySettings(presence: SelectivePrivacySettings(apiRules: lastSeenRules, peers: peerMap), groupInvitations: SelectivePrivacySettings(apiRules: groupRules, peers: peerMap), voiceCalls: SelectivePrivacySettings(apiRules: voiceRules, peers: peerMap), voiceCallsP2P: SelectivePrivacySettings(apiRules: voiceP2PRules, peers: peerMap), profilePhoto: SelectivePrivacySettings(apiRules: profilePhotoRules, peers: peerMap), forwards: SelectivePrivacySettings(apiRules: forwardRules, peers: peerMap), phoneNumber: SelectivePrivacySettings(apiRules: phoneNumberRules, peers: peerMap), phoneDiscoveryEnabled: phoneDiscoveryValue, accountRemovalTimeout: accountTimeoutSeconds)
|
||||
return AccountPrivacySettings(presence: SelectivePrivacySettings(apiRules: lastSeenRules, peers: peerMap), groupInvitations: SelectivePrivacySettings(apiRules: groupRules, peers: peerMap), voiceCalls: SelectivePrivacySettings(apiRules: voiceRules, peers: peerMap), voiceCallsP2P: SelectivePrivacySettings(apiRules: voiceP2PRules, peers: peerMap), profilePhoto: SelectivePrivacySettings(apiRules: profilePhotoRules, peers: peerMap), forwards: SelectivePrivacySettings(apiRules: forwardRules, peers: peerMap), phoneNumber: SelectivePrivacySettings(apiRules: phoneNumberRules, peers: peerMap), phoneDiscoveryEnabled: phoneDiscoveryValue, automaticallyArchiveAndMuteNonContacts: automaticallyArchiveAndMuteNonContacts, accountRemovalTimeout: accountTimeoutSeconds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func updateAccountAutoArchiveChats(account: Account, value: Bool) -> Signal<Never, NoError> {
|
||||
|
||||
return account.network.request(Api.functions.account.setGlobalPrivacySettings(
|
||||
settings: .globalPrivacySettings(flags: 1 << 0, archiveAndMuteNewNoncontactPeers: value ? .boolTrue : .boolFalse)
|
||||
))
|
||||
|> retryRequest
|
||||
|> ignoreValues
|
||||
}
|
||||
|
||||
public func updateAccountRemovalTimeout(account: Account, timeout: Int32) -> Signal<Void, NoError> {
|
||||
return account.network.request(Api.functions.account.setAccountTTL(ttl: .accountDaysTTL(days: timeout / (24 * 60 * 60))))
|
||||
|> retryRequest
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user