diff --git a/TelegramCore/Api0.swift b/TelegramCore/Api0.swift index 2b08d0108f..5c4a266e3a 100644 --- a/TelegramCore/Api0.swift +++ b/TelegramCore/Api0.swift @@ -105,6 +105,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1000708810] = { return Api.help.AppUpdate.parse_noAppUpdate($0) } dict[-209337866] = { return Api.LangPackDifference.parse_langPackDifference($0) } dict[-1590738760] = { return Api.WallPaperSettings.parse_wallPaperSettings($0) } + dict[1152191385] = { return Api.EmojiURL.parse_EmojiURL($0) } dict[-791039645] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) } dict[-1736378792] = { return Api.InputCheckPasswordSRP.parse_inputCheckPasswordEmpty($0) } dict[-763367294] = { return Api.InputCheckPasswordSRP.parse_inputCheckPasswordSRP($0) } @@ -157,6 +158,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1343122938] = { return Api.PrivacyKey.parse_privacyKeyChatInvite($0) } dict[1030105979] = { return Api.PrivacyKey.parse_privacyKeyPhoneCall($0) } dict[961092808] = { return Api.PrivacyKey.parse_privacyKeyPhoneP2P($0) } + dict[1777096355] = { return Api.PrivacyKey.parse_privacyKeyForwards($0) } + dict[-1777000467] = { return Api.PrivacyKey.parse_privacyKeyProfilePhoto($0) } dict[522914557] = { return Api.Update.parse_updateNewMessage($0) } dict[1318109142] = { return Api.Update.parse_updateMessageID($0) } dict[-1576161051] = { return Api.Update.parse_updateDeleteMessages($0) } @@ -413,12 +416,14 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1107622874] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyChatInvite($0) } dict[-88417185] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneCall($0) } dict[-610373422] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneP2P($0) } + dict[-1529000952] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyForwards($0) } + dict[1461304012] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyProfilePhoto($0) } dict[235081943] = { return Api.help.RecentMeUrls.parse_recentMeUrls($0) } dict[-1606526075] = { return Api.ReplyMarkup.parse_replyKeyboardHide($0) } dict[-200242528] = { return Api.ReplyMarkup.parse_replyKeyboardForceReply($0) } dict[889353612] = { return Api.ReplyMarkup.parse_replyKeyboardMarkup($0) } dict[1218642516] = { return Api.ReplyMarkup.parse_replyInlineMarkup($0) } - dict[2147310185] = { return Api.EmojiKeywordsDifference.parse_emojiKeywordsDifference($0) } + dict[1556570557] = { return Api.EmojiKeywordsDifference.parse_emojiKeywordsDifference($0) } dict[1493171408] = { return Api.HighScore.parse_highScore($0) } dict[-305282981] = { return Api.TopPeer.parse_topPeer($0) } dict[986597452] = { return Api.contacts.Link.parse_link($0) } @@ -847,6 +852,8 @@ struct Api { _1.serialize(buffer, boxed) case let _1 as Api.WallPaperSettings: _1.serialize(buffer, boxed) + case let _1 as Api.EmojiURL: + _1.serialize(buffer, boxed) case let _1 as Api.channels.ChannelParticipant: _1.serialize(buffer, boxed) case let _1 as Api.InputCheckPasswordSRP: diff --git a/TelegramCore/Api1.swift b/TelegramCore/Api1.swift index 6ba5357258..fab820b993 100644 --- a/TelegramCore/Api1.swift +++ b/TelegramCore/Api1.swift @@ -2882,6 +2882,40 @@ extension Api { } } + } + enum EmojiURL: TypeConstructorDescription { + case EmojiURL(url: String) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .EmojiURL(let url): + if boxed { + buffer.appendInt32(1152191385) + } + serializeString(url, buffer: buffer, boxed: false) + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .EmojiURL(let url): + return ("EmojiURL", [("url", url)]) + } + } + + static func parse_EmojiURL(_ reader: BufferReader) -> EmojiURL? { + var _1: String? + _1 = parseString(reader) + let _c1 = _1 != nil + if _c1 { + return Api.EmojiURL.EmojiURL(url: _1!) + } + else { + return nil + } + } + } enum InputCheckPasswordSRP: TypeConstructorDescription { case inputCheckPasswordEmpty @@ -3678,6 +3712,8 @@ extension Api { case privacyKeyChatInvite case privacyKeyPhoneCall case privacyKeyPhoneP2P + case privacyKeyForwards + case privacyKeyProfilePhoto func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -3704,6 +3740,18 @@ extension Api { buffer.appendInt32(961092808) } + break + case .privacyKeyForwards: + if boxed { + buffer.appendInt32(1777096355) + } + + break + case .privacyKeyProfilePhoto: + if boxed { + buffer.appendInt32(-1777000467) + } + break } } @@ -3718,6 +3766,10 @@ extension Api { return ("privacyKeyPhoneCall", []) case .privacyKeyPhoneP2P: return ("privacyKeyPhoneP2P", []) + case .privacyKeyForwards: + return ("privacyKeyForwards", []) + case .privacyKeyProfilePhoto: + return ("privacyKeyProfilePhoto", []) } } @@ -3733,6 +3785,12 @@ extension Api { static func parse_privacyKeyPhoneP2P(_ reader: BufferReader) -> PrivacyKey? { return Api.PrivacyKey.privacyKeyPhoneP2P } + static func parse_privacyKeyForwards(_ reader: BufferReader) -> PrivacyKey? { + return Api.PrivacyKey.privacyKeyForwards + } + static func parse_privacyKeyProfilePhoto(_ reader: BufferReader) -> PrivacyKey? { + return Api.PrivacyKey.privacyKeyProfilePhoto + } } enum Update: TypeConstructorDescription { @@ -10100,6 +10158,8 @@ extension Api { case inputPrivacyKeyChatInvite case inputPrivacyKeyPhoneCall case inputPrivacyKeyPhoneP2P + case inputPrivacyKeyForwards + case inputPrivacyKeyProfilePhoto func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -10126,6 +10186,18 @@ extension Api { buffer.appendInt32(-610373422) } + break + case .inputPrivacyKeyForwards: + if boxed { + buffer.appendInt32(-1529000952) + } + + break + case .inputPrivacyKeyProfilePhoto: + if boxed { + buffer.appendInt32(1461304012) + } + break } } @@ -10140,6 +10212,10 @@ extension Api { return ("inputPrivacyKeyPhoneCall", []) case .inputPrivacyKeyPhoneP2P: return ("inputPrivacyKeyPhoneP2P", []) + case .inputPrivacyKeyForwards: + return ("inputPrivacyKeyForwards", []) + case .inputPrivacyKeyProfilePhoto: + return ("inputPrivacyKeyProfilePhoto", []) } } @@ -10155,6 +10231,12 @@ extension Api { static func parse_inputPrivacyKeyPhoneP2P(_ reader: BufferReader) -> InputPrivacyKey? { return Api.InputPrivacyKey.inputPrivacyKeyPhoneP2P } + static func parse_inputPrivacyKeyForwards(_ reader: BufferReader) -> InputPrivacyKey? { + return Api.InputPrivacyKey.inputPrivacyKeyForwards + } + static func parse_inputPrivacyKeyProfilePhoto(_ reader: BufferReader) -> InputPrivacyKey? { + return Api.InputPrivacyKey.inputPrivacyKeyProfilePhoto + } } enum ReplyMarkup: TypeConstructorDescription { @@ -10268,14 +10350,15 @@ extension Api { } enum EmojiKeywordsDifference: TypeConstructorDescription { - case emojiKeywordsDifference(fromVersion: Int32, version: Int32, keywords: [Api.EmojiKeyword]) + case emojiKeywordsDifference(langCode: String, fromVersion: Int32, version: Int32, keywords: [Api.EmojiKeyword]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .emojiKeywordsDifference(let fromVersion, let version, let keywords): + case .emojiKeywordsDifference(let langCode, let fromVersion, let version, let keywords): if boxed { - buffer.appendInt32(2147310185) + buffer.appendInt32(1556570557) } + serializeString(langCode, buffer: buffer, boxed: false) serializeInt32(fromVersion, buffer: buffer, boxed: false) serializeInt32(version, buffer: buffer, boxed: false) buffer.appendInt32(481674261) @@ -10289,25 +10372,28 @@ extension Api { func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .emojiKeywordsDifference(let fromVersion, let version, let keywords): - return ("emojiKeywordsDifference", [("fromVersion", fromVersion), ("version", version), ("keywords", keywords)]) + case .emojiKeywordsDifference(let langCode, let fromVersion, let version, let keywords): + return ("emojiKeywordsDifference", [("langCode", langCode), ("fromVersion", fromVersion), ("version", version), ("keywords", keywords)]) } } static func parse_emojiKeywordsDifference(_ reader: BufferReader) -> EmojiKeywordsDifference? { - var _1: Int32? - _1 = reader.readInt32() + var _1: String? + _1 = parseString(reader) var _2: Int32? _2 = reader.readInt32() - var _3: [Api.EmojiKeyword]? + var _3: Int32? + _3 = reader.readInt32() + var _4: [Api.EmojiKeyword]? if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.EmojiKeyword.self) + _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.EmojiKeyword.self) } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.EmojiKeywordsDifference.emojiKeywordsDifference(fromVersion: _1!, version: _2!, keywords: _3!) + let _c4 = _4 != nil + if _c1 && _c2 && _c3 && _c4 { + return Api.EmojiKeywordsDifference.emojiKeywordsDifference(langCode: _1!, fromVersion: _2!, version: _3!, keywords: _4!) } else { return nil diff --git a/TelegramCore/Api3.swift b/TelegramCore/Api3.swift index 5090fa9f97..3fa3ec324c 100644 --- a/TelegramCore/Api3.swift +++ b/TelegramCore/Api3.swift @@ -2875,6 +2875,20 @@ extension Api { return result }) } + + static func getEmojiURL(langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + let buffer = Buffer() + buffer.appendInt32(-709817306) + serializeString(langCode, buffer: buffer, boxed: false) + return (FunctionDescription(name: "messages.getEmojiURL", parameters: [("langCode", langCode)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.EmojiURL? in + let reader = BufferReader(buffer) + var result: Api.EmojiURL? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.EmojiURL + } + return result + }) + } } struct channels { static func readHistory(channel: Api.InputChannel, maxId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { diff --git a/TelegramCore/NotificationExceptionsList.swift b/TelegramCore/NotificationExceptionsList.swift index 876286c6f5..2e17529bf7 100644 --- a/TelegramCore/NotificationExceptionsList.swift +++ b/TelegramCore/NotificationExceptionsList.swift @@ -7,11 +7,11 @@ import SwiftSignalKit import Postbox #endif -public final class NotificationExceptionsList : Equatable { - public let peers:[PeerId: Peer] +public final class NotificationExceptionsList: Equatable { + public let peers: [PeerId: Peer] public let settings: [PeerId: TelegramPeerNotificationSettings] - init(_ peers:[PeerId: Peer], _ settings: [PeerId : TelegramPeerNotificationSettings]) { + init(peers: [PeerId: Peer], settings: [PeerId: TelegramPeerNotificationSettings]) { self.peers = peers self.settings = settings } @@ -21,50 +21,49 @@ public final class NotificationExceptionsList : Equatable { } } - public func notificationExceptionsList(network: Network) -> Signal { return network.request(Api.functions.account.getNotifyExceptions(flags: 1 << 1, peer: nil)) |> retryRequest |> map { result in switch result { - case let .updates(updates, users, chats, _, _): - var peers:[PeerId: Peer] = [:] - var settings:[PeerId : TelegramPeerNotificationSettings] = [:] - - for user in users { - let peer = TelegramUser(user: user) - peers[peer.id] = peer - } - for chat in chats { - if let peer = parseTelegramGroupOrChannel(chat: chat) { + case let .updates(updates, users, chats, _, _): + var peers:[PeerId: Peer] = [:] + var settings:[PeerId : TelegramPeerNotificationSettings] = [:] + + for user in users { + let peer = TelegramUser(user: user) peers[peer.id] = peer } - } - - for update in updates { - switch update { - case let .updateNotifySettings(apiPeer, notifySettings): - switch apiPeer { - case let .notifyPeer(notifyPeer): - let peerId: PeerId - switch notifyPeer { - case let .peerUser(userId): - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId) - case let .peerChat(chatId): - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId) - case let .peerChannel(channelId): - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId) - } - settings[peerId] = TelegramPeerNotificationSettings(apiSettings: notifySettings) - default: - break + for chat in chats { + if let peer = parseTelegramGroupOrChannel(chat: chat) { + peers[peer.id] = peer } - default: - break } - } - - return NotificationExceptionsList(peers, settings) - default: - return NotificationExceptionsList([:], [:]) + + for update in updates { + switch update { + case let .updateNotifySettings(apiPeer, notifySettings): + switch apiPeer { + case let .notifyPeer(notifyPeer): + let peerId: PeerId + switch notifyPeer { + case let .peerUser(userId): + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId) + case let .peerChat(chatId): + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId) + case let .peerChannel(channelId): + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId) + } + settings[peerId] = TelegramPeerNotificationSettings(apiSettings: notifySettings) + default: + break + } + default: + break + } + } + + return NotificationExceptionsList(peers: peers, settings: settings) + default: + return NotificationExceptionsList(peers: [:], settings: [:]) } } } diff --git a/TelegramCore/PrivacySettings.swift b/TelegramCore/PrivacySettings.swift index 9cf4dd0199..2f0f5b34bc 100644 --- a/TelegramCore/PrivacySettings.swift +++ b/TelegramCore/PrivacySettings.swift @@ -61,14 +61,18 @@ public struct AccountPrivacySettings: Equatable { public let groupInvitations: SelectivePrivacySettings public let voiceCalls: SelectivePrivacySettings public let voiceCallsP2P: SelectivePrivacySettings + public let profilePhoto: SelectivePrivacySettings + public let forwards: SelectivePrivacySettings public let accountRemovalTimeout: Int32 - public init(presence: SelectivePrivacySettings, groupInvitations: SelectivePrivacySettings, voiceCalls: SelectivePrivacySettings, voiceCallsP2P: SelectivePrivacySettings, accountRemovalTimeout: Int32) { + public init(presence: SelectivePrivacySettings, groupInvitations: SelectivePrivacySettings, voiceCalls: SelectivePrivacySettings, voiceCallsP2P: SelectivePrivacySettings, profilePhoto: SelectivePrivacySettings, forwards: SelectivePrivacySettings, accountRemovalTimeout: Int32) { self.presence = presence self.groupInvitations = groupInvitations self.voiceCalls = voiceCalls self.voiceCallsP2P = voiceCallsP2P + self.profilePhoto = profilePhoto + self.forwards = forwards self.accountRemovalTimeout = accountRemovalTimeout } @@ -85,7 +89,12 @@ public struct AccountPrivacySettings: Equatable { if lhs.voiceCallsP2P != rhs.voiceCallsP2P { return false } - + if lhs.profilePhoto != rhs.profilePhoto { + return false + } + if lhs.forwards != rhs.forwards { + return false + } if lhs.accountRemovalTimeout != rhs.accountRemovalTimeout { return false } diff --git a/TelegramCore/StringFormat.swift b/TelegramCore/StringFormat.swift index 0165737708..3b58878fcd 100644 --- a/TelegramCore/StringFormat.swift +++ b/TelegramCore/StringFormat.swift @@ -1,26 +1,26 @@ -public func dataSizeString(_ size: Int, forceDecimal: Bool = false) -> String { - return dataSizeString(Int64(size), forceDecimal: forceDecimal) +public func dataSizeString(_ size: Int, forceDecimal: Bool = false, decimalSeparator: String = ".") -> String { + return dataSizeString(Int64(size), forceDecimal: forceDecimal, decimalSeparator: decimalSeparator) } -public func dataSizeString(_ size: Int64, forceDecimal: Bool = false) -> String { +public func dataSizeString(_ size: Int64, forceDecimal: Bool = false, decimalSeparator: String = ".") -> String { if size >= 1024 * 1024 * 1024 { - let remainder = (size % (1024 * 1024 * 1024)) / (1024 * 1024 * 102) + let remainder = Int64((Double(size % (1024 * 1024 * 1024)) / (1024 * 1024 * 102.4)).rounded(.down)) if remainder != 0 || forceDecimal { - return "\(size / (1024 * 1024 * 1024)),\(remainder) GB" + return "\(size / (1024 * 1024 * 1024))\(decimalSeparator)\(remainder) GB" } else { return "\(size / (1024 * 1024 * 1024)) GB" } } else if size >= 1024 * 1024 { - let remainder = (size % (1024 * 1024)) / (1024 * 102) + let remainder = Int64((Double(size % (1024 * 1024)) / (1024.0 * 102.4)).rounded(.down)) if remainder != 0 || forceDecimal { - return "\(size / (1024 * 1024)),\(remainder) MB" + return "\(size / (1024 * 1024))\(decimalSeparator)\(remainder) MB" } else { return "\(size / (1024 * 1024)) MB" } } else if size >= 1024 { let remainder = (size % (1024)) / (102) if remainder != 0 || forceDecimal { - return "\(size / 1024),\(remainder) KB" + return "\(size / 1024)\(decimalSeparator)\(remainder) KB" } else { return "\(size / 1024) KB" } diff --git a/TelegramCore/UpdatedAccountPrivacySettings.swift b/TelegramCore/UpdatedAccountPrivacySettings.swift index 99dc63c1d2..9a2f87c514 100644 --- a/TelegramCore/UpdatedAccountPrivacySettings.swift +++ b/TelegramCore/UpdatedAccountPrivacySettings.swift @@ -12,10 +12,12 @@ public func requestAccountPrivacySettings(account: Account) -> Signal retryRequest - |> mapToSignal { lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, autoremoveTimeout -> Signal in + |> mapToSignal { lastSeenPrivacy, groupPrivacy, voiceCallPrivacy, voiceCallP2P, profilePhotoPrivacy, forwardPrivacy, autoremoveTimeout -> Signal in let accountTimeoutSeconds: Int32 switch autoremoveTimeout { case let .accountDaysTTL(days): @@ -27,6 +29,8 @@ public func requestAccountPrivacySettings(account: Account) -> Signal Signal AccountPrivacySettings in @@ -60,7 +76,7 @@ public func requestAccountPrivacySettings(account: Account) -> Signal