mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Update API
This commit is contained in:
parent
5cf50d8602
commit
55a7ee118d
@ -520,6 +520,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[340088945] = { return Api.MediaArea.parse_mediaAreaSuggestedReaction($0) }
|
dict[340088945] = { return Api.MediaArea.parse_mediaAreaSuggestedReaction($0) }
|
||||||
dict[926421125] = { return Api.MediaArea.parse_mediaAreaUrl($0) }
|
dict[926421125] = { return Api.MediaArea.parse_mediaAreaUrl($0) }
|
||||||
dict[-1098720356] = { return Api.MediaArea.parse_mediaAreaVenue($0) }
|
dict[-1098720356] = { return Api.MediaArea.parse_mediaAreaVenue($0) }
|
||||||
|
dict[1132918857] = { return Api.MediaArea.parse_mediaAreaWeather($0) }
|
||||||
dict[-808853502] = { return Api.MediaAreaCoordinates.parse_mediaAreaCoordinates($0) }
|
dict[-808853502] = { return Api.MediaAreaCoordinates.parse_mediaAreaCoordinates($0) }
|
||||||
dict[-1808510398] = { return Api.Message.parse_message($0) }
|
dict[-1808510398] = { return Api.Message.parse_message($0) }
|
||||||
dict[-1868117372] = { return Api.Message.parse_messageEmpty($0) }
|
dict[-1868117372] = { return Api.Message.parse_messageEmpty($0) }
|
||||||
|
@ -231,6 +231,7 @@ public extension Api {
|
|||||||
case mediaAreaSuggestedReaction(flags: Int32, coordinates: Api.MediaAreaCoordinates, reaction: Api.Reaction)
|
case mediaAreaSuggestedReaction(flags: Int32, coordinates: Api.MediaAreaCoordinates, reaction: Api.Reaction)
|
||||||
case mediaAreaUrl(coordinates: Api.MediaAreaCoordinates, url: String)
|
case mediaAreaUrl(coordinates: Api.MediaAreaCoordinates, url: String)
|
||||||
case mediaAreaVenue(coordinates: Api.MediaAreaCoordinates, geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String)
|
case mediaAreaVenue(coordinates: Api.MediaAreaCoordinates, geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String)
|
||||||
|
case mediaAreaWeather(flags: Int32, coordinates: Api.MediaAreaCoordinates, emoji: String, temperatureC: Double)
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
@ -294,6 +295,15 @@ public extension Api {
|
|||||||
serializeString(venueId, buffer: buffer, boxed: false)
|
serializeString(venueId, buffer: buffer, boxed: false)
|
||||||
serializeString(venueType, buffer: buffer, boxed: false)
|
serializeString(venueType, buffer: buffer, boxed: false)
|
||||||
break
|
break
|
||||||
|
case .mediaAreaWeather(let flags, let coordinates, let emoji, let temperatureC):
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(1132918857)
|
||||||
|
}
|
||||||
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
|
coordinates.serialize(buffer, true)
|
||||||
|
serializeString(emoji, buffer: buffer, boxed: false)
|
||||||
|
serializeDouble(temperatureC, buffer: buffer, boxed: false)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,6 +323,8 @@ public extension Api {
|
|||||||
return ("mediaAreaUrl", [("coordinates", coordinates as Any), ("url", url as Any)])
|
return ("mediaAreaUrl", [("coordinates", coordinates as Any), ("url", url as Any)])
|
||||||
case .mediaAreaVenue(let coordinates, let geo, let title, let address, let provider, let venueId, let venueType):
|
case .mediaAreaVenue(let coordinates, let geo, let title, let address, let provider, let venueId, let venueType):
|
||||||
return ("mediaAreaVenue", [("coordinates", coordinates as Any), ("geo", geo as Any), ("title", title as Any), ("address", address as Any), ("provider", provider as Any), ("venueId", venueId as Any), ("venueType", venueType as Any)])
|
return ("mediaAreaVenue", [("coordinates", coordinates as Any), ("geo", geo as Any), ("title", title as Any), ("address", address as Any), ("provider", provider as Any), ("venueId", venueId as Any), ("venueType", venueType as Any)])
|
||||||
|
case .mediaAreaWeather(let flags, let coordinates, let emoji, let temperatureC):
|
||||||
|
return ("mediaAreaWeather", [("flags", flags as Any), ("coordinates", coordinates as Any), ("emoji", emoji as Any), ("temperatureC", temperatureC as Any)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,6 +483,28 @@ public extension Api {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static func parse_mediaAreaWeather(_ reader: BufferReader) -> MediaArea? {
|
||||||
|
var _1: Int32?
|
||||||
|
_1 = reader.readInt32()
|
||||||
|
var _2: Api.MediaAreaCoordinates?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
_2 = Api.parse(reader, signature: signature) as? Api.MediaAreaCoordinates
|
||||||
|
}
|
||||||
|
var _3: String?
|
||||||
|
_3 = parseString(reader)
|
||||||
|
var _4: Double?
|
||||||
|
_4 = reader.readDouble()
|
||||||
|
let _c1 = _1 != nil
|
||||||
|
let _c2 = _2 != nil
|
||||||
|
let _c3 = _3 != nil
|
||||||
|
let _c4 = _4 != nil
|
||||||
|
if _c1 && _c2 && _c3 && _c4 {
|
||||||
|
return Api.MediaArea.mediaAreaWeather(flags: _1!, coordinates: _2!, emoji: _3!, temperatureC: _4!)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -522,6 +522,12 @@ func mediaAreaFromApiMediaArea(_ mediaArea: Api.MediaArea) -> MediaArea? {
|
|||||||
return .link(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), url: url)
|
return .link(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), url: url)
|
||||||
case let .mediaAreaChannelPost(coordinates, channelId, messageId):
|
case let .mediaAreaChannelPost(coordinates, channelId, messageId):
|
||||||
return .channelMessage(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), messageId: EngineMessage.Id(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: messageId))
|
return .channelMessage(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), messageId: EngineMessage.Id(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: messageId))
|
||||||
|
case let .mediaAreaWeather(flags, coordinates, emoji, temperatureC):
|
||||||
|
var parsedFlags = MediaArea.WeatherFlags()
|
||||||
|
if (flags & (1 << 0)) != 0 {
|
||||||
|
parsedFlags.insert(.isDark)
|
||||||
|
}
|
||||||
|
return .weather(coordinates: coodinatesFromApiMediaAreaCoordinates(coordinates), emoji: emoji, temperature: temperatureC, flags: parsedFlags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,6 +580,12 @@ func apiMediaAreasFromMediaAreas(_ mediaAreas: [MediaArea], transaction: Transac
|
|||||||
}
|
}
|
||||||
case let .link(_, url):
|
case let .link(_, url):
|
||||||
apiMediaAreas.append(.mediaAreaUrl(coordinates: inputCoordinates, url: url))
|
apiMediaAreas.append(.mediaAreaUrl(coordinates: inputCoordinates, url: url))
|
||||||
|
case let .weather(_, emoji, temperature, flags):
|
||||||
|
var apiFlags: Int32 = 0
|
||||||
|
if flags.contains(.isDark) {
|
||||||
|
apiFlags |= (1 << 0)
|
||||||
|
}
|
||||||
|
apiMediaAreas.append(.mediaAreaWeather(flags: apiFlags, coordinates: inputCoordinates, emoji: emoji, temperatureC: temperature))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return apiMediaAreas
|
return apiMediaAreas
|
||||||
|
@ -7,6 +7,7 @@ public enum MediaArea: Codable, Equatable {
|
|||||||
case coordinates
|
case coordinates
|
||||||
case value
|
case value
|
||||||
case flags
|
case flags
|
||||||
|
case temperature
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct Coordinates: Codable, Equatable {
|
public struct Coordinates: Codable, Equatable {
|
||||||
@ -149,6 +150,7 @@ public enum MediaArea: Codable, Equatable {
|
|||||||
case reaction(coordinates: Coordinates, reaction: MessageReaction.Reaction, flags: ReactionFlags)
|
case reaction(coordinates: Coordinates, reaction: MessageReaction.Reaction, flags: ReactionFlags)
|
||||||
case channelMessage(coordinates: Coordinates, messageId: EngineMessage.Id)
|
case channelMessage(coordinates: Coordinates, messageId: EngineMessage.Id)
|
||||||
case link(coordinates: Coordinates, url: String)
|
case link(coordinates: Coordinates, url: String)
|
||||||
|
case weather(coordinates: Coordinates, emoji: String, temperature: Double, flags: WeatherFlags)
|
||||||
|
|
||||||
public struct ReactionFlags: OptionSet {
|
public struct ReactionFlags: OptionSet {
|
||||||
public var rawValue: Int32
|
public var rawValue: Int32
|
||||||
@ -165,12 +167,27 @@ public enum MediaArea: Codable, Equatable {
|
|||||||
public static let isFlipped = ReactionFlags(rawValue: 1 << 1)
|
public static let isFlipped = ReactionFlags(rawValue: 1 << 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public struct WeatherFlags: OptionSet {
|
||||||
|
public var rawValue: Int32
|
||||||
|
|
||||||
|
public init(rawValue: Int32) {
|
||||||
|
self.rawValue = rawValue
|
||||||
|
}
|
||||||
|
|
||||||
|
public init() {
|
||||||
|
self.rawValue = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
public static let isDark = WeatherFlags(rawValue: 1 << 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private enum MediaAreaType: Int32 {
|
private enum MediaAreaType: Int32 {
|
||||||
case venue
|
case venue
|
||||||
case reaction
|
case reaction
|
||||||
case channelMessage
|
case channelMessage
|
||||||
case link
|
case link
|
||||||
|
case weather
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DecodingError: Error {
|
public enum DecodingError: Error {
|
||||||
@ -201,6 +218,12 @@ public enum MediaArea: Codable, Equatable {
|
|||||||
let coordinates = try container.decode(MediaArea.Coordinates.self, forKey: .coordinates)
|
let coordinates = try container.decode(MediaArea.Coordinates.self, forKey: .coordinates)
|
||||||
let url = try container.decode(String.self, forKey: .value)
|
let url = try container.decode(String.self, forKey: .value)
|
||||||
self = .link(coordinates: coordinates, url: url)
|
self = .link(coordinates: coordinates, url: url)
|
||||||
|
case .weather:
|
||||||
|
let coordinates = try container.decode(MediaArea.Coordinates.self, forKey: .coordinates)
|
||||||
|
let emoji = try container.decode(String.self, forKey: .value)
|
||||||
|
let temperature = try container.decode(Double.self, forKey: .temperature)
|
||||||
|
let flags = WeatherFlags(rawValue: try container.decodeIfPresent(Int32.self, forKey: .flags) ?? 0)
|
||||||
|
self = .weather(coordinates: coordinates, emoji: emoji, temperature: temperature, flags: flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,6 +248,12 @@ public enum MediaArea: Codable, Equatable {
|
|||||||
try container.encode(MediaAreaType.link.rawValue, forKey: .type)
|
try container.encode(MediaAreaType.link.rawValue, forKey: .type)
|
||||||
try container.encode(coordinates, forKey: .coordinates)
|
try container.encode(coordinates, forKey: .coordinates)
|
||||||
try container.encode(url, forKey: .value)
|
try container.encode(url, forKey: .value)
|
||||||
|
case let .weather(coordinates, emoji, temperature, flags):
|
||||||
|
try container.encode(MediaAreaType.link.rawValue, forKey: .type)
|
||||||
|
try container.encode(coordinates, forKey: .coordinates)
|
||||||
|
try container.encode(emoji, forKey: .value)
|
||||||
|
try container.encode(temperature, forKey: .temperature)
|
||||||
|
try container.encode(flags.rawValue, forKey: .flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,6 +269,8 @@ public extension MediaArea {
|
|||||||
return coordinates
|
return coordinates
|
||||||
case let .link(coordinates, _):
|
case let .link(coordinates, _):
|
||||||
return coordinates
|
return coordinates
|
||||||
|
case let .weather(coordinates, _, _, _):
|
||||||
|
return coordinates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3434,6 +3434,8 @@ final class StoryItemSetContainerSendMessage {
|
|||||||
actions.append(ContextMenuAction(content: .textWithSubtitleAndIcon(title: updatedPresentationData.initial.strings.Story_ViewLink, subtitle: url, icon: generateTintedImage(image: UIImage(bundleImageName: "Settings/TextArrowRight"), color: .white)), action: {
|
actions.append(ContextMenuAction(content: .textWithSubtitleAndIcon(title: updatedPresentationData.initial.strings.Story_ViewLink, subtitle: url, icon: generateTintedImage(image: UIImage(bundleImageName: "Settings/TextArrowRight"), color: .white)), action: {
|
||||||
action()
|
action()
|
||||||
}))
|
}))
|
||||||
|
case .weather:
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
self.selectedMediaArea = mediaArea
|
self.selectedMediaArea = mediaArea
|
||||||
|
Loading…
x
Reference in New Issue
Block a user