diff --git a/TelegramCore.xcodeproj/project.pbxproj b/TelegramCore.xcodeproj/project.pbxproj index 15f6b01e9d..cbafd53561 100644 --- a/TelegramCore.xcodeproj/project.pbxproj +++ b/TelegramCore.xcodeproj/project.pbxproj @@ -2328,6 +2328,7 @@ "$(PROJECT_DIR)/third-party/FFmpeg-iOS/lib", "$(PROJECT_DIR)/third-party/libwebp/lib", ); + MODULEMAP_PRIVATE_FILE = "$(SRCROOT)/TelegramCore/module.private.modulemap"; OTHER_LDFLAGS = "-Wl,-dead_strip"; PRODUCT_BUNDLE_IDENTIFIER = org.telegram.TelegramCore; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2369,6 +2370,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; + MODULEMAP_PRIVATE_FILE = "$(SRCROOT)/TelegramCore/module.private-mac.modulemap"; PRODUCT_BUNDLE_IDENTIFIER = org.telegram.Telegram.TelegramCoreMac; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; @@ -2448,6 +2450,7 @@ "$(PROJECT_DIR)/third-party/FFmpeg-iOS/lib", "$(PROJECT_DIR)/third-party/libwebp/lib", ); + MODULEMAP_PRIVATE_FILE = "$(SRCROOT)/TelegramCore/module.private.modulemap"; OTHER_LDFLAGS = "-Wl,-dead_strip"; PRODUCT_BUNDLE_IDENTIFIER = org.telegram.TelegramCore; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2592,6 +2595,7 @@ "$(PROJECT_DIR)/third-party/FFmpeg-iOS/lib", "$(PROJECT_DIR)/third-party/libwebp/lib", ); + MODULEMAP_PRIVATE_FILE = "$(SRCROOT)/TelegramCore/module.private.modulemap"; OTHER_LDFLAGS = "-Wl,-dead_strip"; OTHER_SWIFT_FLAGS = "-DDEBUG -Xfrontend -debug-time-function-bodies"; PRODUCT_BUNDLE_IDENTIFIER = org.telegram.TelegramCore; @@ -2629,6 +2633,7 @@ "$(PROJECT_DIR)/third-party/FFmpeg-iOS/lib", "$(PROJECT_DIR)/third-party/libwebp/lib", ); + MODULEMAP_PRIVATE_FILE = "$(SRCROOT)/TelegramCore/module.private.modulemap"; OTHER_LDFLAGS = "-Wl,-dead_strip"; OTHER_SWIFT_FLAGS = "-DDEBUG -Xfrontend -debug-time-function-bodies"; PRODUCT_BUNDLE_IDENTIFIER = org.telegram.TelegramCore; @@ -2682,6 +2687,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; + MODULEMAP_PRIVATE_FILE = "$(SRCROOT)/TelegramCore/module.private-mac.modulemap"; OTHER_SWIFT_FLAGS = "-DDEBUG"; PRODUCT_BUNDLE_IDENTIFIER = org.telegram.Telegram.TelegramCoreMac; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2712,6 +2718,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; + MODULEMAP_PRIVATE_FILE = "$(SRCROOT)/TelegramCore/module.private-mac.modulemap"; OTHER_SWIFT_FLAGS = "-DDEBUG"; PRODUCT_BUNDLE_IDENTIFIER = org.telegram.Telegram.TelegramCoreMac; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2741,6 +2748,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; + MODULEMAP_PRIVATE_FILE = "$(SRCROOT)/TelegramCore/module.private-mac.modulemap"; PRODUCT_BUNDLE_IDENTIFIER = org.telegram.Telegram.TelegramCoreMac; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; diff --git a/TelegramCore/Account.swift b/TelegramCore/Account.swift index e327067052..c993147b83 100644 --- a/TelegramCore/Account.swift +++ b/TelegramCore/Account.swift @@ -678,7 +678,7 @@ public class Account { } else { return .complete() } - } + } self.updatedPresenceDisposable.set(updatedPresence.start()) self.deviceContactListDisposable.set(managedDeviceContacts(postbox: self.postbox, network: self.network, deviceContacts: self.deviceContactList.get()).start()) diff --git a/TelegramCore/ConvertGroupToSupergroup.swift b/TelegramCore/ConvertGroupToSupergroup.swift index 09e49ef89d..8d4ceab07c 100644 --- a/TelegramCore/ConvertGroupToSupergroup.swift +++ b/TelegramCore/ConvertGroupToSupergroup.swift @@ -18,6 +18,7 @@ public func convertGroupToSupergroup(account: Account, peerId: PeerId) -> Signal |> mapError { _ -> ConvertGroupToSupergroupError in return .generic } + |> timeout(5.0, queue: Queue.concurrentDefaultQueue(), alternate: .fail(.generic)) |> mapToSignal { updates -> Signal in account.stateManager.addUpdates(updates) var createdPeerId: PeerId? diff --git a/TelegramCore/RequestUserPhotos.swift b/TelegramCore/RequestUserPhotos.swift index 6be45d2937..3f718fbdc9 100644 --- a/TelegramCore/RequestUserPhotos.swift +++ b/TelegramCore/RequestUserPhotos.swift @@ -13,6 +13,7 @@ import Foundation public struct TelegramPeerPhoto { public let image: TelegramMediaImage + public let reference:TelegramMediaRemoteImageReference public let index:Int public let totalCount:Int } @@ -45,13 +46,16 @@ public func requestPeerPhotos(account:Account, peerId:PeerId) -> Signal<[Telegra for i in 0 ..< photos.count { let photo = photos[i] let image:TelegramMediaImage + let reference: TelegramMediaRemoteImageReference switch photo { case let .photo(data): image = TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.CloudImage, id: data.id), representations: telegramMediaImageRepresentationsFromApiSizes(data.sizes)) + reference = .remoteImage(imageId: data.id, accessHash: data.accessHash) case let .photoEmpty(id: id): image = TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.CloudImage, id: id), representations: []) + reference = .remoteImage(imageId: id, accessHash: 0) } - images.append(TelegramPeerPhoto(image: image, index: i, totalCount: totalCount)) + images.append(TelegramPeerPhoto(image: image, reference: reference, index: i, totalCount: totalCount)) } return images @@ -116,7 +120,7 @@ public func requestPeerPhotos(account:Account, peerId:PeerId) -> Signal<[Telegra switch media.action { case let .photoUpdated(image): if let image = image { - photos.append(TelegramPeerPhoto(image: image, index: index, totalCount: messages.count)) + photos.append(TelegramPeerPhoto(image: image, reference: .none, index: index, totalCount: messages.count)) } default: break diff --git a/TelegramCore/TelegramMediaImage.swift b/TelegramCore/TelegramMediaImage.swift index 02ce510f0e..dd1ce7763f 100644 --- a/TelegramCore/TelegramMediaImage.swift +++ b/TelegramCore/TelegramMediaImage.swift @@ -7,6 +7,7 @@ import Foundation public enum TelegramMediaRemoteImageReference { case remoteImage(imageId: Int64, accessHash: Int64) + case none } public final class TelegramMediaImage: Media, Equatable { diff --git a/TelegramCore/TelegramUser.swift b/TelegramCore/TelegramUser.swift index 926d443212..2b91f1d71e 100644 --- a/TelegramCore/TelegramUser.swift +++ b/TelegramCore/TelegramUser.swift @@ -241,42 +241,42 @@ func parsedTelegramProfilePhoto(_ photo: Api.UserProfilePhoto?) -> [TelegramMedi public extension TelegramUser { public convenience init(user: Api.User) { switch user { - case let .user(flags, id, accessHash, firstName, lastName, username, phone, photo, _, _, _, botInlinePlaceholder, _): - var telegramPhoto: [TelegramMediaImageRepresentation] = [] - if let photo = photo { - switch photo { - case let .userProfilePhoto(_, photoSmall, photoBig): - if let smallResource = mediaResourceFromApiFileLocation(photoSmall, size: nil), let largeResource = mediaResourceFromApiFileLocation(photoBig, size: nil) { - telegramPhoto.append(TelegramMediaImageRepresentation(dimensions: CGSize(width: 80.0, height: 80.0), resource: smallResource)) - telegramPhoto.append(TelegramMediaImageRepresentation(dimensions: CGSize(width: 640.0, height: 640.0), resource: largeResource)) - } - case .userProfilePhotoEmpty: - break + case let .user(flags, id, accessHash, firstName, lastName, username, phone, photo, _, _, _, botInlinePlaceholder, _): + var telegramPhoto: [TelegramMediaImageRepresentation] = [] + if let photo = photo { + switch photo { + case let .userProfilePhoto(_, photoSmall, photoBig): + if let smallResource = mediaResourceFromApiFileLocation(photoSmall, size: nil), let largeResource = mediaResourceFromApiFileLocation(photoBig, size: nil) { + telegramPhoto.append(TelegramMediaImageRepresentation(dimensions: CGSize(width: 80.0, height: 80.0), resource: smallResource)) + telegramPhoto.append(TelegramMediaImageRepresentation(dimensions: CGSize(width: 640.0, height: 640.0), resource: largeResource)) } + case .userProfilePhotoEmpty: + break } - - var userFlags: UserInfoFlags = [] - if (flags & (1 << 17)) != 0 { - userFlags.insert(.isVerified) + } + + var userFlags: UserInfoFlags = [] + if (flags & (1 << 17)) != 0 { + userFlags.insert(.isVerified) + } + + var botInfo: BotUserInfo? + if (flags & (1 << 14)) != 0 { + var botFlags = BotUserInfoFlags() + if (flags & (1 << 15)) != 0 { + botFlags.insert(.hasAccessToChatHistory) } - - var botInfo: BotUserInfo? - if (flags & (1 << 14)) != 0 { - var botFlags = BotUserInfoFlags() - if (flags & (1 << 15)) != 0 { - botFlags.insert(.hasAccessToChatHistory) - } - if (flags & (1 << 16)) == 0 { - botFlags.insert(.worksWithGroups) - } - if (flags & (1 << 21)) == 0 { - botFlags.insert(.requiresGeolocationForInlineRequests) - } - botInfo = BotUserInfo(flags: botFlags, inlinePlaceholder: botInlinePlaceholder) + if (flags & (1 << 16)) == 0 { + botFlags.insert(.worksWithGroups) } - self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: id), accessHash: accessHash, firstName: firstName, lastName: lastName, username: username, phone: phone, photo: telegramPhoto, botInfo: botInfo, flags: userFlags) - case let .userEmpty(id): - self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: id), accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, flags: []) + if (flags & (1 << 21)) == 0 { + botFlags.insert(.requiresGeolocationForInlineRequests) + } + botInfo = BotUserInfo(flags: botFlags, inlinePlaceholder: botInlinePlaceholder) + } + self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: id), accessHash: accessHash, firstName: firstName, lastName: lastName, username: username, phone: phone, photo: telegramPhoto, botInfo: botInfo, flags: userFlags) + case let .userEmpty(id): + self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: id), accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, flags: []) } } diff --git a/TelegramCore/module.private-mac.modulemap b/TelegramCore/module.private-mac.modulemap new file mode 100644 index 0000000000..4d71be2a5a --- /dev/null +++ b/TelegramCore/module.private-mac.modulemap @@ -0,0 +1,3 @@ +module TelegramCoreMac.TelegramCorePrivate { + export * +}