- prem required error for secret chat

- better struct for privacy settings
This commit is contained in:
Mikhail Filimonov 2024-04-01 13:27:52 +04:00
parent 6ceba731ac
commit 08e2e0b123
2 changed files with 17 additions and 14 deletions

View File

@ -107,21 +107,21 @@ public enum SelectivePrivacySettings: Equatable {
} }
public struct AccountPrivacySettings: Equatable { public struct AccountPrivacySettings: Equatable {
public let presence: SelectivePrivacySettings public var presence: SelectivePrivacySettings
public let groupInvitations: SelectivePrivacySettings public var groupInvitations: SelectivePrivacySettings
public let voiceCalls: SelectivePrivacySettings public var voiceCalls: SelectivePrivacySettings
public let voiceCallsP2P: SelectivePrivacySettings public var voiceCallsP2P: SelectivePrivacySettings
public let profilePhoto: SelectivePrivacySettings public var profilePhoto: SelectivePrivacySettings
public let forwards: SelectivePrivacySettings public var forwards: SelectivePrivacySettings
public let phoneNumber: SelectivePrivacySettings public var phoneNumber: SelectivePrivacySettings
public let phoneDiscoveryEnabled: Bool public var phoneDiscoveryEnabled: Bool
public let voiceMessages: SelectivePrivacySettings public var voiceMessages: SelectivePrivacySettings
public let bio: SelectivePrivacySettings public var bio: SelectivePrivacySettings
public let birthday: SelectivePrivacySettings public var birthday: SelectivePrivacySettings
public let globalSettings: GlobalPrivacySettings public var globalSettings: GlobalPrivacySettings
public let accountRemovalTimeout: Int32 public var accountRemovalTimeout: Int32
public let messageAutoremoveTimeout: Int32? public var messageAutoremoveTimeout: Int32?
public init(presence: SelectivePrivacySettings, groupInvitations: SelectivePrivacySettings, voiceCalls: SelectivePrivacySettings, voiceCallsP2P: SelectivePrivacySettings, profilePhoto: SelectivePrivacySettings, forwards: SelectivePrivacySettings, phoneNumber: SelectivePrivacySettings, phoneDiscoveryEnabled: Bool, voiceMessages: SelectivePrivacySettings, bio: SelectivePrivacySettings, birthday: SelectivePrivacySettings, globalSettings: GlobalPrivacySettings, accountRemovalTimeout: Int32, messageAutoremoveTimeout: Int32?) { public init(presence: SelectivePrivacySettings, groupInvitations: SelectivePrivacySettings, voiceCalls: SelectivePrivacySettings, voiceCallsP2P: SelectivePrivacySettings, profilePhoto: SelectivePrivacySettings, forwards: SelectivePrivacySettings, phoneNumber: SelectivePrivacySettings, phoneDiscoveryEnabled: Bool, voiceMessages: SelectivePrivacySettings, bio: SelectivePrivacySettings, birthday: SelectivePrivacySettings, globalSettings: GlobalPrivacySettings, accountRemovalTimeout: Int32, messageAutoremoveTimeout: Int32?) {
self.presence = presence self.presence = presence

View File

@ -7,6 +7,7 @@ import MtProtoKit
public enum CreateSecretChatError { public enum CreateSecretChatError {
case generic case generic
case limitExceeded case limitExceeded
case premiumRequired(EnginePeer)
} }
func _internal_createSecretChat(account: Account, peerId: PeerId) -> Signal<PeerId, CreateSecretChatError> { func _internal_createSecretChat(account: Account, peerId: PeerId) -> Signal<PeerId, CreateSecretChatError> {
@ -34,6 +35,8 @@ func _internal_createSecretChat(account: Account, peerId: PeerId) -> Signal<Peer
|> mapError { error -> CreateSecretChatError in |> mapError { error -> CreateSecretChatError in
if error.errorDescription.hasPrefix("FLOOD_WAIT_") { if error.errorDescription.hasPrefix("FLOOD_WAIT_") {
return .limitExceeded return .limitExceeded
} else if error.errorDescription.hasPrefix("PRIVACY_PREMIUM_REQUIRED") {
return .premiumRequired(.init(peer))
} else { } else {
return .generic return .generic
} }