diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a2557b9b68..acbb37f19a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,7 +108,7 @@ verifysanity_beta_testflight: artifacts: when: on_failure paths: - - build/verifysanity_artifacts + - build/artifacts expire_in: 1 week verify_beta_testflight: @@ -126,5 +126,5 @@ verify_beta_testflight: artifacts: when: on_failure paths: - - build/verify_artifacts + - build/artifacts expire_in: 1 week diff --git a/Makefile b/Makefile index b3aeeafa42..77a0ce04ca 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,10 @@ BUCK_OPTIONS=\ BAZEL=$(shell which bazel) -ifneq ($(BAZEL_CACHE_DIR),) +ifneq ($(BAZEL_HTTP_CACHE_URL),) + export BAZEL_CACHE_FLAGS=\ + --remote_cache="$(BAZEL_HTTP_CACHE_URL)" +else ifneq ($(BAZEL_CACHE_DIR),) export BAZEL_CACHE_FLAGS=\ --disk_cache="${BAZEL_CACHE_DIR}" endif @@ -59,12 +62,14 @@ BAZEL_DEBUG_FLAGS=\ --features=swift.enable_batch_mode \ --swiftcopt=-j${CORE_COUNT_MINUS_ONE} \ +# --num-threads 0 forces swiftc to generate one object file per module; it: +# 1. resolves issues with the linker caused by swift-objc mixing. +# 2. makes the resulting binaries significantly smaller (up to 9% for this project). BAZEL_OPT_FLAGS=\ --features=swift.opt_uses_wmo \ --features=swift.opt_uses_osize \ - --swiftcopt='-num-threads' --swiftcopt='16' \ + --swiftcopt='-num-threads' --swiftcopt='0' \ --objc_enable_binary_stripping \ - -s \ build_arm64: check_env diff --git a/Telegram/BUILD b/Telegram/BUILD index 0b0da01a9d..7f65ccaa2f 100644 --- a/Telegram/BUILD +++ b/Telegram/BUILD @@ -1250,10 +1250,10 @@ ios_application( ":AppStringResources", ], extensions = [ - #":ShareExtension", + ":ShareExtension", #":NotificationServiceExtension", ], - #watch_application = ":TelegramWatchApp", + watch_application = ":TelegramWatchApp", deps = [ ":Main", ":Lib", diff --git a/buildbox/deploy-telegram.sh b/buildbox/deploy-telegram.sh index f1bf2e7e4d..2eb0dcaf05 100644 --- a/buildbox/deploy-telegram.sh +++ b/buildbox/deploy-telegram.sh @@ -2,6 +2,13 @@ set -e +COMMIT_COMMENT="$(git log -1 --pretty=%B)" +case "$COMMIT_COMMENT" in + *"[nodeploy]"*) + exit 0 + ;; +esac + CONFIGURATION="$1" if [ -z "$CONFIGURATION" ]; then diff --git a/submodules/DeviceLocationManager/Sources/DeviceLocationManager.swift b/submodules/DeviceLocationManager/Sources/DeviceLocationManager.swift index b4b052d256..beacf3f56b 100644 --- a/submodules/DeviceLocationManager/Sources/DeviceLocationManager.swift +++ b/submodules/DeviceLocationManager/Sources/DeviceLocationManager.swift @@ -9,9 +9,9 @@ public enum DeviceLocationMode: Int32 { private final class DeviceLocationSubscriber { let id: Int32 let mode: DeviceLocationMode - let update: (CLLocationCoordinate2D) -> Void + let update: (CLLocationCoordinate2D, Double, Double?) -> Void - init(id: Int32, mode: DeviceLocationMode, update: @escaping (CLLocationCoordinate2D) -> Void) { + init(id: Int32, mode: DeviceLocationMode, update: @escaping (CLLocationCoordinate2D, Double, Double?) -> Void) { self.id = id self.mode = mode self.update = update @@ -39,7 +39,8 @@ public final class DeviceLocationManager: NSObject { private var subscribers: [DeviceLocationSubscriber] = [] private var currentTopMode: DeviceLocationMode? - private var currentLocation: CLLocationCoordinate2D? + private var currentLocation: (CLLocationCoordinate2D, Double)? + private var currentHeading: CLHeading? public init(queue: Queue, log: ((String) -> Void)? = nil) { assert(queue.isCurrent()) @@ -60,7 +61,7 @@ public final class DeviceLocationManager: NSObject { self.manager.pausesLocationUpdatesAutomatically = false } - public func push(mode: DeviceLocationMode, updated: @escaping (CLLocationCoordinate2D) -> Void) -> Disposable { + public func push(mode: DeviceLocationMode, updated: @escaping (CLLocationCoordinate2D, Double, Double?) -> Void) -> Disposable { assert(self.queue.isCurrent()) let id = self.nextSubscriberId @@ -68,7 +69,7 @@ public final class DeviceLocationManager: NSObject { self.subscribers.append(DeviceLocationSubscriber(id: id, mode: mode, update: updated)) if let currentLocation = self.currentLocation { - updated(currentLocation) + updated(currentLocation.0, currentLocation.1, self.currentHeading?.magneticHeading) } self.updateTopMode() @@ -107,6 +108,7 @@ public final class DeviceLocationManager: NSObject { self.manager.requestAlwaysAuthorization() } self.manager.startUpdatingLocation() + self.manager.startUpdatingHeading() } } else { self.currentLocation = nil @@ -123,9 +125,22 @@ extension DeviceLocationManager: CLLocationManagerDelegate { if let location = locations.first { if self.currentTopMode != nil { - self.currentLocation = location.coordinate + self.currentLocation = (location.coordinate, location.horizontalAccuracy) for subscriber in self.subscribers { - subscriber.update(location.coordinate) + subscriber.update(location.coordinate, location.horizontalAccuracy, self.currentHeading?.magneticHeading) + } + } + } + } + + public func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) { + assert(self.queue.isCurrent()) + + if self.currentTopMode != nil { + self.currentHeading = newHeading + if let currentLocation = self.currentLocation { + for subscriber in self.subscribers { + subscriber.update(currentLocation.0, currentLocation.1, newHeading.magneticHeading) } } } @@ -135,7 +150,7 @@ extension DeviceLocationManager: CLLocationManagerDelegate { public func currentLocationManagerCoordinate(manager: DeviceLocationManager, timeout timeoutValue: Double) -> Signal { return ( Signal { subscriber in - let disposable = manager.push(mode: .precise, updated: { coordinate in + let disposable = manager.push(mode: .precise, updated: { coordinate, _, _ in subscriber.putNext(coordinate) subscriber.putCompletion() }) diff --git a/submodules/Display/BUILD b/submodules/Display/BUILD index 27763006d8..277d09ae20 100644 --- a/submodules/Display/BUILD +++ b/submodules/Display/BUILD @@ -14,7 +14,6 @@ swift_library( "//submodules/Markdown:Markdown", "//submodules/AsyncDisplayKit:AsyncDisplayKit", ], - alwayslink = True, visibility = [ "//visibility:public", ], diff --git a/submodules/InstantPageUI/Sources/InstantPageLayout.swift b/submodules/InstantPageUI/Sources/InstantPageLayout.swift index 4de40ca9b9..d1d5c4bd8d 100644 --- a/submodules/InstantPageUI/Sources/InstantPageLayout.swift +++ b/submodules/InstantPageUI/Sources/InstantPageLayout.swift @@ -816,7 +816,7 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins } } - let map = TelegramMediaMap(latitude: latitude, longitude: longitude, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil) + let map = TelegramMediaMap(latitude: latitude, longitude: longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil) let attributes: [InstantPageImageAttribute] = [InstantPageMapAttribute(zoom: zoom, dimensions: dimensions.cgSize)] var contentSize = CGSize(width: boundingWidth - safeInset * 2.0, height: 0.0) diff --git a/submodules/LegacyDataImport/Sources/LegacyChatImport.swift b/submodules/LegacyDataImport/Sources/LegacyChatImport.swift index 3280e88720..c1c77fd37f 100644 --- a/submodules/LegacyDataImport/Sources/LegacyChatImport.swift +++ b/submodules/LegacyDataImport/Sources/LegacyChatImport.swift @@ -553,7 +553,7 @@ private func loadLegacyMessages(account: TemporaryAccount, basePath: String, acc if let v = item.venue { venue = MapVenue(title: v.title ?? "", address: v.address ?? "", provider: v.provider == "" ? nil : v.provider, id: v.venueId == "" ? nil : v.venueId, type: v.type == "" ? nil : v.type) } - parsedMedia.append(TelegramMediaMap(latitude: item.latitude, longitude: item.longitude, geoPlace: nil, venue: venue, liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: item.latitude, longitude: item.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: venue, liveBroadcastingTimeout: nil)) } } } diff --git a/submodules/LiveLocationManager/Sources/LiveLocationManager.swift b/submodules/LiveLocationManager/Sources/LiveLocationManager.swift index 4c31f5589d..ca36297c12 100644 --- a/submodules/LiveLocationManager/Sources/LiveLocationManager.swift +++ b/submodules/LiveLocationManager/Sources/LiveLocationManager.swift @@ -107,9 +107,9 @@ public final class LiveLocationManagerImpl: LiveLocationManager { if let strongSelf = self { if value { let queue = strongSelf.queue - strongSelf.deviceLocationDisposable.set(strongSelf.locationManager.push(mode: .precise, updated: { coordinate in + strongSelf.deviceLocationDisposable.set(strongSelf.locationManager.push(mode: .precise, updated: { coordinate, accuracyRadius, heading in queue.async { - self?.updateDeviceCoordinate(coordinate) + self?.updateDeviceCoordinate(coordinate, accuracyRadius: accuracyRadius, heading: heading) } })) } else { @@ -158,7 +158,7 @@ public final class LiveLocationManagerImpl: LiveLocationManager { let addedStopped = stopMessageIds.subtracting(self.stopMessageIds) self.stopMessageIds = stopMessageIds for id in addedStopped { - self.editMessageDisposables.set((requestEditLiveLocation(postbox: self.postbox, network: self.network, stateManager: self.stateManager, messageId: id, coordinate: nil) + self.editMessageDisposables.set((requestEditLiveLocation(postbox: self.postbox, network: self.network, stateManager: self.stateManager, messageId: id, coordinate: nil, heading: nil) |> deliverOn(self.queue)).start(completed: { [weak self] in if let strongSelf = self { strongSelf.editMessageDisposables.set(nil, forKey: id) @@ -207,13 +207,13 @@ public final class LiveLocationManagerImpl: LiveLocationManager { self.update(broadcastToMessageIds: updatedBroadcastToMessageIds, stopMessageIds: updatedStopMessageIds) } - private func updateDeviceCoordinate(_ coordinate: CLLocationCoordinate2D) { + private func updateDeviceCoordinate(_ coordinate: CLLocationCoordinate2D, accuracyRadius: Double, heading: Double?) { assert(self.queue.isCurrent()) let ids = self.broadcastToMessageIds let remainingIds = Atomic>(value: Set(ids.keys)) for id in ids.keys { - self.editMessageDisposables.set((requestEditLiveLocation(postbox: self.postbox, network: self.network, stateManager: self.stateManager, messageId: id, coordinate: (latitude: coordinate.latitude, longitude: coordinate.longitude)) + self.editMessageDisposables.set((requestEditLiveLocation(postbox: self.postbox, network: self.network, stateManager: self.stateManager, messageId: id, coordinate: (latitude: coordinate.latitude, longitude: coordinate.longitude, accuracyRadius: Int32(accuracyRadius)), heading: Int32(heading ?? 0)) |> deliverOn(self.queue)).start(completed: { [weak self] in if let strongSelf = self { strongSelf.editMessageDisposables.set(nil, forKey: id) @@ -247,7 +247,7 @@ public final class LiveLocationManagerImpl: LiveLocationManager { let timestamp = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) for i in 0 ..< updatedMedia.count { if let media = updatedMedia[i] as? TelegramMediaMap, let _ = media.liveBroadcastingTimeout { - updatedMedia[i] = TelegramMediaMap(latitude: media.latitude, longitude: media.longitude, geoPlace: media.geoPlace, venue: media.venue, liveBroadcastingTimeout: max(0, timestamp - currentMessage.timestamp - 1)) + updatedMedia[i] = TelegramMediaMap(latitude: media.latitude, longitude: media.longitude, heading: media.heading, accuracyRadius: media.accuracyRadius, geoPlace: media.geoPlace, venue: media.venue, liveBroadcastingTimeout: max(0, timestamp - currentMessage.timestamp - 1)) } } return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, threadId: currentMessage.threadId, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: updatedMedia)) diff --git a/submodules/LocationUI/Sources/LegacyLocationController.swift b/submodules/LocationUI/Sources/LegacyLocationController.swift index 473b1f5708..3ad6687a3a 100644 --- a/submodules/LocationUI/Sources/LegacyLocationController.swift +++ b/submodules/LocationUI/Sources/LegacyLocationController.swift @@ -120,7 +120,7 @@ private func telegramMap(for location: TGLocationMediaAttachment) -> TelegramMed } else { mapVenue = nil } - return TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, geoPlace: nil, venue: mapVenue, liveBroadcastingTimeout: nil) + return TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: mapVenue, liveBroadcastingTimeout: nil) } func legacyLocationPalette(from theme: PresentationTheme) -> TGLocationPallete { diff --git a/submodules/LocationUI/Sources/LocationPickerController.swift b/submodules/LocationUI/Sources/LocationPickerController.swift index 3602c194f3..3b0c7fb075 100644 --- a/submodules/LocationUI/Sources/LocationPickerController.swift +++ b/submodules/LocationUI/Sources/LocationPickerController.swift @@ -103,7 +103,7 @@ public final class LocationPickerController: ViewController { }) let locationWithTimeout: (CLLocationCoordinate2D, Int32?) -> TelegramMediaMap = { coordinate, timeout in - return TelegramMediaMap(latitude: coordinate.latitude, longitude: coordinate.longitude, geoPlace: nil, venue: nil, liveBroadcastingTimeout: timeout) + return TelegramMediaMap(latitude: coordinate.latitude, longitude: coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: timeout) } self.interaction = LocationPickerInteraction(sendLocation: { [weak self] coordinate in @@ -168,7 +168,7 @@ public final class LocationPickerController: ViewController { } let venueType = venue.venue?.type ?? "" if ["home", "work"].contains(venueType) { - completion(TelegramMediaMap(latitude: venue.latitude, longitude: venue.longitude, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil), nil) + completion(TelegramMediaMap(latitude: venue.latitude, longitude: venue.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil), nil) } else { completion(venue, nil) } diff --git a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift index 78e0adcad2..0e61831c9c 100644 --- a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift @@ -386,10 +386,10 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM |> map { homeCoordinate, workCoordinate -> [TelegramMediaMap]? in var venues: [TelegramMediaMap] = [] if let (latitude, longitude) = homeCoordinate, let address = homeAddress { - venues.append(TelegramMediaMap(latitude: latitude, longitude: longitude, geoPlace: nil, venue: MapVenue(title: presentationData.strings.Map_Home, address: address.displayString, provider: nil, id: "home", type: "home"), liveBroadcastingTimeout: nil)) + venues.append(TelegramMediaMap(latitude: latitude, longitude: longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: presentationData.strings.Map_Home, address: address.displayString, provider: nil, id: "home", type: "home"), liveBroadcastingTimeout: nil)) } if let (latitude, longitude) = workCoordinate, let address = workAddress { - venues.append(TelegramMediaMap(latitude: latitude, longitude: longitude, geoPlace: nil, venue: MapVenue(title: presentationData.strings.Map_Work, address: address.displayString, provider: nil, id: "work", type: "work"), liveBroadcastingTimeout: nil)) + venues.append(TelegramMediaMap(latitude: latitude, longitude: longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: presentationData.strings.Map_Work, address: address.displayString, provider: nil, id: "work", type: "work"), liveBroadcastingTimeout: nil)) } return venues } diff --git a/submodules/LocationUI/Sources/LocationSearchContainerNode.swift b/submodules/LocationUI/Sources/LocationSearchContainerNode.swift index aaac3717f6..c66026b5dd 100644 --- a/submodules/LocationUI/Sources/LocationSearchContainerNode.swift +++ b/submodules/LocationUI/Sources/LocationSearchContainerNode.swift @@ -179,7 +179,7 @@ final class LocationSearchContainerNode: ASDisplayNode { guard let placemarkLocation = placemark.location else { continue } - let location = TelegramMediaMap(latitude: placemarkLocation.coordinate.latitude, longitude: placemarkLocation.coordinate.longitude, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil) + let location = TelegramMediaMap(latitude: placemarkLocation.coordinate.latitude, longitude: placemarkLocation.coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil) entries.append(LocationSearchEntry(index: index, theme: themeAndStrings.0, location: location, title: placemark.name ?? "Name", distance: placemarkLocation.distance(from: currentLocation))) diff --git a/submodules/LocationUI/Sources/LocationUtils.swift b/submodules/LocationUI/Sources/LocationUtils.swift index 901d96af3c..f8d5f0b8bc 100644 --- a/submodules/LocationUI/Sources/LocationUtils.swift +++ b/submodules/LocationUI/Sources/LocationUtils.swift @@ -8,7 +8,7 @@ import MapKit extension TelegramMediaMap { convenience init(coordinate: CLLocationCoordinate2D, liveBroadcastingTimeout: Int32? = nil) { - self.init(latitude: coordinate.latitude, longitude: coordinate.longitude, geoPlace: nil, venue: nil, liveBroadcastingTimeout: liveBroadcastingTimeout) + self.init(latitude: coordinate.latitude, longitude: coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: liveBroadcastingTimeout) } var coordinate: CLLocationCoordinate2D { diff --git a/submodules/PeerInfoUI/Sources/GroupInfoController.swift b/submodules/PeerInfoUI/Sources/GroupInfoController.swift index d93f87178e..8e74a94b0c 100644 --- a/submodules/PeerInfoUI/Sources/GroupInfoController.swift +++ b/submodules/PeerInfoUI/Sources/GroupInfoController.swift @@ -2112,7 +2112,7 @@ public func groupInfoController(context: AccountContext, peerId originalPeerId: return } let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let mapMedia = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, geoPlace: nil, venue: MapVenue(title: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), address: location.address, provider: nil, id: nil, type: nil), liveBroadcastingTimeout: nil) + let mapMedia = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), address: location.address, provider: nil, id: nil, type: nil), liveBroadcastingTimeout: nil) let controller = legacyLocationController(message: nil, mapMedia: mapMedia, context: context, openPeer: { _ in }, sendLiveLocation: { _, _ in }, stopLiveLocation: {}, openUrl: { url in context.sharedContext.applicationBindings.openUrl(url) }) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAutoNightSettingsController.swift b/submodules/SettingsUI/Sources/Themes/ThemeAutoNightSettingsController.swift index 70501d7344..2f5fe0fe67 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAutoNightSettingsController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAutoNightSettingsController.swift @@ -385,7 +385,7 @@ public func themeAutoNightSettingsController(context: AccountContext) -> ViewCon let forceUpdateLocation: () -> Void = { let locationCoordinates = Signal<(Double, Double), NoError> { subscriber in - return context.sharedContext.locationManager!.push(mode: DeviceLocationMode.precise, updated: { coordinate in + return context.sharedContext.locationManager!.push(mode: DeviceLocationMode.precise, updated: { coordinate, _, _ in subscriber.putNext((coordinate.latitude, coordinate.longitude)) subscriber.putCompletion() }) diff --git a/submodules/ShareItems/Sources/ShareItems.swift b/submodules/ShareItems/Sources/ShareItems.swift index 642dc3feb3..4d450af59b 100644 --- a/submodules/ShareItems/Sources/ShareItems.swift +++ b/submodules/ShareItems/Sources/ShareItems.swift @@ -260,9 +260,9 @@ private func preparedShareItem(account: Account, to peerId: PeerId, value: [Stri let disposable = TGShareLocationSignals.locationMessageContent(for: url).start(next: { value in if let value = value as? TGShareLocationResult { if let title = value.title { - subscriber.putNext(.done(.media(.media(.standalone(media: TelegramMediaMap(latitude: value.latitude, longitude: value.longitude, geoPlace: nil, venue: MapVenue(title: title, address: value.address, provider: value.provider, id: value.venueId, type: value.venueType), liveBroadcastingTimeout: nil)))))) + subscriber.putNext(.done(.media(.media(.standalone(media: TelegramMediaMap(latitude: value.latitude, longitude: value.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: value.address, provider: value.provider, id: value.venueId, type: value.venueType), liveBroadcastingTimeout: nil)))))) } else { - subscriber.putNext(.done(.media(.media(.standalone(media: TelegramMediaMap(latitude: value.latitude, longitude: value.longitude, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)))))) + subscriber.putNext(.done(.media(.media(.standalone(media: TelegramMediaMap(latitude: value.latitude, longitude: value.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)))))) } subscriber.putCompletion() } else if let value = value as? String { diff --git a/submodules/SyncCore/Sources/TelegramMediaAction.swift b/submodules/SyncCore/Sources/TelegramMediaAction.swift index ffd4c61755..63fe26ba31 100644 --- a/submodules/SyncCore/Sources/TelegramMediaAction.swift +++ b/submodules/SyncCore/Sources/TelegramMediaAction.swift @@ -45,6 +45,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { case botSentSecureValues(types: [SentSecureValueType]) case peerJoined case phoneNumberRequest + case geoProximityReached(distance: Int32) public init(decoder: PostboxDecoder) { let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0) @@ -95,6 +96,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { self = .peerJoined case 20: self = .phoneNumberRequest + case 21: + self = .geoProximityReached(distance: (decoder.decodeInt32ForKey("dst", orElse: 0))) default: self = .unknown } @@ -180,6 +183,9 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { encoder.encodeInt32(19, forKey: "_rawValue") case .phoneNumberRequest: encoder.encodeInt32(20, forKey: "_rawValue") + case let .geoProximityReached(distance): + encoder.encodeInt32(21, forKey: "_rawValue") + encoder.encodeInt32(distance, forKey: "dst") } } diff --git a/submodules/SyncCore/Sources/TelegramMediaMap.swift b/submodules/SyncCore/Sources/TelegramMediaMap.swift index a54f276c1a..7d069ebfe6 100644 --- a/submodules/SyncCore/Sources/TelegramMediaMap.swift +++ b/submodules/SyncCore/Sources/TelegramMediaMap.swift @@ -133,6 +133,8 @@ public final class MapVenue: PostboxCoding, Equatable { public final class TelegramMediaMap: Media { public let latitude: Double public let longitude: Double + public let heading: Double? + public let accuracyRadius: Double? public let geoPlace: NamedGeoPlace? public let venue: MapVenue? public let liveBroadcastingTimeout: Int32? @@ -140,9 +142,11 @@ public final class TelegramMediaMap: Media { public let id: MediaId? = nil public let peerIds: [PeerId] = [] - public init(latitude: Double, longitude: Double, geoPlace: NamedGeoPlace?, venue: MapVenue?, liveBroadcastingTimeout: Int32?) { + public init(latitude: Double, longitude: Double, heading: Double?, accuracyRadius: Double?, geoPlace: NamedGeoPlace?, venue: MapVenue?, liveBroadcastingTimeout: Int32?) { self.latitude = latitude self.longitude = longitude + self.heading = heading + self.accuracyRadius = accuracyRadius self.geoPlace = geoPlace self.venue = venue self.liveBroadcastingTimeout = liveBroadcastingTimeout @@ -151,6 +155,8 @@ public final class TelegramMediaMap: Media { public init(decoder: PostboxDecoder) { self.latitude = decoder.decodeDoubleForKey("la", orElse: 0.0) self.longitude = decoder.decodeDoubleForKey("lo", orElse: 0.0) + self.heading = decoder.decodeOptionalDoubleForKey("hdg") + self.accuracyRadius = decoder.decodeOptionalDoubleForKey("acc") self.geoPlace = decoder.decodeObjectForKey("gp", decoder: { NamedGeoPlace(decoder: $0) }) as? NamedGeoPlace self.venue = decoder.decodeObjectForKey("ve", decoder: { MapVenue(decoder: $0) }) as? MapVenue self.liveBroadcastingTimeout = decoder.decodeOptionalInt32ForKey("bt") @@ -159,6 +165,16 @@ public final class TelegramMediaMap: Media { public func encode(_ encoder: PostboxEncoder) { encoder.encodeDouble(self.latitude, forKey: "la") encoder.encodeDouble(self.longitude, forKey: "lo") + if let heading = self.heading { + encoder.encodeDouble(heading, forKey: "hdg") + } else { + encoder.encodeNil(forKey: "hdg") + } + if let accuracyRadius = self.accuracyRadius { + encoder.encodeDouble(accuracyRadius, forKey: "acc") + } else { + encoder.encodeNil(forKey: "acc") + } if let geoPlace = self.geoPlace { encoder.encodeObject(geoPlace, forKey: "gp") } else { @@ -181,6 +197,12 @@ public final class TelegramMediaMap: Media { if self.latitude != other.latitude || self.longitude != other.longitude { return false } + if self.heading != other.heading { + return false + } + if self.accuracyRadius != other.accuracyRadius { + return false + } if self.geoPlace != other.geoPlace { return false } diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index 8613d5a417..8ad7e05cff 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -7,7 +7,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1255641564] = { return parseString($0) } dict[-1240849242] = { return Api.messages.StickerSet.parse_stickerSet($0) } dict[-457104426] = { return Api.InputGeoPoint.parse_inputGeoPointEmpty($0) } - dict[-206066487] = { return Api.InputGeoPoint.parse_inputGeoPoint($0) } + dict[1210199983] = { return Api.InputGeoPoint.parse_inputGeoPoint($0) } dict[-784000893] = { return Api.payments.ValidatedRequestedInfo.parse_validatedRequestedInfo($0) } dict[461151667] = { return Api.ChatFull.parse_chatFull($0) } dict[-253335766] = { return Api.ChatFull.parse_channelFull($0) } @@ -209,7 +209,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1417832080] = { return Api.Update.parse_updateBotInlineQuery($0) } dict[239663460] = { return Api.Update.parse_updateBotInlineSend($0) } dict[457133559] = { return Api.Update.parse_updateEditChannelMessage($0) } - dict[-1738988427] = { return Api.Update.parse_updateChannelPinnedMessage($0) } dict[-415938591] = { return Api.Update.parse_updateBotCallbackQuery($0) } dict[-469536605] = { return Api.Update.parse_updateEditMessage($0) } dict[-103646630] = { return Api.Update.parse_updateInlineBotCallbackQuery($0) } @@ -373,9 +372,9 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-440664550] = { return Api.InputMedia.parse_inputMediaPhotoExternal($0) } dict[-78455655] = { return Api.InputMedia.parse_inputMediaDocumentExternal($0) } dict[-122978821] = { return Api.InputMedia.parse_inputMediaContact($0) } - dict[-833715459] = { return Api.InputMedia.parse_inputMediaGeoLive($0) } dict[261416433] = { return Api.InputMedia.parse_inputMediaPoll($0) } dict[-428884101] = { return Api.InputMedia.parse_inputMediaDice($0) } + dict[-1574158066] = { return Api.InputMedia.parse_inputMediaGeoLive($0) } dict[2134579434] = { return Api.InputPeer.parse_inputPeerEmpty($0) } dict[2107670217] = { return Api.InputPeer.parse_inputPeerSelf($0) } dict[396093539] = { return Api.InputPeer.parse_inputPeerChat($0) } @@ -569,13 +568,13 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1557277184] = { return Api.MessageMedia.parse_messageMediaWebPage($0) } dict[-38694904] = { return Api.MessageMedia.parse_messageMediaGame($0) } dict[-2074799289] = { return Api.MessageMedia.parse_messageMediaInvoice($0) } - dict[2084316681] = { return Api.MessageMedia.parse_messageMediaGeoLive($0) } dict[784356159] = { return Api.MessageMedia.parse_messageMediaVenue($0) } dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) } dict[-1666158377] = { return Api.MessageMedia.parse_messageMediaDocument($0) } dict[-873313984] = { return Api.MessageMedia.parse_messageMediaContact($0) } dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) } dict[1065280907] = { return Api.MessageMedia.parse_messageMediaDice($0) } + dict[-967079536] = { return Api.MessageMedia.parse_messageMediaGeoLive($0) } dict[-842892769] = { return Api.PaymentSavedCredentials.parse_paymentSavedCredentialsCard($0) } dict[1450380236] = { return Api.Null.parse_null($0) } dict[1923290508] = { return Api.auth.CodeType.parse_codeTypeSms($0) } @@ -624,7 +623,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[668375447] = { return Api.InputFileLocation.parse_inputPeerPhotoFileLocation($0) } dict[230353641] = { return Api.InputFileLocation.parse_inputStickerSetThumb($0) } dict[286776671] = { return Api.GeoPoint.parse_geoPointEmpty($0) } - dict[43446532] = { return Api.GeoPoint.parse_geoPoint($0) } + dict[-1297942941] = { return Api.GeoPoint.parse_geoPoint($0) } dict[506920429] = { return Api.InputPhoneCall.parse_inputPhoneCall($0) } dict[-1551583367] = { return Api.ReceivedNotifyMessage.parse_receivedNotifyMessage($0) } dict[-57668565] = { return Api.ChatParticipants.parse_chatParticipantsForbidden($0) } @@ -777,6 +776,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[455635795] = { return Api.MessageAction.parse_messageActionSecureValuesSentMe($0) } dict[-648257196] = { return Api.MessageAction.parse_messageActionSecureValuesSent($0) } dict[-202219658] = { return Api.MessageAction.parse_messageActionContactSignUp($0) } + dict[-1730095465] = { return Api.MessageAction.parse_messageActionGeoProximityReached($0) } dict[1399245077] = { return Api.PhoneCall.parse_phoneCallEmpty($0) } dict[462375633] = { return Api.PhoneCall.parse_phoneCallWaiting($0) } dict[-2014659757] = { return Api.PhoneCall.parse_phoneCallRequested($0) } diff --git a/submodules/TelegramApi/Sources/Api1.swift b/submodules/TelegramApi/Sources/Api1.swift index f21d28d9ca..6adfb5aa76 100644 --- a/submodules/TelegramApi/Sources/Api1.swift +++ b/submodules/TelegramApi/Sources/Api1.swift @@ -1903,7 +1903,7 @@ public struct messages { public extension Api { public enum InputGeoPoint: TypeConstructorDescription { case inputGeoPointEmpty - case inputGeoPoint(lat: Double, long: Double) + case inputGeoPoint(flags: Int32, lat: Double, long: Double, accuracyRadius: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -1913,12 +1913,14 @@ public extension Api { } break - case .inputGeoPoint(let lat, let long): + case .inputGeoPoint(let flags, let lat, let long, let accuracyRadius): if boxed { - buffer.appendInt32(-206066487) + buffer.appendInt32(1210199983) } + serializeInt32(flags, buffer: buffer, boxed: false) serializeDouble(lat, buffer: buffer, boxed: false) serializeDouble(long, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {serializeInt32(accuracyRadius!, buffer: buffer, boxed: false)} break } } @@ -1927,8 +1929,8 @@ public extension Api { switch self { case .inputGeoPointEmpty: return ("inputGeoPointEmpty", []) - case .inputGeoPoint(let lat, let long): - return ("inputGeoPoint", [("lat", lat), ("long", long)]) + case .inputGeoPoint(let flags, let lat, let long, let accuracyRadius): + return ("inputGeoPoint", [("flags", flags), ("lat", lat), ("long", long), ("accuracyRadius", accuracyRadius)]) } } @@ -1936,14 +1938,20 @@ public extension Api { return Api.InputGeoPoint.inputGeoPointEmpty } public static func parse_inputGeoPoint(_ reader: BufferReader) -> InputGeoPoint? { - var _1: Double? - _1 = reader.readDouble() + var _1: Int32? + _1 = reader.readInt32() var _2: Double? _2 = reader.readDouble() + var _3: Double? + _3 = reader.readDouble() + var _4: Int32? + if Int(_1!) & Int(1 << 0) != 0 {_4 = reader.readInt32() } let _c1 = _1 != nil let _c2 = _2 != nil - if _c1 && _c2 { - return Api.InputGeoPoint.inputGeoPoint(lat: _1!, long: _2!) + let _c3 = _3 != nil + let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil + if _c1 && _c2 && _c3 && _c4 { + return Api.InputGeoPoint.inputGeoPoint(flags: _1!, lat: _2!, long: _3!, accuracyRadius: _4) } else { return nil @@ -6128,7 +6136,6 @@ public extension Api { case updateBotInlineQuery(flags: Int32, queryId: Int64, userId: Int32, query: String, geo: Api.GeoPoint?, offset: String) case updateBotInlineSend(flags: Int32, userId: Int32, query: String, geo: Api.GeoPoint?, id: String, msgId: Api.InputBotInlineMessageID?) case updateEditChannelMessage(message: Api.Message, pts: Int32, ptsCount: Int32) - case updateChannelPinnedMessage(channelId: Int32, id: Int32) case updateBotCallbackQuery(flags: Int32, queryId: Int64, userId: Int32, peer: Api.Peer, msgId: Int32, chatInstance: Int64, data: Buffer?, gameShortName: String?) case updateEditMessage(message: Api.Message, pts: Int32, ptsCount: Int32) case updateInlineBotCallbackQuery(flags: Int32, queryId: Int64, userId: Int32, msgId: Api.InputBotInlineMessageID, chatInstance: Int64, data: Buffer?, gameShortName: String?) @@ -6491,13 +6498,6 @@ public extension Api { serializeInt32(pts, buffer: buffer, boxed: false) serializeInt32(ptsCount, buffer: buffer, boxed: false) break - case .updateChannelPinnedMessage(let channelId, let id): - if boxed { - buffer.appendInt32(-1738988427) - } - serializeInt32(channelId, buffer: buffer, boxed: false) - serializeInt32(id, buffer: buffer, boxed: false) - break case .updateBotCallbackQuery(let flags, let queryId, let userId, let peer, let msgId, let chatInstance, let data, let gameShortName): if boxed { buffer.appendInt32(-415938591) @@ -6999,8 +6999,6 @@ public extension Api { return ("updateBotInlineSend", [("flags", flags), ("userId", userId), ("query", query), ("geo", geo), ("id", id), ("msgId", msgId)]) case .updateEditChannelMessage(let message, let pts, let ptsCount): return ("updateEditChannelMessage", [("message", message), ("pts", pts), ("ptsCount", ptsCount)]) - case .updateChannelPinnedMessage(let channelId, let id): - return ("updateChannelPinnedMessage", [("channelId", channelId), ("id", id)]) case .updateBotCallbackQuery(let flags, let queryId, let userId, let peer, let msgId, let chatInstance, let data, let gameShortName): return ("updateBotCallbackQuery", [("flags", flags), ("queryId", queryId), ("userId", userId), ("peer", peer), ("msgId", msgId), ("chatInstance", chatInstance), ("data", data), ("gameShortName", gameShortName)]) case .updateEditMessage(let message, let pts, let ptsCount): @@ -7737,20 +7735,6 @@ public extension Api { return nil } } - public static func parse_updateChannelPinnedMessage(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.Update.updateChannelPinnedMessage(channelId: _1!, id: _2!) - } - else { - return nil - } - } public static func parse_updateBotCallbackQuery(_ reader: BufferReader) -> Update? { var _1: Int32? _1 = reader.readInt32() @@ -11191,9 +11175,9 @@ public extension Api { case inputMediaPhotoExternal(flags: Int32, url: String, ttlSeconds: Int32?) case inputMediaDocumentExternal(flags: Int32, url: String, ttlSeconds: Int32?) case inputMediaContact(phoneNumber: String, firstName: String, lastName: String, vcard: String) - case inputMediaGeoLive(flags: Int32, geoPoint: Api.InputGeoPoint, period: Int32?) case inputMediaPoll(flags: Int32, poll: Api.Poll, correctAnswers: [Buffer]?, solution: String?, solutionEntities: [Api.MessageEntity]?) case inputMediaDice(emoticon: String) + case inputMediaGeoLive(flags: Int32, geoPoint: Api.InputGeoPoint, heading: Int32, period: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -11321,14 +11305,6 @@ public extension Api { serializeString(lastName, buffer: buffer, boxed: false) serializeString(vcard, buffer: buffer, boxed: false) break - case .inputMediaGeoLive(let flags, let geoPoint, let period): - if boxed { - buffer.appendInt32(-833715459) - } - serializeInt32(flags, buffer: buffer, boxed: false) - geoPoint.serialize(buffer, true) - if Int(flags) & Int(1 << 1) != 0 {serializeInt32(period!, buffer: buffer, boxed: false)} - break case .inputMediaPoll(let flags, let poll, let correctAnswers, let solution, let solutionEntities): if boxed { buffer.appendInt32(261416433) @@ -11353,6 +11329,15 @@ public extension Api { } serializeString(emoticon, buffer: buffer, boxed: false) break + case .inputMediaGeoLive(let flags, let geoPoint, let heading, let period): + if boxed { + buffer.appendInt32(-1574158066) + } + serializeInt32(flags, buffer: buffer, boxed: false) + geoPoint.serialize(buffer, true) + serializeInt32(heading, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 1) != 0 {serializeInt32(period!, buffer: buffer, boxed: false)} + break } } @@ -11384,12 +11369,12 @@ public extension Api { return ("inputMediaDocumentExternal", [("flags", flags), ("url", url), ("ttlSeconds", ttlSeconds)]) case .inputMediaContact(let phoneNumber, let firstName, let lastName, let vcard): return ("inputMediaContact", [("phoneNumber", phoneNumber), ("firstName", firstName), ("lastName", lastName), ("vcard", vcard)]) - case .inputMediaGeoLive(let flags, let geoPoint, let period): - return ("inputMediaGeoLive", [("flags", flags), ("geoPoint", geoPoint), ("period", period)]) case .inputMediaPoll(let flags, let poll, let correctAnswers, let solution, let solutionEntities): return ("inputMediaPoll", [("flags", flags), ("poll", poll), ("correctAnswers", correctAnswers), ("solution", solution), ("solutionEntities", solutionEntities)]) case .inputMediaDice(let emoticon): return ("inputMediaDice", [("emoticon", emoticon)]) + case .inputMediaGeoLive(let flags, let geoPoint, let heading, let period): + return ("inputMediaGeoLive", [("flags", flags), ("geoPoint", geoPoint), ("heading", heading), ("period", period)]) } } @@ -11658,25 +11643,6 @@ public extension Api { return nil } } - public static func parse_inputMediaGeoLive(_ reader: BufferReader) -> InputMedia? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Api.InputGeoPoint? - if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.InputGeoPoint - } - var _3: Int32? - if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil - if _c1 && _c2 && _c3 { - return Api.InputMedia.inputMediaGeoLive(flags: _1!, geoPoint: _2!, period: _3) - } - else { - return nil - } - } public static func parse_inputMediaPoll(_ reader: BufferReader) -> InputMedia? { var _1: Int32? _1 = reader.readInt32() @@ -11717,6 +11683,28 @@ public extension Api { return nil } } + public static func parse_inputMediaGeoLive(_ reader: BufferReader) -> InputMedia? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Api.InputGeoPoint? + if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.InputGeoPoint + } + var _3: Int32? + _3 = reader.readInt32() + var _4: Int32? + if Int(_1!) & Int(1 << 1) != 0 {_4 = reader.readInt32() } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil + if _c1 && _c2 && _c3 && _c4 { + return Api.InputMedia.inputMediaGeoLive(flags: _1!, geoPoint: _2!, heading: _3!, period: _4) + } + else { + return nil + } + } } public enum InputPeer: TypeConstructorDescription { @@ -16448,13 +16436,13 @@ public extension Api { case messageMediaWebPage(webpage: Api.WebPage) case messageMediaGame(game: Api.Game) case messageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, receiptMsgId: Int32?, currency: String, totalAmount: Int64, startParam: String) - case messageMediaGeoLive(geo: Api.GeoPoint, period: Int32) case messageMediaVenue(geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String) case messageMediaPhoto(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?) case messageMediaDocument(flags: Int32, document: Api.Document?, ttlSeconds: Int32?) case messageMediaContact(phoneNumber: String, firstName: String, lastName: String, vcard: String, userId: Int32) case messageMediaPoll(poll: Api.Poll, results: Api.PollResults) case messageMediaDice(value: Int32, emoticon: String) + case messageMediaGeoLive(geo: Api.GeoPoint, heading: Int32, period: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -16501,13 +16489,6 @@ public extension Api { serializeInt64(totalAmount, buffer: buffer, boxed: false) serializeString(startParam, buffer: buffer, boxed: false) break - case .messageMediaGeoLive(let geo, let period): - if boxed { - buffer.appendInt32(2084316681) - } - geo.serialize(buffer, true) - serializeInt32(period, buffer: buffer, boxed: false) - break case .messageMediaVenue(let geo, let title, let address, let provider, let venueId, let venueType): if boxed { buffer.appendInt32(784356159) @@ -16559,6 +16540,14 @@ public extension Api { serializeInt32(value, buffer: buffer, boxed: false) serializeString(emoticon, buffer: buffer, boxed: false) break + case .messageMediaGeoLive(let geo, let heading, let period): + if boxed { + buffer.appendInt32(-967079536) + } + geo.serialize(buffer, true) + serializeInt32(heading, buffer: buffer, boxed: false) + serializeInt32(period, buffer: buffer, boxed: false) + break } } @@ -16576,8 +16565,6 @@ public extension Api { return ("messageMediaGame", [("game", game)]) case .messageMediaInvoice(let flags, let title, let description, let photo, let receiptMsgId, let currency, let totalAmount, let startParam): return ("messageMediaInvoice", [("flags", flags), ("title", title), ("description", description), ("photo", photo), ("receiptMsgId", receiptMsgId), ("currency", currency), ("totalAmount", totalAmount), ("startParam", startParam)]) - case .messageMediaGeoLive(let geo, let period): - return ("messageMediaGeoLive", [("geo", geo), ("period", period)]) case .messageMediaVenue(let geo, let title, let address, let provider, let venueId, let venueType): return ("messageMediaVenue", [("geo", geo), ("title", title), ("address", address), ("provider", provider), ("venueId", venueId), ("venueType", venueType)]) case .messageMediaPhoto(let flags, let photo, let ttlSeconds): @@ -16590,6 +16577,8 @@ public extension Api { return ("messageMediaPoll", [("poll", poll), ("results", results)]) case .messageMediaDice(let value, let emoticon): return ("messageMediaDice", [("value", value), ("emoticon", emoticon)]) + case .messageMediaGeoLive(let geo, let heading, let period): + return ("messageMediaGeoLive", [("geo", geo), ("heading", heading), ("period", period)]) } } @@ -16672,22 +16661,6 @@ public extension Api { return nil } } - public static func parse_messageMediaGeoLive(_ reader: BufferReader) -> MessageMedia? { - var _1: Api.GeoPoint? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.GeoPoint - } - var _2: Int32? - _2 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.MessageMedia.messageMediaGeoLive(geo: _1!, period: _2!) - } - else { - return nil - } - } public static func parse_messageMediaVenue(_ reader: BufferReader) -> MessageMedia? { var _1: Api.GeoPoint? if let signature = reader.readInt32() { @@ -16809,6 +16782,25 @@ public extension Api { return nil } } + public static func parse_messageMediaGeoLive(_ reader: BufferReader) -> MessageMedia? { + var _1: Api.GeoPoint? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.GeoPoint + } + var _2: Int32? + _2 = reader.readInt32() + var _3: Int32? + _3 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + if _c1 && _c2 && _c3 { + return Api.MessageMedia.messageMediaGeoLive(geo: _1!, heading: _2!, period: _3!) + } + else { + return nil + } + } } public enum PaymentSavedCredentials: TypeConstructorDescription { @@ -18093,7 +18085,7 @@ public extension Api { } public enum GeoPoint: TypeConstructorDescription { case geoPointEmpty - case geoPoint(long: Double, lat: Double, accessHash: Int64) + case geoPoint(flags: Int32, long: Double, lat: Double, accessHash: Int64, accuracyRadius: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -18103,13 +18095,15 @@ public extension Api { } break - case .geoPoint(let long, let lat, let accessHash): + case .geoPoint(let flags, let long, let lat, let accessHash, let accuracyRadius): if boxed { - buffer.appendInt32(43446532) + buffer.appendInt32(-1297942941) } + serializeInt32(flags, buffer: buffer, boxed: false) serializeDouble(long, buffer: buffer, boxed: false) serializeDouble(lat, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {serializeInt32(accuracyRadius!, buffer: buffer, boxed: false)} break } } @@ -18118,8 +18112,8 @@ public extension Api { switch self { case .geoPointEmpty: return ("geoPointEmpty", []) - case .geoPoint(let long, let lat, let accessHash): - return ("geoPoint", [("long", long), ("lat", lat), ("accessHash", accessHash)]) + case .geoPoint(let flags, let long, let lat, let accessHash, let accuracyRadius): + return ("geoPoint", [("flags", flags), ("long", long), ("lat", lat), ("accessHash", accessHash), ("accuracyRadius", accuracyRadius)]) } } @@ -18127,17 +18121,23 @@ public extension Api { return Api.GeoPoint.geoPointEmpty } public static func parse_geoPoint(_ reader: BufferReader) -> GeoPoint? { - var _1: Double? - _1 = reader.readDouble() + var _1: Int32? + _1 = reader.readInt32() var _2: Double? _2 = reader.readDouble() - var _3: Int64? - _3 = reader.readInt64() + var _3: Double? + _3 = reader.readDouble() + var _4: Int64? + _4 = reader.readInt64() + var _5: Int32? + if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt32() } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.GeoPoint.geoPoint(long: _1!, lat: _2!, accessHash: _3!) + let _c4 = _4 != nil + let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.GeoPoint.geoPoint(flags: _1!, long: _2!, lat: _3!, accessHash: _4!, accuracyRadius: _5) } else { return nil @@ -21141,6 +21141,7 @@ public extension Api { case messageActionSecureValuesSentMe(values: [Api.SecureValue], credentials: Api.SecureCredentialsEncrypted) case messageActionSecureValuesSent(types: [Api.SecureValueType]) case messageActionContactSignUp + case messageActionGeoProximityReached(fromId: Api.Peer, toId: Api.Peer, distance: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -21311,6 +21312,14 @@ public extension Api { buffer.appendInt32(-202219658) } + break + case .messageActionGeoProximityReached(let fromId, let toId, let distance): + if boxed { + buffer.appendInt32(-1730095465) + } + fromId.serialize(buffer, true) + toId.serialize(buffer, true) + serializeInt32(distance, buffer: buffer, boxed: false) break } } @@ -21363,6 +21372,8 @@ public extension Api { return ("messageActionSecureValuesSent", [("types", types)]) case .messageActionContactSignUp: return ("messageActionContactSignUp", []) + case .messageActionGeoProximityReached(let fromId, let toId, let distance): + return ("messageActionGeoProximityReached", [("fromId", fromId), ("toId", toId), ("distance", distance)]) } } @@ -21631,6 +21642,27 @@ public extension Api { public static func parse_messageActionContactSignUp(_ reader: BufferReader) -> MessageAction? { return Api.MessageAction.messageActionContactSignUp } + public static func parse_messageActionGeoProximityReached(_ reader: BufferReader) -> MessageAction? { + var _1: Api.Peer? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.Peer + } + var _2: Api.Peer? + if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.Peer + } + var _3: Int32? + _3 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + if _c1 && _c2 && _c3 { + return Api.MessageAction.messageActionGeoProximityReached(fromId: _1!, toId: _2!, distance: _3!) + } + else { + return nil + } + } } public enum PhoneCall: TypeConstructorDescription { diff --git a/submodules/TelegramApi/Sources/Api3.swift b/submodules/TelegramApi/Sources/Api3.swift index 9dd2ea0f0f..434e262188 100644 --- a/submodules/TelegramApi/Sources/Api3.swift +++ b/submodules/TelegramApi/Sources/Api3.swift @@ -2963,6 +2963,22 @@ public extension Api { }) } + public static func updatePinnedMessage(flags: Int32, peer: Api.InputPeer, id: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + let buffer = Buffer() + buffer.appendInt32(-760547348) + serializeInt32(flags, buffer: buffer, boxed: false) + peer.serialize(buffer, true) + serializeInt32(id, buffer: buffer, boxed: false) + return (FunctionDescription(name: "messages.updatePinnedMessage", parameters: [("flags", flags), ("peer", peer), ("id", id)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in + let reader = BufferReader(buffer) + var result: Api.Updates? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.Updates + } + return result + }) + } + public static func sendVote(peer: Api.InputPeer, msgId: Int32, options: [Buffer]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() buffer.appendInt32(283795844) @@ -3765,17 +3781,19 @@ public extension Api { }) } - public static func updatePinnedMessage(flags: Int32, peer: Api.InputPeer, id: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func requestProximityNotification(flags: Int32, peer: Api.InputPeer, msgId: Int32, ownLocation: Api.InputGeoPoint?, maxDistance: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-760547348) + buffer.appendInt32(-699657935) serializeInt32(flags, buffer: buffer, boxed: false) peer.serialize(buffer, true) - serializeInt32(id, buffer: buffer, boxed: false) - return (FunctionDescription(name: "messages.updatePinnedMessage", parameters: [("flags", flags), ("peer", peer), ("id", id)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in + serializeInt32(msgId, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {ownLocation!.serialize(buffer, true)} + if Int(flags) & Int(1 << 0) != 0 {serializeInt32(maxDistance!, buffer: buffer, boxed: false)} + return (FunctionDescription(name: "messages.requestProximityNotification", parameters: [("flags", flags), ("peer", peer), ("msgId", msgId), ("ownLocation", ownLocation), ("maxDistance", maxDistance)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in let reader = BufferReader(buffer) - var result: Api.Updates? + var result: Api.Bool? if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Updates + result = Api.parse(reader, signature: signature) as? Api.Bool } return result }) diff --git a/submodules/TelegramCore/BUILD b/submodules/TelegramCore/BUILD index b21c34fcc0..8d28b82d2e 100644 --- a/submodules/TelegramCore/BUILD +++ b/submodules/TelegramCore/BUILD @@ -18,7 +18,6 @@ swift_library( "//submodules/NetworkLogging:NetworkLogging", "//submodules/Reachability:Reachability", ], - alwayslink = True, visibility = [ "//visibility:public", ], diff --git a/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift b/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift index 6973182383..ef69bac4b1 100644 --- a/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift +++ b/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift @@ -1115,19 +1115,6 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo return peer } }) - case let .updateChannelPinnedMessage(channelId, id): - let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId) - updatedState.updateMessagesPinned(ids: [MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: id)], pinned: true) - - /*updatedState.updateCachedPeerData(channelPeerId, { current in - let previous: CachedChannelData - if let current = current as? CachedChannelData { - previous = current - } else { - previous = CachedChannelData() - } - return previous.withUpdatedPinnedMessageId(id == 0 ? nil : MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: id)) - })*/ case let .updatePinnedChannelMessages(flags, channelId, messages, pts, ptsCount): let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId) if let previousState = updatedState.channelStates[peerId] { @@ -1934,16 +1921,6 @@ private func pollChannel(network: Network, peer: Peer, state: AccountMutableStat } else { Logger.shared.log("State", "Invalid updateEditChannelMessage") } - case let .updateChannelPinnedMessage(_, id): - updatedState.updateCachedPeerData(peer.id, { current in - let previous: CachedChannelData - if let current = current as? CachedChannelData { - previous = current - } else { - previous = CachedChannelData() - } - return previous.withUpdatedPinnedMessageId(id == 0 ? nil : MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: id)) - }) case let .updatePinnedChannelMessages(flags, channelId, messages, _, _): let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId) updatedState.updateMessagesPinned(ids: messages.map { id in diff --git a/submodules/TelegramCore/Sources/CachedChannelData.swift b/submodules/TelegramCore/Sources/CachedChannelData.swift index bb8b4e580c..3653967727 100644 --- a/submodules/TelegramCore/Sources/CachedChannelData.swift +++ b/submodules/TelegramCore/Sources/CachedChannelData.swift @@ -8,7 +8,7 @@ extension PeerGeoLocation { init?(apiLocation: Api.ChannelLocation) { switch apiLocation { case let .channelLocation(geopoint, address): - if case let .geoPoint(longitude, latitude, _) = geopoint { + if case let .geoPoint(_, longitude, latitude, _, _) = geopoint { self.init(latitude: latitude, longitude: longitude, address: address) } else { return nil diff --git a/submodules/TelegramCore/Sources/CanSendMessagesToPeer.swift b/submodules/TelegramCore/Sources/CanSendMessagesToPeer.swift index 49fecd5af5..ed83582a3d 100644 --- a/submodules/TelegramCore/Sources/CanSendMessagesToPeer.swift +++ b/submodules/TelegramCore/Sources/CanSendMessagesToPeer.swift @@ -3,6 +3,10 @@ import Postbox import SyncCore +// Incuding at least one Objective-C class in a swift file ensures that it doesn't get stripped by the linker +private final class LinkHelperClass: NSObject { +} + public func canSendMessagesToPeer(_ peer: Peer) -> Bool { if peer is TelegramUser || peer is TelegramGroup { return !peer.isDeleted diff --git a/submodules/TelegramCore/Sources/ChannelCreation.swift b/submodules/TelegramCore/Sources/ChannelCreation.swift index 4fbe458d0d..df03fd51c9 100644 --- a/submodules/TelegramCore/Sources/ChannelCreation.swift +++ b/submodules/TelegramCore/Sources/ChannelCreation.swift @@ -25,7 +25,7 @@ private func createChannel(account: Account, title: String, description: String? var address: String? if let location = location { flags |= (1 << 2) - geoPoint = .inputGeoPoint(lat: location.latitude, long: location.longitude) + geoPoint = .inputGeoPoint(flags: 0, lat: location.latitude, long: location.longitude, accuracyRadius: nil) address = location.address } diff --git a/submodules/TelegramCore/Sources/ChatContextResult.swift b/submodules/TelegramCore/Sources/ChatContextResult.swift index ab703b262b..60ec1d7a1c 100644 --- a/submodules/TelegramCore/Sources/ChatContextResult.swift +++ b/submodules/TelegramCore/Sources/ChatContextResult.swift @@ -424,14 +424,14 @@ extension ChatContextResultMessage { } self = .text(text: message, entities: parsedEntities, disableUrlPreview: (flags & (1 << 0)) != 0, replyMarkup: parsedReplyMarkup) case let .botInlineMessageMediaGeo(_, geo, period, replyMarkup): - let media = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: period) + let media = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: period, heading: nil) var parsedReplyMarkup: ReplyMarkupMessageAttribute? if let replyMarkup = replyMarkup { parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup) } self = .mapLocation(media: media, replyMarkup: parsedReplyMarkup) case let .botInlineMessageMediaVenue(_, geo, title, address, provider, venueId, venueType, replyMarkup): - let media = telegramMediaMapFromApiGeoPoint(geo, title: title, address: address, provider: provider, venueId: venueId, venueType: venueType, liveBroadcastingTimeout: nil) + let media = telegramMediaMapFromApiGeoPoint(geo, title: title, address: address, provider: provider, venueId: venueId, venueType: venueType, liveBroadcastingTimeout: nil, heading: nil) var parsedReplyMarkup: ReplyMarkupMessageAttribute? if let replyMarkup = replyMarkup { parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup) diff --git a/submodules/TelegramCore/Sources/InstantPage.swift b/submodules/TelegramCore/Sources/InstantPage.swift index a813d9cfb0..9366e88376 100644 --- a/submodules/TelegramCore/Sources/InstantPage.swift +++ b/submodules/TelegramCore/Sources/InstantPage.swift @@ -158,7 +158,7 @@ extension InstantPageBlock { self = .relatedArticles(title: RichText(apiText: title), articles: articles.map({ InstantPageRelatedArticle(apiRelatedArticle: $0) })) case let .pageBlockMap(geo, zoom, w, h, caption): switch geo { - case let .geoPoint(long, lat, _): + case let .geoPoint(_, long, lat, _, _): self = .map(latitude: lat, longitude: long, zoom: zoom, dimensions: PixelDimensions(width: w, height: h), caption: InstantPageCaption(apiCaption: caption)) default: self = .unsupported diff --git a/submodules/TelegramCore/Sources/MD5.swift b/submodules/TelegramCore/Sources/MD5.swift index 3c64edda8e..f7d4600a7e 100644 --- a/submodules/TelegramCore/Sources/MD5.swift +++ b/submodules/TelegramCore/Sources/MD5.swift @@ -2,6 +2,10 @@ import Foundation import Postbox import CryptoUtils +// Incuding at least one Objective-C class in a swift file ensures that it doesn't get stripped by the linker +private final class LinkHelperClass: NSObject { +} + public extension MemoryBuffer { func md5Digest() -> Data { return CryptoMD5(self.memory, Int32(self.length)) diff --git a/submodules/TelegramCore/Sources/PeersNearby.swift b/submodules/TelegramCore/Sources/PeersNearby.swift index 2ab193029e..5d9954c7d7 100644 --- a/submodules/TelegramCore/Sources/PeersNearby.swift +++ b/submodules/TelegramCore/Sources/PeersNearby.swift @@ -33,10 +33,10 @@ public func updatePeersNearbyVisibility(account: Account, update: PeerNearbyVisi switch update { case let .visible(latitude, longitude): flags |= (1 << 0) - geoPoint = .inputGeoPoint(lat: latitude, long: longitude) + geoPoint = .inputGeoPoint(flags: 0, lat: latitude, long: longitude, accuracyRadius: nil) selfExpires = 0x7fffffff case let .location(latitude, longitude): - geoPoint = .inputGeoPoint(lat: latitude, long: longitude) + geoPoint = .inputGeoPoint(flags: 0, lat: latitude, long: longitude, accuracyRadius: nil) case .invisible: flags |= (1 << 0) geoPoint = .inputGeoPointEmpty @@ -87,7 +87,7 @@ public final class PeersNearbyContext { public init(network: Network, stateManager: AccountStateManager, coordinate: (latitude: Double, longitude: Double)) { let expiryExtension: Double = 10.0 - let poll = network.request(Api.functions.contacts.getLocated(flags: 0, geoPoint: .inputGeoPoint(lat: coordinate.latitude, long: coordinate.longitude), selfExpires: nil)) + let poll = network.request(Api.functions.contacts.getLocated(flags: 0, geoPoint: .inputGeoPoint(flags: 0, lat: coordinate.latitude, long: coordinate.longitude, accuracyRadius: nil), selfExpires: nil)) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) @@ -234,7 +234,7 @@ public func updateChannelGeoLocation(postbox: Postbox, network: Network, channel let geoPoint: Api.InputGeoPoint if let (latitude, longitude) = coordinate, let _ = address { - geoPoint = .inputGeoPoint(lat: latitude, long: longitude) + geoPoint = .inputGeoPoint(flags: 0, lat: latitude, long: longitude, accuracyRadius: nil) } else { geoPoint = .inputGeoPointEmpty } diff --git a/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift b/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift index 9370f00b36..ef21c53ddf 100644 --- a/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift +++ b/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift @@ -142,12 +142,16 @@ func mediaContentToUpload(network: Network, postbox: Postbox, auxiliaryMethods: return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(input, text), reuploadInfo: nil))) } else if let map = media as? TelegramMediaMap { let input: Api.InputMedia + var geoFlags: Int32 = 0 + if let _ = map.accuracyRadius { + geoFlags |= 1 << 0 + } if let liveBroadcastingTimeout = map.liveBroadcastingTimeout { - input = .inputMediaGeoLive(flags: 1 << 1, geoPoint: Api.InputGeoPoint.inputGeoPoint(lat: map.latitude, long: map.longitude), period: liveBroadcastingTimeout) + input = .inputMediaGeoLive(flags: 1 << 1, geoPoint: Api.InputGeoPoint.inputGeoPoint(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) })), heading: 0, period: liveBroadcastingTimeout) } else if let venue = map.venue { - input = .inputMediaVenue(geoPoint: Api.InputGeoPoint.inputGeoPoint(lat: map.latitude, long: map.longitude), title: venue.title, address: venue.address ?? "", provider: venue.provider ?? "", venueId: venue.id ?? "", venueType: venue.type ?? "") + input = .inputMediaVenue(geoPoint: Api.InputGeoPoint.inputGeoPoint(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) })), title: venue.title, address: venue.address ?? "", provider: venue.provider ?? "", venueId: venue.id ?? "", venueType: venue.type ?? "") } else { - input = .inputMediaGeoPoint(geoPoint: Api.InputGeoPoint.inputGeoPoint(lat: map.latitude, long: map.longitude)) + input = .inputMediaGeoPoint(geoPoint: Api.InputGeoPoint.inputGeoPoint(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) }))) } return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(input, text), reuploadInfo: nil))) } else if let poll = media as? TelegramMediaPoll { diff --git a/submodules/TelegramCore/Sources/ProcessSecretChatIncomingDecryptedOperations.swift b/submodules/TelegramCore/Sources/ProcessSecretChatIncomingDecryptedOperations.swift index 8ff17a6ce9..ebd7dbd8ee 100644 --- a/submodules/TelegramCore/Sources/ProcessSecretChatIncomingDecryptedOperations.swift +++ b/submodules/TelegramCore/Sources/ProcessSecretChatIncomingDecryptedOperations.swift @@ -794,11 +794,11 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 case let .decryptedMessageMediaWebPage(url): parsedMedia.append(TelegramMediaWebpage(webpageId: MediaId(namespace: Namespaces.Media.LocalWebpage, id: arc4random64()), content: .Pending(0, url))) case let .decryptedMessageMediaGeoPoint(lat, long): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)) case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId): parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), vCardData: nil)) case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil)) case .decryptedMessageMediaEmpty: break } @@ -1013,11 +1013,11 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 case let .decryptedMessageMediaWebPage(url): parsedMedia.append(TelegramMediaWebpage(webpageId: MediaId(namespace: Namespaces.Media.LocalWebpage, id: arc4random64()), content: .Pending(0, url))) case let .decryptedMessageMediaGeoPoint(lat, long): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)) case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId): parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), vCardData: nil)) case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil)) case .decryptedMessageMediaEmpty: break } @@ -1251,11 +1251,11 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 case let .decryptedMessageMediaWebPage(url): parsedMedia.append(TelegramMediaWebpage(webpageId: MediaId(namespace: Namespaces.Media.LocalWebpage, id: arc4random64()), content: .Pending(0, url))) case let .decryptedMessageMediaGeoPoint(lat, long): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)) case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId): parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), vCardData: nil)) case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil)) case .decryptedMessageMediaEmpty: break } diff --git a/submodules/TelegramCore/Sources/RequestChatContextResults.swift b/submodules/TelegramCore/Sources/RequestChatContextResults.swift index 2c820c7d2c..20ef3a4b63 100644 --- a/submodules/TelegramCore/Sources/RequestChatContextResults.swift +++ b/submodules/TelegramCore/Sources/RequestChatContextResults.swift @@ -116,7 +116,8 @@ public func requestChatContextResults(account: Account, botId: PeerId, peerId: P } if let (latitude, longitude) = location { flags |= (1 << 0) - geoPoint = Api.InputGeoPoint.inputGeoPoint(lat: latitude, long: longitude) + var geoPointFlags: Int32 = 0 + geoPoint = Api.InputGeoPoint.inputGeoPoint(flags: geoPointFlags, lat: latitude, long: longitude, accuracyRadius: nil) } var signal: Signal = account.network.request(Api.functions.messages.getInlineBotResults(flags: flags, bot: inputBot, peer: inputPeer, geoPoint: geoPoint, query: query, offset: offset)) diff --git a/submodules/TelegramCore/Sources/RequestEditMessage.swift b/submodules/TelegramCore/Sources/RequestEditMessage.swift index e266c1bc41..93238bc26a 100644 --- a/submodules/TelegramCore/Sources/RequestEditMessage.swift +++ b/submodules/TelegramCore/Sources/RequestEditMessage.swift @@ -252,7 +252,7 @@ private func requestEditMessageInternal(postbox: Postbox, network: Network, stat } } -public func requestEditLiveLocation(postbox: Postbox, network: Network, stateManager: AccountStateManager, messageId: MessageId, coordinate: (latitude: Double, longitude: Double)?) -> Signal { +public func requestEditLiveLocation(postbox: Postbox, network: Network, stateManager: AccountStateManager, messageId: MessageId, coordinate: (latitude: Double, longitude: Double, accuracyRadius: Int32?)?, heading: Int32?) -> Signal { return postbox.transaction { transaction -> (Api.InputPeer, TelegramMediaMap)? in guard let inputPeer = transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) else { return nil @@ -273,9 +273,13 @@ public func requestEditLiveLocation(postbox: Postbox, network: Network, stateMan } let inputMedia: Api.InputMedia if let coordinate = coordinate, let liveBroadcastingTimeout = media.liveBroadcastingTimeout { - inputMedia = .inputMediaGeoLive(flags: 1 << 1, geoPoint: .inputGeoPoint(lat: coordinate.latitude, long: coordinate.longitude), period: liveBroadcastingTimeout) + var geoFlags: Int32 = 0 + if let _ = coordinate.accuracyRadius { + geoFlags |= 1 << 0 + } + inputMedia = .inputMediaGeoLive(flags: 1 << 1, geoPoint: .inputGeoPoint(flags: geoFlags, lat: coordinate.latitude, long: coordinate.longitude, accuracyRadius: coordinate.accuracyRadius.flatMap({ Int32($0) })), heading: heading ?? 0, period: liveBroadcastingTimeout) } else { - inputMedia = .inputMediaGeoLive(flags: 1 << 0, geoPoint: .inputGeoPoint(lat: media.latitude, long: media.longitude), period: nil) + inputMedia = .inputMediaGeoLive(flags: 1 << 0, geoPoint: .inputGeoPoint(flags: 0, lat: media.latitude, long: media.longitude, accuracyRadius: nil), heading: 0, period: nil) } return network.request(Api.functions.messages.editMessage(flags: 1 << 14, peer: inputPeer, id: messageId.id, message: nil, media: inputMedia, replyMarkup: nil, entities: nil, scheduleDate: nil)) |> map(Optional.init) @@ -305,3 +309,45 @@ public func requestEditLiveLocation(postbox: Postbox, network: Network, stateMan } } +public func requestProximityNotification(postbox: Postbox, network: Network, messageId: MessageId, distance: Int32, coordinate: (latitude: Double, longitude: Double, accuracyRadius: Int32?)) -> Signal { + return postbox.transaction { transaction -> Api.InputPeer? in + return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) + } + |> mapToSignal { inputPeer -> Signal in + guard let inputPeer = inputPeer else { + return .complete() + } + let flags: Int32 = 1 << 0 + var geoFlags: Int32 = 0 + if let _ = coordinate.accuracyRadius { + geoFlags |= 1 << 0 + } + return network.request(Api.functions.messages.requestProximityNotification(flags: flags, peer: inputPeer, msgId: messageId.id, ownLocation: .inputGeoPoint(flags: geoFlags, lat: coordinate.latitude, long: coordinate.longitude, accuracyRadius: coordinate.accuracyRadius), maxDistance: distance)) + |> map(Optional.init) + |> `catch` { _ -> Signal in + return .single(nil) + } + |> mapToSignal { _ -> Signal in + return .complete() + } + } +} + +public func cancelProximityNotification(postbox: Postbox, network: Network, messageId: MessageId) -> Signal { + return postbox.transaction { transaction -> Api.InputPeer? in + return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) + } + |> mapToSignal { inputPeer -> Signal in + guard let inputPeer = inputPeer else { + return .complete() + } + return network.request(Api.functions.messages.requestProximityNotification(flags: 1 << 1, peer: inputPeer, msgId: messageId.id, ownLocation: nil, maxDistance: nil)) + |> map(Optional.init) + |> `catch` { _ -> Signal in + return .single(nil) + } + |> mapToSignal { _ -> Signal in + return .complete() + } + } +} diff --git a/submodules/TelegramCore/Sources/StoreMessage_Telegram.swift b/submodules/TelegramCore/Sources/StoreMessage_Telegram.swift index a89d719e0e..099609b9ee 100644 --- a/submodules/TelegramCore/Sources/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/Sources/StoreMessage_Telegram.swift @@ -206,6 +206,9 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: inviterId)) case let .messageActionChatMigrateTo(channelId): result.append(PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)) + case let .messageActionGeoProximityReached(fromId, toId, _): + result.append(fromId.peerId) + result.append(toId.peerId) } return result @@ -252,13 +255,13 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI let mediaContact = TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: contactPeerId, vCardData: vcard.isEmpty ? nil : vcard) return (mediaContact, nil) case let .messageMediaGeo(geo): - let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: nil) + let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: nil, heading: nil) return (mediaMap, nil) case let .messageMediaVenue(geo, title, address, provider, venueId, venueType): - let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: title, address: address, provider: provider, venueId: venueId, venueType: venueType, liveBroadcastingTimeout: nil) + let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: title, address: address, provider: provider, venueId: venueId, venueType: venueType, liveBroadcastingTimeout: nil, heading: nil) return (mediaMap, nil) - case let .messageMediaGeoLive(geo, period): - let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: period) + case let .messageMediaGeoLive(geo, heading, period): + let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: period, heading: heading) return (mediaMap, nil) case let .messageMediaDocument(_, document, ttlSeconds): if let document = document { diff --git a/submodules/TelegramCore/Sources/StringFormat.swift b/submodules/TelegramCore/Sources/StringFormat.swift index 3b58878fcd..e71bca62ab 100644 --- a/submodules/TelegramCore/Sources/StringFormat.swift +++ b/submodules/TelegramCore/Sources/StringFormat.swift @@ -1,3 +1,9 @@ +import Foundation + +// Incuding at least one Objective-C class in a swift file ensures that it doesn't get stripped by the linker +private final class LinkHelperClass: NSObject { +} + public func dataSizeString(_ size: Int, forceDecimal: Bool = false, decimalSeparator: String = ".") -> String { return dataSizeString(Int64(size), forceDecimal: forceDecimal, decimalSeparator: decimalSeparator) } diff --git a/submodules/TelegramCore/Sources/TelegramGroup.swift b/submodules/TelegramCore/Sources/TelegramGroup.swift index 8c8f512713..ab1b39589b 100644 --- a/submodules/TelegramCore/Sources/TelegramGroup.swift +++ b/submodules/TelegramCore/Sources/TelegramGroup.swift @@ -3,6 +3,10 @@ import Postbox import SyncCore +// Incuding at least one Objective-C class in a swift file ensures that it doesn't get stripped by the linker +private final class LinkHelperClass: NSObject { +} + public extension TelegramGroup { func hasBannedPermission(_ rights: TelegramChatBannedRightsFlags) -> Bool { switch self.role { diff --git a/submodules/TelegramCore/Sources/TelegramMediaAction.swift b/submodules/TelegramCore/Sources/TelegramMediaAction.swift index e16fb9002d..208401144c 100644 --- a/submodules/TelegramCore/Sources/TelegramMediaAction.swift +++ b/submodules/TelegramCore/Sources/TelegramMediaAction.swift @@ -57,6 +57,8 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe return TelegramMediaAction(action: .botSentSecureValues(types: types.map(SentSecureValueType.init))) case .messageActionContactSignUp: return TelegramMediaAction(action: .peerJoined) + case let .messageActionGeoProximityReached(fromId, toId, distance): + return TelegramMediaAction(action: .geoProximityReached(distance: distance)) } } diff --git a/submodules/TelegramCore/Sources/TelegramMediaMap.swift b/submodules/TelegramCore/Sources/TelegramMediaMap.swift index 85c13e5e35..df3b7c0648 100644 --- a/submodules/TelegramCore/Sources/TelegramMediaMap.swift +++ b/submodules/TelegramCore/Sources/TelegramMediaMap.swift @@ -4,15 +4,15 @@ import TelegramApi import SyncCore -func telegramMediaMapFromApiGeoPoint(_ geo: Api.GeoPoint, title: String?, address: String?, provider: String?, venueId: String?, venueType: String?, liveBroadcastingTimeout: Int32?) -> TelegramMediaMap { +func telegramMediaMapFromApiGeoPoint(_ geo: Api.GeoPoint, title: String?, address: String?, provider: String?, venueId: String?, venueType: String?, liveBroadcastingTimeout: Int32?, heading: Int32?) -> TelegramMediaMap { var venue: MapVenue? if let title = title { venue = MapVenue(title: title, address: address, provider: provider, id: venueId, type: venueType) } switch geo { - case let .geoPoint(long, lat, _): - return TelegramMediaMap(latitude: lat, longitude: long, geoPlace: nil, venue: venue, liveBroadcastingTimeout: liveBroadcastingTimeout) + case let .geoPoint(_, long, lat, accessHash, accuracyRadius): + return TelegramMediaMap(latitude: lat, longitude: long, heading: heading.flatMap { Double($0) }, accuracyRadius: accuracyRadius.flatMap { Double($0) }, geoPlace: nil, venue: venue, liveBroadcastingTimeout: liveBroadcastingTimeout) case .geoPointEmpty: - return TelegramMediaMap(latitude: 0.0, longitude: 0.0, geoPlace: nil, venue: venue, liveBroadcastingTimeout: liveBroadcastingTimeout) + return TelegramMediaMap(latitude: 0.0, longitude: 0.0, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: venue, liveBroadcastingTimeout: liveBroadcastingTimeout) } } diff --git a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift index c35ca10a06..4fd0f1b3f7 100644 --- a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift +++ b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift @@ -442,6 +442,8 @@ public func universalServiceMessageString(presentationData: (PresentationTheme, attributedString = addAttributesToStringWithRanges(strings.Notification_Joined(authorName), body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id)])) case .phoneNumberRequest: attributedString = nil + case .geoProximityReached: + attributedString = nil case .unknown: attributedString = nil } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 7c8237946a..314cda923e 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -1088,7 +1088,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G |> deliverOnMainQueue).start(next: { coordinate in if let strongSelf = self { if let coordinate = coordinate { - strongSelf.sendMessages([.message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaMap(latitude: coordinate.latitude, longitude: coordinate.longitude, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)), replyToMessageId: nil, localGroupingKey: nil)]) + strongSelf.sendMessages([.message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaMap(latitude: coordinate.latitude, longitude: coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)), replyToMessageId: nil, localGroupingKey: nil)]) } else { strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: {})]), in: .window(.root)) } @@ -3268,20 +3268,25 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G case .Loading: break case let .HistoryView(view, _, _, _, _, _, _): + let topMessageId: MessageId + if view.entries.isEmpty { + return nil + } + topMessageId = view.entries[view.entries.count - 1].message.id for i in 0 ..< view.entries.count { let entry = view.entries[i] var matches = false if message == nil { matches = true } else if let topVisibleMessageRange = topVisibleMessageRange { - if entry.message.id < topVisibleMessageRange.upperBound { + if entry.message.id <= topVisibleMessageRange.upperBound { matches = true } } else { matches = true } if matches { - message = ChatPinnedMessage(message: entry.message, isLatest: i == view.entries.count - 1) + message = ChatPinnedMessage(message: entry.message, topMessageId: topMessageId) } } break @@ -3352,7 +3357,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let pinnedMessageId = pinnedMessageId { if let cachedDataMessages = combinedInitialData.cachedDataMessages { if let message = cachedDataMessages[pinnedMessageId] { - pinnedMessage = ChatPinnedMessage(message: message, isLatest: true) + pinnedMessage = ChatPinnedMessage(message: message, topMessageId: message.id) } } } @@ -3504,7 +3509,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } if let pinnedMessageId = pinnedMessageId { if let message = messages?[pinnedMessageId] { - pinnedMessage = ChatPinnedMessage(message: message, isLatest: true) + pinnedMessage = ChatPinnedMessage(message: message, topMessageId: message.id) } } case let .peer(peerId): @@ -3514,7 +3519,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } else { if let pinnedMessageId = pinnedMessageId { if let message = messages?[pinnedMessageId] { - pinnedMessage = ChatPinnedMessage(message: message, isLatest: true) + pinnedMessage = ChatPinnedMessage(message: message, topMessageId: message.id) } } } @@ -4864,11 +4869,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }) } } else { - if let pinnedMessageId = strongSelf.presentationInterfaceState.pinnedMessage?.message.id { + if let topPinnedMessageId = strongSelf.presentationInterfaceState.pinnedMessage?.topMessageId { strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { return $0.updatedInterfaceState({ $0.withUpdatedMessageActionsState({ value in var value = value - value.closedPinnedMessageId = pinnedMessageId + value.closedPinnedMessageId = topPinnedMessageId return value }) }) @@ -4916,7 +4921,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { return $0.updatedInterfaceState({ $0.withUpdatedMessageActionsState({ value in var value = value - value.closedPinnedMessageId = pinnedMessage.message.id + value.closedPinnedMessageId = pinnedMessage.topMessageId return value }) }) }) diff --git a/submodules/TelegramUI/Sources/ChatInterfaceTitlePanelNodes.swift b/submodules/TelegramUI/Sources/ChatInterfaceTitlePanelNodes.swift index 9b40aa2467..f959c009cc 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceTitlePanelNodes.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceTitlePanelNodes.swift @@ -19,7 +19,7 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat loop: for context in chatPresentationInterfaceState.titlePanelContexts.reversed() { switch context { case .pinnedMessage: - if let pinnedMessage = chatPresentationInterfaceState.pinnedMessage, pinnedMessage.message.id != chatPresentationInterfaceState.interfaceState.messageActionsState.closedPinnedMessageId { + if let pinnedMessage = chatPresentationInterfaceState.pinnedMessage, pinnedMessage.topMessageId != chatPresentationInterfaceState.interfaceState.messageActionsState.closedPinnedMessageId { selectedContext = context break loop } diff --git a/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift b/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift index 1d2af3438c..62597c088f 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift @@ -281,10 +281,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { var consumableContentIcon: UIImage? for attribute in message.attributes { if let attribute = attribute as? ConsumableContentMessageAttribute { - var isConsumed = attribute.consumed - if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = channel.info { - isConsumed = true - } + let isConsumed = attribute.consumed if !isConsumed { if incoming { consumableContentIcon = PresentationResourcesChat.chatBubbleConsumableContentIncomingIcon(presentationData.theme.theme) diff --git a/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift b/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift index 37c731f0df..fde33abda8 100644 --- a/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift @@ -241,7 +241,7 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode { var imageDimensions: CGSize? var titleString: String - if pinnedMessage.isLatest { + if pinnedMessage.topMessageId == pinnedMessage.message.id { titleString = strings.Conversation_PinnedMessage } else { titleString = strings.Conversation_PinnedPreviousMessage diff --git a/submodules/TelegramUI/Sources/ChatPresentationInterfaceState.swift b/submodules/TelegramUI/Sources/ChatPresentationInterfaceState.swift index 54f76b2d61..491f9138cb 100644 --- a/submodules/TelegramUI/Sources/ChatPresentationInterfaceState.swift +++ b/submodules/TelegramUI/Sources/ChatPresentationInterfaceState.swift @@ -259,11 +259,11 @@ struct ChatSlowmodeState: Equatable { final class ChatPinnedMessage: Equatable { let message: Message - let isLatest: Bool + let topMessageId: MessageId - init(message: Message, isLatest: Bool) { + init(message: Message, topMessageId: MessageId) { self.message = message - self.isLatest = isLatest + self.topMessageId = topMessageId } static func ==(lhs: ChatPinnedMessage, rhs: ChatPinnedMessage) -> Bool { @@ -276,7 +276,7 @@ final class ChatPinnedMessage: Equatable { if lhs.message.stableVersion != rhs.message.stableVersion { return false } - if lhs.isLatest != rhs.isLatest { + if lhs.topMessageId != rhs.topMessageId { return false } return true diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift index 0dd763ed33..6249c33961 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift @@ -1037,7 +1037,7 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { return [] }, to: &text, entities: &entities) - let mediaMap = TelegramMediaMap(latitude: updated.latitude, longitude: updated.longitude, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil) + let mediaMap = TelegramMediaMap(latitude: updated.latitude, longitude: updated.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil) let message = Message(stableId: self.entry.stableId, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: Int32(bitPattern: self.entry.stableId)), globallyUniqueId: self.entry.event.id, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: self.entry.event.date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: author, text: text, attributes: [], media: [mediaMap], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: []) return ChatMessageItem(presentationData: self.presentationData, context: context, chatLocation: .peer(peer.id), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .channel, automaticDownloadNetworkType: .cellular, isRecentActions: true), controllerInteraction: controllerInteraction, content: .message(message: message, read: true, selection: .none, attributes: ChatMessageEntryAttributes())) diff --git a/submodules/TelegramUI/Sources/OpenChatMessage.swift b/submodules/TelegramUI/Sources/OpenChatMessage.swift index f4ac6a8238..cdc17aed8c 100644 --- a/submodules/TelegramUI/Sources/OpenChatMessage.swift +++ b/submodules/TelegramUI/Sources/OpenChatMessage.swift @@ -82,7 +82,7 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool { let controller = legacyLocationController(message: params.message, mapMedia: mapMedia, context: params.context, openPeer: { peer in params.openPeer(peer, .info) }, sendLiveLocation: { coordinate, period in - let outMessage: EnqueueMessage = .message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaMap(latitude: coordinate.latitude, longitude: coordinate.longitude, geoPlace: nil, venue: nil, liveBroadcastingTimeout: period)), replyToMessageId: nil, localGroupingKey: nil) + let outMessage: EnqueueMessage = .message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaMap(latitude: coordinate.latitude, longitude: coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: period)), replyToMessageId: nil, localGroupingKey: nil) params.enqueueMessage(outMessage) }, stopLiveLocation: { params.context.liveLocationManager?.cancelLiveLocation(peerId: params.message.id.peerId) diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 6b0d5bff27..2fe33c23dd 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -3641,7 +3641,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD } let context = self.context let presentationData = self.presentationData - let mapMedia = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, geoPlace: nil, venue: MapVenue(title: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), address: location.address, provider: nil, id: nil, type: nil), liveBroadcastingTimeout: nil) + let mapMedia = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), address: location.address, provider: nil, id: nil, type: nil), liveBroadcastingTimeout: nil) let locationController = legacyLocationController(message: nil, mapMedia: mapMedia, context: context, openPeer: { _ in }, sendLiveLocation: { _, _ in }, stopLiveLocation: {}, openUrl: { url in context.sharedContext.applicationBindings.openUrl(url) }) diff --git a/submodules/WatchBridge/Sources/WatchRequestHandlers.swift b/submodules/WatchBridge/Sources/WatchRequestHandlers.swift index be82c9c4e2..14518597f2 100644 --- a/submodules/WatchBridge/Sources/WatchRequestHandlers.swift +++ b/submodules/WatchBridge/Sources/WatchRequestHandlers.swift @@ -203,7 +203,7 @@ final class WatchSendMessageHandler: WatchRequestHandler { messageSignal = .single((.message(text: args.text, attributes: [], mediaReference: nil, replyToMessageId: replyMessageId, localGroupingKey: nil), peerId)) } else if let args = subscription as? TGBridgeSendLocationMessageSubscription, let location = args.location { let peerId = makePeerIdFromBridgeIdentifier(args.peerId) - let map = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, geoPlace: nil, venue: makeVenue(from: location.venue), liveBroadcastingTimeout: nil) + let map = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: makeVenue(from: location.venue), liveBroadcastingTimeout: nil) messageSignal = .single((.message(text: "", attributes: [], mediaReference: .standalone(media: map), replyToMessageId: nil, localGroupingKey: nil), peerId)) } else if let args = subscription as? TGBridgeSendStickerMessageSubscription { let peerId = makePeerIdFromBridgeIdentifier(args.peerId)