mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
[WIP] Stories
This commit is contained in:
parent
39963f3a6c
commit
00b62b3e58
@ -244,7 +244,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
|
||||
private var powerSavingMonitoringDisposable: Disposable?
|
||||
|
||||
public private(set) var storyListContext: StoryListContext?
|
||||
private var storySubscriptions: EngineStorySubscriptions?
|
||||
|
||||
private var storySubscriptionsDisposable: Disposable?
|
||||
@ -2543,204 +2542,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
)
|
||||
self.push(storyContainerScreen)
|
||||
})
|
||||
|
||||
/*let storyFocusContext = self.context.engine.messages.peerStoryFocusContext(id: peer.id, focusItemId: nil)
|
||||
|
||||
let _ = (storyFocusContext.state
|
||||
|> filter { state -> Bool in
|
||||
if state.isLoading {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] state in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
let _ = storyFocusContext
|
||||
let _ = self
|
||||
|
||||
if let item = state.item {
|
||||
let _ = item
|
||||
|
||||
let _ = (StoryChatContent.subscriptionsStories(
|
||||
context: self.context,
|
||||
peerId: peer.id
|
||||
)
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] initialContent in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
|
||||
var transitionIn: StoryContainerScreen.TransitionIn?
|
||||
if let componentView = self.headerContentView.view as? ChatListHeaderComponent.View {
|
||||
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: peer.id) {
|
||||
transitionIn = StoryContainerScreen.TransitionIn(
|
||||
sourceView: transitionView,
|
||||
sourceRect: transitionView.bounds,
|
||||
sourceCornerRadius: transitionView.bounds.height * 0.5
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var cameraTransitionIn: StoryCameraTransitionIn?
|
||||
if let componentView = self.headerContentView.view as? ChatListHeaderComponent.View {
|
||||
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
|
||||
cameraTransitionIn = StoryCameraTransitionIn(
|
||||
sourceView: transitionView,
|
||||
sourceRect: transitionView.bounds,
|
||||
sourceCornerRadius: transitionView.bounds.height * 0.5
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var initialFocusedId: AnyHashable?
|
||||
//if let peer {
|
||||
initialFocusedId = AnyHashable(peer.id)
|
||||
//}
|
||||
|
||||
if initialFocusedId == AnyHashable(self.context.account.peerId), let firstItem = initialContent.first, firstItem.id == initialFocusedId && firstItem.items.isEmpty {
|
||||
if let rootController = self.context.sharedContext.mainWindow?.viewController as? TelegramRootControllerInterface {
|
||||
rootController.openStoryCamera(transitionIn: cameraTransitionIn, transitionOut: { [weak self] _ in
|
||||
guard let self else {
|
||||
return nil
|
||||
}
|
||||
if let componentView = self.headerContentView.view as? ChatListHeaderComponent.View {
|
||||
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
|
||||
return StoryCameraTransitionOut(
|
||||
destinationView: transitionView,
|
||||
destinationRect: transitionView.bounds,
|
||||
destinationCornerRadius: transitionView.bounds.height * 0.5
|
||||
)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let storyContainerScreen = StoryContainerScreen(
|
||||
context: self.context,
|
||||
initialFocusedId: initialFocusedId,
|
||||
initialContent: initialContent,
|
||||
transitionIn: transitionIn,
|
||||
transitionOut: { [weak self] peerId, _ in
|
||||
guard let self else {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let componentView = self.headerContentView.view as? ChatListHeaderComponent.View {
|
||||
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: peerId) {
|
||||
return StoryContainerScreen.TransitionOut(
|
||||
destinationView: transitionView,
|
||||
destinationRect: transitionView.bounds,
|
||||
destinationCornerRadius: transitionView.bounds.height * 0.5,
|
||||
destinationIsAvatar: true,
|
||||
completed: {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
)
|
||||
self.push(storyContainerScreen)
|
||||
})
|
||||
}
|
||||
})*/
|
||||
|
||||
/*let _ = (StoryChatContent.stories(
|
||||
context: self.context,
|
||||
storyList: storyListContext,
|
||||
focusItem: nil
|
||||
)
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] initialContent in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
|
||||
var transitionIn: StoryContainerScreen.TransitionIn?
|
||||
if let peer, let componentView = self.headerContentView.view as? ChatListHeaderComponent.View {
|
||||
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: peer.id) {
|
||||
transitionIn = StoryContainerScreen.TransitionIn(
|
||||
sourceView: transitionView,
|
||||
sourceRect: transitionView.bounds,
|
||||
sourceCornerRadius: transitionView.bounds.height * 0.5
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var cameraTransitionIn: StoryCameraTransitionIn?
|
||||
if let componentView = self.headerContentView.view as? ChatListHeaderComponent.View {
|
||||
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
|
||||
cameraTransitionIn = StoryCameraTransitionIn(
|
||||
sourceView: transitionView,
|
||||
sourceRect: transitionView.bounds,
|
||||
sourceCornerRadius: transitionView.bounds.height * 0.5
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var initialFocusedId: AnyHashable?
|
||||
if let peer {
|
||||
initialFocusedId = AnyHashable(peer.id)
|
||||
}
|
||||
|
||||
if initialFocusedId == AnyHashable(self.context.account.peerId), let firstItem = initialContent.first, firstItem.id == initialFocusedId && firstItem.items.isEmpty {
|
||||
if let rootController = self.context.sharedContext.mainWindow?.viewController as? TelegramRootControllerInterface {
|
||||
rootController.openStoryCamera(transitionIn: cameraTransitionIn, transitionOut: { [weak self] _ in
|
||||
guard let self else {
|
||||
return nil
|
||||
}
|
||||
if let componentView = self.headerContentView.view as? ChatListHeaderComponent.View {
|
||||
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
|
||||
return StoryCameraTransitionOut(
|
||||
destinationView: transitionView,
|
||||
destinationRect: transitionView.bounds,
|
||||
destinationCornerRadius: transitionView.bounds.height * 0.5
|
||||
)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let storyContainerScreen = StoryContainerScreen(
|
||||
context: self.context,
|
||||
initialFocusedId: initialFocusedId,
|
||||
initialContent: initialContent,
|
||||
transitionIn: transitionIn,
|
||||
transitionOut: { [weak self] peerId, _ in
|
||||
guard let self else {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let componentView = self.headerContentView.view as? ChatListHeaderComponent.View {
|
||||
if let transitionView = componentView.storyPeerListView()?.transitionViewForItem(peerId: peerId) {
|
||||
return StoryContainerScreen.TransitionOut(
|
||||
destinationView: transitionView,
|
||||
destinationRect: transitionView.bounds,
|
||||
destinationCornerRadius: transitionView.bounds.height * 0.5,
|
||||
destinationIsAvatar: true,
|
||||
completed: {}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
)
|
||||
self.push(storyContainerScreen)
|
||||
})*/
|
||||
}
|
||||
|
||||
let fraction = 94.0 / (navigationBarSearchContentHeight + 94.0)
|
||||
|
@ -351,11 +351,11 @@ public final class DirectMediaImageCache {
|
||||
return self.getProgressiveSize(mediaReference: MediaReference.message(message: MessageReference(message), media: file).abstract, width: width, representations: file.previewRepresentations)
|
||||
}
|
||||
|
||||
private func getResource(peer: PeerReference, story: StoryListContext.Item, image: TelegramMediaImage, width: Int) -> (resource: MediaResourceReference, size: Int64)? {
|
||||
private func getResource(peer: PeerReference, story: EngineStoryItem, image: TelegramMediaImage, width: Int) -> (resource: MediaResourceReference, size: Int64)? {
|
||||
return self.getProgressiveSize(mediaReference: MediaReference.story(peer: peer, id: story.id, media: image).abstract, width: width, representations: image.representations)
|
||||
}
|
||||
|
||||
private func getResource(peer: PeerReference, story: StoryListContext.Item, file: TelegramMediaFile, width: Int) -> (resource: MediaResourceReference, size: Int64)? {
|
||||
private func getResource(peer: PeerReference, story: EngineStoryItem, file: TelegramMediaFile, width: Int) -> (resource: MediaResourceReference, size: Int64)? {
|
||||
return self.getProgressiveSize(mediaReference: MediaReference.story(peer: peer, id: story.id, media: file).abstract, width: width, representations: file.previewRepresentations)
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ public final class DirectMediaImageCache {
|
||||
}
|
||||
}
|
||||
|
||||
private func getImageSynchronous(peer: PeerReference, story: StoryListContext.Item, userLocation: MediaResourceUserLocation, media: Media, width: Int, aspectRatio: CGFloat, possibleWidths: [Int], includeBlurred: Bool) -> GetMediaResult? {
|
||||
private func getImageSynchronous(peer: PeerReference, story: EngineStoryItem, userLocation: MediaResourceUserLocation, media: Media, width: Int, aspectRatio: CGFloat, possibleWidths: [Int], includeBlurred: Bool) -> GetMediaResult? {
|
||||
var immediateThumbnailData: Data?
|
||||
var resource: (resource: MediaResourceReference, size: Int64)?
|
||||
if let image = media as? TelegramMediaImage {
|
||||
@ -492,7 +492,7 @@ public final class DirectMediaImageCache {
|
||||
return GetMediaResult(image: resultImage, blurredImage: blurredImage, loadSignal: self.getLoadSignal(width: width, aspectRatio: aspectRatio, userLocation: userLocation, userContentType: .image, resource: resource.resource, resourceSizeLimit: resource.size))
|
||||
}
|
||||
|
||||
public func getImage(peer: PeerReference, story: StoryListContext.Item, media: Media, width: Int, aspectRatio: CGFloat, possibleWidths: [Int], includeBlurred: Bool = false, synchronous: Bool) -> GetMediaResult? {
|
||||
public func getImage(peer: PeerReference, story: EngineStoryItem, media: Media, width: Int, aspectRatio: CGFloat, possibleWidths: [Int], includeBlurred: Bool = false, synchronous: Bool) -> GetMediaResult? {
|
||||
if synchronous {
|
||||
return self.getImageSynchronous(peer: peer, story: story, userLocation: .peer(peer.id), media: media, width: width, aspectRatio: aspectRatio, possibleWidths: possibleWidths, includeBlurred: includeBlurred)
|
||||
} else {
|
||||
|
@ -15,11 +15,12 @@
|
||||
if (self != nil) {
|
||||
void *avIoBuffer = av_malloc(bufferSize);
|
||||
_impl = avio_alloc_context(avIoBuffer, bufferSize, 0, opaqueContext, readPacket, writePacket, seek);
|
||||
_impl->direct = 1;
|
||||
if (_impl == nil) {
|
||||
av_free(avIoBuffer);
|
||||
return nil;
|
||||
}
|
||||
_impl->direct = 1;
|
||||
_impl->seekable = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -95,6 +95,9 @@ private func readPacketCallback(userData: UnsafeMutableRawPointer?, buffer: Unsa
|
||||
if readCount == 0 {
|
||||
fetchedData = Data()
|
||||
} else {
|
||||
#if DEBUG
|
||||
print("requestRange: \(requestRange)")
|
||||
#endif
|
||||
if let tempFilePath = context.tempFilePath, let fileData = (try? Data(contentsOf: URL(fileURLWithPath: tempFilePath), options: .mappedRead))?.subdata(in: Int(requestRange.lowerBound) ..< Int(requestRange.upperBound)) {
|
||||
fetchedData = fileData
|
||||
} else {
|
||||
|
@ -85,7 +85,7 @@ public enum MediaPlayerStreaming {
|
||||
case .earlierStart:
|
||||
return (1.0, 1.0, 2.0)
|
||||
case .story:
|
||||
return (0.25, 0.5, 2.0)
|
||||
return (0.25, 0.5, 0.5)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,13 @@ public enum MediaTrackFrameResult {
|
||||
case finished
|
||||
}
|
||||
|
||||
private let traceEvents = false
|
||||
private let traceEvents: Bool = {
|
||||
#if DEBUG
|
||||
return true
|
||||
#else
|
||||
return false
|
||||
#endif
|
||||
}()
|
||||
|
||||
public final class MediaTrackFrameBuffer {
|
||||
private let stallDuration: Double
|
||||
@ -89,7 +95,7 @@ public final class MediaTrackFrameBuffer {
|
||||
|
||||
if let maxUntilTime = maxUntilTime {
|
||||
if traceEvents {
|
||||
print("added \(frames.count) frames until \(CMTimeGetSeconds(maxUntilTime)), \(self.frames.count) total")
|
||||
print("\(self.type) added \(frames.count) frames until \(CMTimeGetSeconds(maxUntilTime)), \(self.frames.count) total")
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +129,7 @@ public final class MediaTrackFrameBuffer {
|
||||
|
||||
if bufferedDuration < self.lowWaterDuration {
|
||||
if traceEvents {
|
||||
print("buffered duration: \(bufferedDuration), requesting until \(timestamp) + \(self.highWaterDuration - bufferedDuration)")
|
||||
print("\(self.type) buffered duration: \(bufferedDuration), requesting until \(timestamp) + \(self.highWaterDuration - bufferedDuration)")
|
||||
}
|
||||
let delayIncrement = 0.3
|
||||
var generateUntil = timestamp + delayIncrement
|
||||
@ -134,7 +140,7 @@ public final class MediaTrackFrameBuffer {
|
||||
|
||||
if bufferedDuration > self.stallDuration && !self.isWaitingForLowWaterDuration {
|
||||
if traceEvents {
|
||||
print("buffered1 duration: \(bufferedDuration), wait until \(timestamp) + \(self.highWaterDuration - bufferedDuration)")
|
||||
print("\(self.type) buffered1 duration: \(bufferedDuration), wait until \(timestamp) + \(self.highWaterDuration - bufferedDuration)")
|
||||
}
|
||||
return .full(until: timestamp + self.highWaterDuration)
|
||||
} else {
|
||||
@ -144,7 +150,7 @@ public final class MediaTrackFrameBuffer {
|
||||
} else {
|
||||
self.isWaitingForLowWaterDuration = false
|
||||
if traceEvents {
|
||||
print("buffered2 duration: \(bufferedDuration), wait until \(timestamp) + \(bufferedDuration - self.lowWaterDuration)")
|
||||
print("\(self.type) buffered2 duration: \(bufferedDuration), wait until \(timestamp) + \(bufferedDuration - self.lowWaterDuration)")
|
||||
}
|
||||
return .full(until: timestamp + max(0.0, bufferedDuration - self.lowWaterDuration))
|
||||
}
|
||||
|
@ -382,6 +382,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-380694650] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowChatParticipants($0) }
|
||||
dict[195371015] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowContacts($0) }
|
||||
dict[-1877932953] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowUsers($0) }
|
||||
dict[-1672247580] = { return Api.InputReplyTo.parse_inputReplyToMessage($0) }
|
||||
dict[-1139169566] = { return Api.InputReplyTo.parse_inputReplyToStory($0) }
|
||||
dict[1399317950] = { return Api.InputSecureFile.parse_inputSecureFile($0) }
|
||||
dict[859091184] = { return Api.InputSecureFile.parse_inputSecureFileUploaded($0) }
|
||||
dict[-618540889] = { return Api.InputSecureValue.parse_inputSecureValue($0) }
|
||||
@ -535,6 +537,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1328256121] = { return Api.MessageReactions.parse_messageReactions($0) }
|
||||
dict[-2083123262] = { return Api.MessageReplies.parse_messageReplies($0) }
|
||||
dict[-1495959709] = { return Api.MessageReplyHeader.parse_messageReplyHeader($0) }
|
||||
dict[-1667711039] = { return Api.MessageReplyHeader.parse_messageReplyStoryHeader($0) }
|
||||
dict[1163625789] = { return Api.MessageViews.parse_messageViews($0) }
|
||||
dict[975236280] = { return Api.MessagesFilter.parse_inputMessagesFilterChatPhotos($0) }
|
||||
dict[-530392189] = { return Api.MessagesFilter.parse_inputMessagesFilterContacts($0) }
|
||||
@ -790,7 +793,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1374088783] = { return Api.StoryItem.parse_storyItemDeleted($0) }
|
||||
dict[-1579626609] = { return Api.StoryItem.parse_storyItemSkipped($0) }
|
||||
dict[-1491424062] = { return Api.StoryView.parse_storyView($0) }
|
||||
dict[1368082392] = { return Api.StoryViews.parse_storyViews($0) }
|
||||
dict[-748199729] = { return Api.StoryViews.parse_storyViews($0) }
|
||||
dict[1964978502] = { return Api.TextWithEntities.parse_textWithEntities($0) }
|
||||
dict[-1609668650] = { return Api.Theme.parse_theme($0) }
|
||||
dict[-94849324] = { return Api.ThemeSettings.parse_themeSettings($0) }
|
||||
@ -1155,7 +1158,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[172975040] = { return Api.storage.FileType.parse_filePng($0) }
|
||||
dict[-1432995067] = { return Api.storage.FileType.parse_fileUnknown($0) }
|
||||
dict[276907596] = { return Api.storage.FileType.parse_fileWebp($0) }
|
||||
dict[1528473228] = { return Api.stories.AllStories.parse_allStories($0) }
|
||||
dict[-2086796248] = { return Api.stories.AllStories.parse_allStories($0) }
|
||||
dict[1205903486] = { return Api.stories.AllStories.parse_allStoriesNotModified($0) }
|
||||
dict[1340440049] = { return Api.stories.Stories.parse_stories($0) }
|
||||
dict[-560009955] = { return Api.stories.StoryViews.parse_storyViews($0) }
|
||||
@ -1479,6 +1482,8 @@ public extension Api {
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.InputPrivacyRule:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.InputReplyTo:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.InputSecureFile:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.InputSecureValue:
|
||||
|
@ -1,3 +1,77 @@
|
||||
public extension Api {
|
||||
indirect enum InputReplyTo: TypeConstructorDescription {
|
||||
case inputReplyToMessage(flags: Int32, replyToMsgId: Int32, topMsgId: Int32?)
|
||||
case inputReplyToStory(flags: Int32, userId: Api.InputUser, storyId: Int32)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .inputReplyToMessage(let flags, let replyToMsgId, let topMsgId):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1672247580)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(replyToMsgId, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .inputReplyToStory(let flags, let userId, let storyId):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1139169566)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
userId.serialize(buffer, true)
|
||||
serializeInt32(storyId, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .inputReplyToMessage(let flags, let replyToMsgId, let topMsgId):
|
||||
return ("inputReplyToMessage", [("flags", flags as Any), ("replyToMsgId", replyToMsgId as Any), ("topMsgId", topMsgId as Any)])
|
||||
case .inputReplyToStory(let flags, let userId, let storyId):
|
||||
return ("inputReplyToStory", [("flags", flags as Any), ("userId", userId as Any), ("storyId", storyId as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_inputReplyToMessage(_ reader: BufferReader) -> InputReplyTo? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: Int32?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.InputReplyTo.inputReplyToMessage(flags: _1!, replyToMsgId: _2!, topMsgId: _3)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputReplyToStory(_ reader: BufferReader) -> InputReplyTo? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.InputUser?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.InputUser
|
||||
}
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.InputReplyTo.inputReplyToStory(flags: _1!, userId: _2!, storyId: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum InputSecureFile: TypeConstructorDescription {
|
||||
case inputSecureFile(id: Int64, accessHash: Int64)
|
||||
@ -932,119 +1006,3 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum InputWebFileLocation: TypeConstructorDescription {
|
||||
case inputWebFileAudioAlbumThumbLocation(flags: Int32, document: Api.InputDocument?, title: String?, performer: String?)
|
||||
case inputWebFileGeoPointLocation(geoPoint: Api.InputGeoPoint, accessHash: Int64, w: Int32, h: Int32, zoom: Int32, scale: Int32)
|
||||
case inputWebFileLocation(url: String, accessHash: Int64)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .inputWebFileAudioAlbumThumbLocation(let flags, let document, let title, let performer):
|
||||
if boxed {
|
||||
buffer.appendInt32(-193992412)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {document!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(performer!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .inputWebFileGeoPointLocation(let geoPoint, let accessHash, let w, let h, let zoom, let scale):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1625153079)
|
||||
}
|
||||
geoPoint.serialize(buffer, true)
|
||||
serializeInt64(accessHash, buffer: buffer, boxed: false)
|
||||
serializeInt32(w, buffer: buffer, boxed: false)
|
||||
serializeInt32(h, buffer: buffer, boxed: false)
|
||||
serializeInt32(zoom, buffer: buffer, boxed: false)
|
||||
serializeInt32(scale, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .inputWebFileLocation(let url, let accessHash):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1036396922)
|
||||
}
|
||||
serializeString(url, buffer: buffer, boxed: false)
|
||||
serializeInt64(accessHash, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .inputWebFileAudioAlbumThumbLocation(let flags, let document, let title, let performer):
|
||||
return ("inputWebFileAudioAlbumThumbLocation", [("flags", flags as Any), ("document", document as Any), ("title", title as Any), ("performer", performer as Any)])
|
||||
case .inputWebFileGeoPointLocation(let geoPoint, let accessHash, let w, let h, let zoom, let scale):
|
||||
return ("inputWebFileGeoPointLocation", [("geoPoint", geoPoint as Any), ("accessHash", accessHash as Any), ("w", w as Any), ("h", h as Any), ("zoom", zoom as Any), ("scale", scale as Any)])
|
||||
case .inputWebFileLocation(let url, let accessHash):
|
||||
return ("inputWebFileLocation", [("url", url as Any), ("accessHash", accessHash as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_inputWebFileAudioAlbumThumbLocation(_ reader: BufferReader) -> InputWebFileLocation? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.InputDocument?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.InputDocument
|
||||
} }
|
||||
var _3: String?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {_3 = parseString(reader) }
|
||||
var _4: String?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {_4 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
|
||||
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.InputWebFileLocation.inputWebFileAudioAlbumThumbLocation(flags: _1!, document: _2, title: _3, performer: _4)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputWebFileGeoPointLocation(_ reader: BufferReader) -> InputWebFileLocation? {
|
||||
var _1: Api.InputGeoPoint?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.InputGeoPoint
|
||||
}
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: Int32?
|
||||
_4 = reader.readInt32()
|
||||
var _5: Int32?
|
||||
_5 = reader.readInt32()
|
||||
var _6: Int32?
|
||||
_6 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.InputWebFileLocation.inputWebFileGeoPointLocation(geoPoint: _1!, accessHash: _2!, w: _3!, h: _4!, zoom: _5!, scale: _6!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputWebFileLocation(_ reader: BufferReader) -> InputWebFileLocation? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.InputWebFileLocation.inputWebFileLocation(url: _1!, accessHash: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,119 @@
|
||||
public extension Api {
|
||||
enum InputWebFileLocation: TypeConstructorDescription {
|
||||
case inputWebFileAudioAlbumThumbLocation(flags: Int32, document: Api.InputDocument?, title: String?, performer: String?)
|
||||
case inputWebFileGeoPointLocation(geoPoint: Api.InputGeoPoint, accessHash: Int64, w: Int32, h: Int32, zoom: Int32, scale: Int32)
|
||||
case inputWebFileLocation(url: String, accessHash: Int64)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .inputWebFileAudioAlbumThumbLocation(let flags, let document, let title, let performer):
|
||||
if boxed {
|
||||
buffer.appendInt32(-193992412)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {document!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(performer!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .inputWebFileGeoPointLocation(let geoPoint, let accessHash, let w, let h, let zoom, let scale):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1625153079)
|
||||
}
|
||||
geoPoint.serialize(buffer, true)
|
||||
serializeInt64(accessHash, buffer: buffer, boxed: false)
|
||||
serializeInt32(w, buffer: buffer, boxed: false)
|
||||
serializeInt32(h, buffer: buffer, boxed: false)
|
||||
serializeInt32(zoom, buffer: buffer, boxed: false)
|
||||
serializeInt32(scale, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .inputWebFileLocation(let url, let accessHash):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1036396922)
|
||||
}
|
||||
serializeString(url, buffer: buffer, boxed: false)
|
||||
serializeInt64(accessHash, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .inputWebFileAudioAlbumThumbLocation(let flags, let document, let title, let performer):
|
||||
return ("inputWebFileAudioAlbumThumbLocation", [("flags", flags as Any), ("document", document as Any), ("title", title as Any), ("performer", performer as Any)])
|
||||
case .inputWebFileGeoPointLocation(let geoPoint, let accessHash, let w, let h, let zoom, let scale):
|
||||
return ("inputWebFileGeoPointLocation", [("geoPoint", geoPoint as Any), ("accessHash", accessHash as Any), ("w", w as Any), ("h", h as Any), ("zoom", zoom as Any), ("scale", scale as Any)])
|
||||
case .inputWebFileLocation(let url, let accessHash):
|
||||
return ("inputWebFileLocation", [("url", url as Any), ("accessHash", accessHash as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_inputWebFileAudioAlbumThumbLocation(_ reader: BufferReader) -> InputWebFileLocation? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.InputDocument?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.InputDocument
|
||||
} }
|
||||
var _3: String?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {_3 = parseString(reader) }
|
||||
var _4: String?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {_4 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
|
||||
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.InputWebFileLocation.inputWebFileAudioAlbumThumbLocation(flags: _1!, document: _2, title: _3, performer: _4)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputWebFileGeoPointLocation(_ reader: BufferReader) -> InputWebFileLocation? {
|
||||
var _1: Api.InputGeoPoint?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.InputGeoPoint
|
||||
}
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: Int32?
|
||||
_4 = reader.readInt32()
|
||||
var _5: Int32?
|
||||
_5 = reader.readInt32()
|
||||
var _6: Int32?
|
||||
_6 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.InputWebFileLocation.inputWebFileGeoPointLocation(geoPoint: _1!, accessHash: _2!, w: _3!, h: _4!, zoom: _5!, scale: _6!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputWebFileLocation(_ reader: BufferReader) -> InputWebFileLocation? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.InputWebFileLocation.inputWebFileLocation(url: _1!, accessHash: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum Invoice: TypeConstructorDescription {
|
||||
case invoice(flags: Int32, currency: String, prices: [Api.LabeledPrice], maxTipAmount: Int64?, suggestedTipAmounts: [Int64]?, recurringTermsUrl: String?)
|
||||
@ -1000,51 +1116,3 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum MaskCoords: TypeConstructorDescription {
|
||||
case maskCoords(n: Int32, x: Double, y: Double, zoom: Double)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .maskCoords(let n, let x, let y, let zoom):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1361650766)
|
||||
}
|
||||
serializeInt32(n, buffer: buffer, boxed: false)
|
||||
serializeDouble(x, buffer: buffer, boxed: false)
|
||||
serializeDouble(y, buffer: buffer, boxed: false)
|
||||
serializeDouble(zoom, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .maskCoords(let n, let x, let y, let zoom):
|
||||
return ("maskCoords", [("n", n as Any), ("x", x as Any), ("y", y as Any), ("zoom", zoom as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_maskCoords(_ reader: BufferReader) -> MaskCoords? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Double?
|
||||
_2 = reader.readDouble()
|
||||
var _3: Double?
|
||||
_3 = reader.readDouble()
|
||||
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.MaskCoords.maskCoords(n: _1!, x: _2!, y: _3!, zoom: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,51 @@
|
||||
public extension Api {
|
||||
enum MaskCoords: TypeConstructorDescription {
|
||||
case maskCoords(n: Int32, x: Double, y: Double, zoom: Double)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .maskCoords(let n, let x, let y, let zoom):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1361650766)
|
||||
}
|
||||
serializeInt32(n, buffer: buffer, boxed: false)
|
||||
serializeDouble(x, buffer: buffer, boxed: false)
|
||||
serializeDouble(y, buffer: buffer, boxed: false)
|
||||
serializeDouble(zoom, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .maskCoords(let n, let x, let y, let zoom):
|
||||
return ("maskCoords", [("n", n as Any), ("x", x as Any), ("y", y as Any), ("zoom", zoom as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_maskCoords(_ reader: BufferReader) -> MaskCoords? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Double?
|
||||
_2 = reader.readDouble()
|
||||
var _3: Double?
|
||||
_3 = reader.readDouble()
|
||||
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.MaskCoords.maskCoords(n: _1!, x: _2!, y: _3!, zoom: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
indirect enum Message: TypeConstructorDescription {
|
||||
case message(flags: Int32, id: Int32, fromId: Api.Peer?, peerId: Api.Peer, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int64?, replyTo: Api.MessageReplyHeader?, date: Int32, message: String, media: Api.MessageMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, views: Int32?, forwards: Int32?, replies: Api.MessageReplies?, editDate: Int32?, postAuthor: String?, groupedId: Int64?, reactions: Api.MessageReactions?, restrictionReason: [Api.RestrictionReason]?, ttlPeriod: Int32?)
|
||||
|
@ -323,6 +323,7 @@ public extension Api {
|
||||
public extension Api {
|
||||
enum MessageReplyHeader: TypeConstructorDescription {
|
||||
case messageReplyHeader(flags: Int32, replyToMsgId: Int32, replyToPeerId: Api.Peer?, replyToTopId: Int32?)
|
||||
case messageReplyStoryHeader(userId: Int64, storyId: Int32)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -335,6 +336,13 @@ public extension Api {
|
||||
if Int(flags) & Int(1 << 0) != 0 {replyToPeerId!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(replyToTopId!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .messageReplyStoryHeader(let userId, let storyId):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1667711039)
|
||||
}
|
||||
serializeInt64(userId, buffer: buffer, boxed: false)
|
||||
serializeInt32(storyId, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,6 +350,8 @@ public extension Api {
|
||||
switch self {
|
||||
case .messageReplyHeader(let flags, let replyToMsgId, let replyToPeerId, let replyToTopId):
|
||||
return ("messageReplyHeader", [("flags", flags as Any), ("replyToMsgId", replyToMsgId as Any), ("replyToPeerId", replyToPeerId as Any), ("replyToTopId", replyToTopId as Any)])
|
||||
case .messageReplyStoryHeader(let userId, let storyId):
|
||||
return ("messageReplyStoryHeader", [("userId", userId as Any), ("storyId", storyId as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,6 +377,20 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageReplyStoryHeader(_ reader: BufferReader) -> MessageReplyHeader? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.MessageReplyHeader.messageReplyStoryHeader(userId: _1!, storyId: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -776,103 +800,3 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum NotifyPeer: TypeConstructorDescription {
|
||||
case notifyBroadcasts
|
||||
case notifyChats
|
||||
case notifyForumTopic(peer: Api.Peer, topMsgId: Int32)
|
||||
case notifyPeer(peer: Api.Peer)
|
||||
case notifyUsers
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .notifyBroadcasts:
|
||||
if boxed {
|
||||
buffer.appendInt32(-703403793)
|
||||
}
|
||||
|
||||
break
|
||||
case .notifyChats:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1073230141)
|
||||
}
|
||||
|
||||
break
|
||||
case .notifyForumTopic(let peer, let topMsgId):
|
||||
if boxed {
|
||||
buffer.appendInt32(577659656)
|
||||
}
|
||||
peer.serialize(buffer, true)
|
||||
serializeInt32(topMsgId, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .notifyPeer(let peer):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1613493288)
|
||||
}
|
||||
peer.serialize(buffer, true)
|
||||
break
|
||||
case .notifyUsers:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1261946036)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .notifyBroadcasts:
|
||||
return ("notifyBroadcasts", [])
|
||||
case .notifyChats:
|
||||
return ("notifyChats", [])
|
||||
case .notifyForumTopic(let peer, let topMsgId):
|
||||
return ("notifyForumTopic", [("peer", peer as Any), ("topMsgId", topMsgId as Any)])
|
||||
case .notifyPeer(let peer):
|
||||
return ("notifyPeer", [("peer", peer as Any)])
|
||||
case .notifyUsers:
|
||||
return ("notifyUsers", [])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_notifyBroadcasts(_ reader: BufferReader) -> NotifyPeer? {
|
||||
return Api.NotifyPeer.notifyBroadcasts
|
||||
}
|
||||
public static func parse_notifyChats(_ reader: BufferReader) -> NotifyPeer? {
|
||||
return Api.NotifyPeer.notifyChats
|
||||
}
|
||||
public static func parse_notifyForumTopic(_ reader: BufferReader) -> NotifyPeer? {
|
||||
var _1: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.NotifyPeer.notifyForumTopic(peer: _1!, topMsgId: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_notifyPeer(_ reader: BufferReader) -> NotifyPeer? {
|
||||
var _1: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.NotifyPeer.notifyPeer(peer: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_notifyUsers(_ reader: BufferReader) -> NotifyPeer? {
|
||||
return Api.NotifyPeer.notifyUsers
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,103 @@
|
||||
public extension Api {
|
||||
enum NotifyPeer: TypeConstructorDescription {
|
||||
case notifyBroadcasts
|
||||
case notifyChats
|
||||
case notifyForumTopic(peer: Api.Peer, topMsgId: Int32)
|
||||
case notifyPeer(peer: Api.Peer)
|
||||
case notifyUsers
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .notifyBroadcasts:
|
||||
if boxed {
|
||||
buffer.appendInt32(-703403793)
|
||||
}
|
||||
|
||||
break
|
||||
case .notifyChats:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1073230141)
|
||||
}
|
||||
|
||||
break
|
||||
case .notifyForumTopic(let peer, let topMsgId):
|
||||
if boxed {
|
||||
buffer.appendInt32(577659656)
|
||||
}
|
||||
peer.serialize(buffer, true)
|
||||
serializeInt32(topMsgId, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .notifyPeer(let peer):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1613493288)
|
||||
}
|
||||
peer.serialize(buffer, true)
|
||||
break
|
||||
case .notifyUsers:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1261946036)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .notifyBroadcasts:
|
||||
return ("notifyBroadcasts", [])
|
||||
case .notifyChats:
|
||||
return ("notifyChats", [])
|
||||
case .notifyForumTopic(let peer, let topMsgId):
|
||||
return ("notifyForumTopic", [("peer", peer as Any), ("topMsgId", topMsgId as Any)])
|
||||
case .notifyPeer(let peer):
|
||||
return ("notifyPeer", [("peer", peer as Any)])
|
||||
case .notifyUsers:
|
||||
return ("notifyUsers", [])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_notifyBroadcasts(_ reader: BufferReader) -> NotifyPeer? {
|
||||
return Api.NotifyPeer.notifyBroadcasts
|
||||
}
|
||||
public static func parse_notifyChats(_ reader: BufferReader) -> NotifyPeer? {
|
||||
return Api.NotifyPeer.notifyChats
|
||||
}
|
||||
public static func parse_notifyForumTopic(_ reader: BufferReader) -> NotifyPeer? {
|
||||
var _1: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.NotifyPeer.notifyForumTopic(peer: _1!, topMsgId: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_notifyPeer(_ reader: BufferReader) -> NotifyPeer? {
|
||||
var _1: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.NotifyPeer.notifyPeer(peer: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_notifyUsers(_ reader: BufferReader) -> NotifyPeer? {
|
||||
return Api.NotifyPeer.notifyUsers
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum Page: TypeConstructorDescription {
|
||||
case page(flags: Int32, url: String, blocks: [Api.PageBlock], photos: [Api.Photo], documents: [Api.Document], views: Int32?)
|
||||
@ -890,111 +990,3 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
indirect enum PageCaption: TypeConstructorDescription {
|
||||
case pageCaption(text: Api.RichText, credit: Api.RichText)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .pageCaption(let text, let credit):
|
||||
if boxed {
|
||||
buffer.appendInt32(1869903447)
|
||||
}
|
||||
text.serialize(buffer, true)
|
||||
credit.serialize(buffer, true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .pageCaption(let text, let credit):
|
||||
return ("pageCaption", [("text", text as Any), ("credit", credit as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_pageCaption(_ reader: BufferReader) -> PageCaption? {
|
||||
var _1: Api.RichText?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.RichText
|
||||
}
|
||||
var _2: Api.RichText?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.RichText
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.PageCaption.pageCaption(text: _1!, credit: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
indirect enum PageListItem: TypeConstructorDescription {
|
||||
case pageListItemBlocks(blocks: [Api.PageBlock])
|
||||
case pageListItemText(text: Api.RichText)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .pageListItemBlocks(let blocks):
|
||||
if boxed {
|
||||
buffer.appendInt32(635466748)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(blocks.count))
|
||||
for item in blocks {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .pageListItemText(let text):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1188055347)
|
||||
}
|
||||
text.serialize(buffer, true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .pageListItemBlocks(let blocks):
|
||||
return ("pageListItemBlocks", [("blocks", blocks as Any)])
|
||||
case .pageListItemText(let text):
|
||||
return ("pageListItemText", [("text", text as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_pageListItemBlocks(_ reader: BufferReader) -> PageListItem? {
|
||||
var _1: [Api.PageBlock]?
|
||||
if let _ = reader.readInt32() {
|
||||
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.PageListItem.pageListItemBlocks(blocks: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_pageListItemText(_ reader: BufferReader) -> PageListItem? {
|
||||
var _1: Api.RichText?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.RichText
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.PageListItem.pageListItemText(text: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,111 @@
|
||||
public extension Api {
|
||||
indirect enum PageCaption: TypeConstructorDescription {
|
||||
case pageCaption(text: Api.RichText, credit: Api.RichText)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .pageCaption(let text, let credit):
|
||||
if boxed {
|
||||
buffer.appendInt32(1869903447)
|
||||
}
|
||||
text.serialize(buffer, true)
|
||||
credit.serialize(buffer, true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .pageCaption(let text, let credit):
|
||||
return ("pageCaption", [("text", text as Any), ("credit", credit as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_pageCaption(_ reader: BufferReader) -> PageCaption? {
|
||||
var _1: Api.RichText?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.RichText
|
||||
}
|
||||
var _2: Api.RichText?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.RichText
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.PageCaption.pageCaption(text: _1!, credit: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
indirect enum PageListItem: TypeConstructorDescription {
|
||||
case pageListItemBlocks(blocks: [Api.PageBlock])
|
||||
case pageListItemText(text: Api.RichText)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .pageListItemBlocks(let blocks):
|
||||
if boxed {
|
||||
buffer.appendInt32(635466748)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(blocks.count))
|
||||
for item in blocks {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .pageListItemText(let text):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1188055347)
|
||||
}
|
||||
text.serialize(buffer, true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .pageListItemBlocks(let blocks):
|
||||
return ("pageListItemBlocks", [("blocks", blocks as Any)])
|
||||
case .pageListItemText(let text):
|
||||
return ("pageListItemText", [("text", text as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_pageListItemBlocks(_ reader: BufferReader) -> PageListItem? {
|
||||
var _1: [Api.PageBlock]?
|
||||
if let _ = reader.readInt32() {
|
||||
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.PageListItem.pageListItemBlocks(blocks: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_pageListItemText(_ reader: BufferReader) -> PageListItem? {
|
||||
var _1: Api.RichText?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.RichText
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.PageListItem.pageListItemText(text: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
indirect enum PageListOrderedItem: TypeConstructorDescription {
|
||||
case pageListOrderedItemBlocks(num: String, blocks: [Api.PageBlock])
|
||||
@ -1114,157 +1222,3 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum PhoneCallProtocol: TypeConstructorDescription {
|
||||
case phoneCallProtocol(flags: Int32, minLayer: Int32, maxLayer: Int32, libraryVersions: [String])
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .phoneCallProtocol(let flags, let minLayer, let maxLayer, let libraryVersions):
|
||||
if boxed {
|
||||
buffer.appendInt32(-58224696)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(minLayer, buffer: buffer, boxed: false)
|
||||
serializeInt32(maxLayer, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(libraryVersions.count))
|
||||
for item in libraryVersions {
|
||||
serializeString(item, buffer: buffer, boxed: false)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .phoneCallProtocol(let flags, let minLayer, let maxLayer, let libraryVersions):
|
||||
return ("phoneCallProtocol", [("flags", flags as Any), ("minLayer", minLayer as Any), ("maxLayer", maxLayer as Any), ("libraryVersions", libraryVersions as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_phoneCallProtocol(_ reader: BufferReader) -> PhoneCallProtocol? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: [String]?
|
||||
if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.PhoneCallProtocol.phoneCallProtocol(flags: _1!, minLayer: _2!, maxLayer: _3!, libraryVersions: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum PhoneConnection: TypeConstructorDescription {
|
||||
case phoneConnection(flags: Int32, id: Int64, ip: String, ipv6: String, port: Int32, peerTag: Buffer)
|
||||
case phoneConnectionWebrtc(flags: Int32, id: Int64, ip: String, ipv6: String, port: Int32, username: String, password: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .phoneConnection(let flags, let id, let ip, let ipv6, let port, let peerTag):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1665063993)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(id, buffer: buffer, boxed: false)
|
||||
serializeString(ip, buffer: buffer, boxed: false)
|
||||
serializeString(ipv6, buffer: buffer, boxed: false)
|
||||
serializeInt32(port, buffer: buffer, boxed: false)
|
||||
serializeBytes(peerTag, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .phoneConnectionWebrtc(let flags, let id, let ip, let ipv6, let port, let username, let password):
|
||||
if boxed {
|
||||
buffer.appendInt32(1667228533)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(id, buffer: buffer, boxed: false)
|
||||
serializeString(ip, buffer: buffer, boxed: false)
|
||||
serializeString(ipv6, buffer: buffer, boxed: false)
|
||||
serializeInt32(port, buffer: buffer, boxed: false)
|
||||
serializeString(username, buffer: buffer, boxed: false)
|
||||
serializeString(password, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .phoneConnection(let flags, let id, let ip, let ipv6, let port, let peerTag):
|
||||
return ("phoneConnection", [("flags", flags as Any), ("id", id as Any), ("ip", ip as Any), ("ipv6", ipv6 as Any), ("port", port as Any), ("peerTag", peerTag as Any)])
|
||||
case .phoneConnectionWebrtc(let flags, let id, let ip, let ipv6, let port, let username, let password):
|
||||
return ("phoneConnectionWebrtc", [("flags", flags as Any), ("id", id as Any), ("ip", ip as Any), ("ipv6", ipv6 as Any), ("port", port as Any), ("username", username as Any), ("password", password as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_phoneConnection(_ reader: BufferReader) -> PhoneConnection? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
var _5: Int32?
|
||||
_5 = reader.readInt32()
|
||||
var _6: Buffer?
|
||||
_6 = parseBytes(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.PhoneConnection.phoneConnection(flags: _1!, id: _2!, ip: _3!, ipv6: _4!, port: _5!, peerTag: _6!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_phoneConnectionWebrtc(_ reader: BufferReader) -> PhoneConnection? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
var _5: Int32?
|
||||
_5 = reader.readInt32()
|
||||
var _6: String?
|
||||
_6 = parseString(reader)
|
||||
var _7: String?
|
||||
_7 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
let _c7 = _7 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
|
||||
return Api.PhoneConnection.phoneConnectionWebrtc(flags: _1!, id: _2!, ip: _3!, ipv6: _4!, port: _5!, username: _6!, password: _7!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,157 @@
|
||||
public extension Api {
|
||||
enum PhoneCallProtocol: TypeConstructorDescription {
|
||||
case phoneCallProtocol(flags: Int32, minLayer: Int32, maxLayer: Int32, libraryVersions: [String])
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .phoneCallProtocol(let flags, let minLayer, let maxLayer, let libraryVersions):
|
||||
if boxed {
|
||||
buffer.appendInt32(-58224696)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(minLayer, buffer: buffer, boxed: false)
|
||||
serializeInt32(maxLayer, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(libraryVersions.count))
|
||||
for item in libraryVersions {
|
||||
serializeString(item, buffer: buffer, boxed: false)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .phoneCallProtocol(let flags, let minLayer, let maxLayer, let libraryVersions):
|
||||
return ("phoneCallProtocol", [("flags", flags as Any), ("minLayer", minLayer as Any), ("maxLayer", maxLayer as Any), ("libraryVersions", libraryVersions as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_phoneCallProtocol(_ reader: BufferReader) -> PhoneCallProtocol? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: [String]?
|
||||
if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.PhoneCallProtocol.phoneCallProtocol(flags: _1!, minLayer: _2!, maxLayer: _3!, libraryVersions: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum PhoneConnection: TypeConstructorDescription {
|
||||
case phoneConnection(flags: Int32, id: Int64, ip: String, ipv6: String, port: Int32, peerTag: Buffer)
|
||||
case phoneConnectionWebrtc(flags: Int32, id: Int64, ip: String, ipv6: String, port: Int32, username: String, password: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .phoneConnection(let flags, let id, let ip, let ipv6, let port, let peerTag):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1665063993)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(id, buffer: buffer, boxed: false)
|
||||
serializeString(ip, buffer: buffer, boxed: false)
|
||||
serializeString(ipv6, buffer: buffer, boxed: false)
|
||||
serializeInt32(port, buffer: buffer, boxed: false)
|
||||
serializeBytes(peerTag, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .phoneConnectionWebrtc(let flags, let id, let ip, let ipv6, let port, let username, let password):
|
||||
if boxed {
|
||||
buffer.appendInt32(1667228533)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(id, buffer: buffer, boxed: false)
|
||||
serializeString(ip, buffer: buffer, boxed: false)
|
||||
serializeString(ipv6, buffer: buffer, boxed: false)
|
||||
serializeInt32(port, buffer: buffer, boxed: false)
|
||||
serializeString(username, buffer: buffer, boxed: false)
|
||||
serializeString(password, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .phoneConnection(let flags, let id, let ip, let ipv6, let port, let peerTag):
|
||||
return ("phoneConnection", [("flags", flags as Any), ("id", id as Any), ("ip", ip as Any), ("ipv6", ipv6 as Any), ("port", port as Any), ("peerTag", peerTag as Any)])
|
||||
case .phoneConnectionWebrtc(let flags, let id, let ip, let ipv6, let port, let username, let password):
|
||||
return ("phoneConnectionWebrtc", [("flags", flags as Any), ("id", id as Any), ("ip", ip as Any), ("ipv6", ipv6 as Any), ("port", port as Any), ("username", username as Any), ("password", password as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_phoneConnection(_ reader: BufferReader) -> PhoneConnection? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
var _5: Int32?
|
||||
_5 = reader.readInt32()
|
||||
var _6: Buffer?
|
||||
_6 = parseBytes(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.PhoneConnection.phoneConnection(flags: _1!, id: _2!, ip: _3!, ipv6: _4!, port: _5!, peerTag: _6!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_phoneConnectionWebrtc(_ reader: BufferReader) -> PhoneConnection? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
var _5: Int32?
|
||||
_5 = reader.readInt32()
|
||||
var _6: String?
|
||||
_6 = parseString(reader)
|
||||
var _7: String?
|
||||
_7 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
let _c7 = _7 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
|
||||
return Api.PhoneConnection.phoneConnectionWebrtc(flags: _1!, id: _2!, ip: _3!, ipv6: _4!, port: _5!, username: _6!, password: _7!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum Photo: TypeConstructorDescription {
|
||||
case photo(flags: Int32, id: Int64, accessHash: Int64, fileReference: Buffer, date: Int32, sizes: [Api.PhotoSize], videoSizes: [Api.VideoSize]?, dcId: Int32)
|
||||
|
@ -492,42 +492,46 @@ public extension Api {
|
||||
}
|
||||
public extension Api {
|
||||
enum StoryViews: TypeConstructorDescription {
|
||||
case storyViews(recentViewers: [Int64], viewsCount: Int32)
|
||||
case storyViews(flags: Int32, viewsCount: Int32, recentViewers: [Int64]?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .storyViews(let recentViewers, let viewsCount):
|
||||
case .storyViews(let flags, let viewsCount, let recentViewers):
|
||||
if boxed {
|
||||
buffer.appendInt32(1368082392)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(recentViewers.count))
|
||||
for item in recentViewers {
|
||||
serializeInt64(item, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(-748199729)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(viewsCount, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(recentViewers!.count))
|
||||
for item in recentViewers! {
|
||||
serializeInt64(item, buffer: buffer, boxed: false)
|
||||
}}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .storyViews(let recentViewers, let viewsCount):
|
||||
return ("storyViews", [("recentViewers", recentViewers as Any), ("viewsCount", viewsCount as Any)])
|
||||
case .storyViews(let flags, let viewsCount, let recentViewers):
|
||||
return ("storyViews", [("flags", flags as Any), ("viewsCount", viewsCount as Any), ("recentViewers", recentViewers as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_storyViews(_ reader: BufferReader) -> StoryViews? {
|
||||
var _1: [Int64]?
|
||||
if let _ = reader.readInt32() {
|
||||
_1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
|
||||
}
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: [Int64]?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.StoryViews.storyViews(recentViewers: _1!, viewsCount: _2!)
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.StoryViews.storyViews(flags: _1!, viewsCount: _2!, recentViewers: _3)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -360,16 +360,17 @@ public extension Api.storage {
|
||||
}
|
||||
public extension Api.stories {
|
||||
enum AllStories: TypeConstructorDescription {
|
||||
case allStories(flags: Int32, state: String, userStories: [Api.UserStories], users: [Api.User])
|
||||
case allStories(flags: Int32, count: Int32, state: String, userStories: [Api.UserStories], users: [Api.User])
|
||||
case allStoriesNotModified(state: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .allStories(let flags, let state, let userStories, let users):
|
||||
case .allStories(let flags, let count, let state, let userStories, let users):
|
||||
if boxed {
|
||||
buffer.appendInt32(1528473228)
|
||||
buffer.appendInt32(-2086796248)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(count, buffer: buffer, boxed: false)
|
||||
serializeString(state, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(userStories.count))
|
||||
@ -393,8 +394,8 @@ public extension Api.stories {
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .allStories(let flags, let state, let userStories, let users):
|
||||
return ("allStories", [("flags", flags as Any), ("state", state as Any), ("userStories", userStories as Any), ("users", users as Any)])
|
||||
case .allStories(let flags, let count, let state, let userStories, let users):
|
||||
return ("allStories", [("flags", flags as Any), ("count", count as Any), ("state", state as Any), ("userStories", userStories as Any), ("users", users as Any)])
|
||||
case .allStoriesNotModified(let state):
|
||||
return ("allStoriesNotModified", [("state", state as Any)])
|
||||
}
|
||||
@ -403,22 +404,25 @@ public extension Api.stories {
|
||||
public static func parse_allStories(_ reader: BufferReader) -> AllStories? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: String?
|
||||
_2 = parseString(reader)
|
||||
var _3: [Api.UserStories]?
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
var _4: [Api.UserStories]?
|
||||
if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.UserStories.self)
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.UserStories.self)
|
||||
}
|
||||
var _4: [Api.User]?
|
||||
var _5: [Api.User]?
|
||||
if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
|
||||
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.stories.AllStories.allStories(flags: _1!, state: _2!, userStories: _3!, users: _4!)
|
||||
let _c5 = _5 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
||||
return Api.stories.AllStories.allStories(flags: _1!, count: _2!, state: _3!, userStories: _4!, users: _5!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -5962,17 +5962,16 @@ public extension Api.functions.messages {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func prolongWebView(flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, queryId: Int64, replyToMsgId: Int32?, topMsgId: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
static func prolongWebView(flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, queryId: Int64, replyTo: Api.InputReplyTo?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(2146648841)
|
||||
buffer.appendInt32(-1328014717)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
peer.serialize(buffer, true)
|
||||
bot.serialize(buffer, true)
|
||||
serializeInt64(queryId, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 9) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {replyTo!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)}
|
||||
return (FunctionDescription(name: "messages.prolongWebView", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("bot", String(describing: bot)), ("queryId", String(describing: queryId)), ("replyToMsgId", String(describing: replyToMsgId)), ("topMsgId", String(describing: topMsgId)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
return (FunctionDescription(name: "messages.prolongWebView", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("bot", String(describing: bot)), ("queryId", String(describing: queryId)), ("replyTo", String(describing: replyTo)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -6337,9 +6336,9 @@ public extension Api.functions.messages {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func requestWebView(flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, url: String?, startParam: String?, themeParams: Api.DataJSON?, platform: String, replyToMsgId: Int32?, topMsgId: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.WebViewResult>) {
|
||||
static func requestWebView(flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, url: String?, startParam: String?, themeParams: Api.DataJSON?, platform: String, replyTo: Api.InputReplyTo?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.WebViewResult>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(395003915)
|
||||
buffer.appendInt32(647873217)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
peer.serialize(buffer, true)
|
||||
bot.serialize(buffer, true)
|
||||
@ -6347,10 +6346,9 @@ public extension Api.functions.messages {
|
||||
if Int(flags) & Int(1 << 3) != 0 {serializeString(startParam!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 2) != 0 {themeParams!.serialize(buffer, true)}
|
||||
serializeString(platform, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 9) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {replyTo!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)}
|
||||
return (FunctionDescription(name: "messages.requestWebView", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("bot", String(describing: bot)), ("url", String(describing: url)), ("startParam", String(describing: startParam)), ("themeParams", String(describing: themeParams)), ("platform", String(describing: platform)), ("replyToMsgId", String(describing: replyToMsgId)), ("topMsgId", String(describing: topMsgId)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.WebViewResult? in
|
||||
return (FunctionDescription(name: "messages.requestWebView", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("bot", String(describing: bot)), ("url", String(describing: url)), ("startParam", String(describing: startParam)), ("themeParams", String(describing: themeParams)), ("platform", String(describing: platform)), ("replyTo", String(describing: replyTo)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.WebViewResult? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.WebViewResult?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -6608,19 +6606,18 @@ public extension Api.functions.messages {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func sendInlineBotResult(flags: Int32, peer: Api.InputPeer, replyToMsgId: Int32?, topMsgId: Int32?, randomId: Int64, queryId: Int64, id: String, scheduleDate: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
static func sendInlineBotResult(flags: Int32, peer: Api.InputPeer, replyTo: Api.InputReplyTo?, randomId: Int64, queryId: Int64, id: String, scheduleDate: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-738468661)
|
||||
buffer.appendInt32(-138647366)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
peer.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 9) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {replyTo!.serialize(buffer, true)}
|
||||
serializeInt64(randomId, buffer: buffer, boxed: false)
|
||||
serializeInt64(queryId, buffer: buffer, boxed: false)
|
||||
serializeString(id, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 10) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)}
|
||||
return (FunctionDescription(name: "messages.sendInlineBotResult", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("replyToMsgId", String(describing: replyToMsgId)), ("topMsgId", String(describing: topMsgId)), ("randomId", String(describing: randomId)), ("queryId", String(describing: queryId)), ("id", String(describing: id)), ("scheduleDate", String(describing: scheduleDate)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
return (FunctionDescription(name: "messages.sendInlineBotResult", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("replyTo", String(describing: replyTo)), ("randomId", String(describing: randomId)), ("queryId", String(describing: queryId)), ("id", String(describing: id)), ("scheduleDate", String(describing: scheduleDate)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -6631,13 +6628,12 @@ public extension Api.functions.messages {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func sendMedia(flags: Int32, peer: Api.InputPeer, replyToMsgId: Int32?, topMsgId: Int32?, media: Api.InputMedia, message: String, randomId: Int64, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, scheduleDate: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
static func sendMedia(flags: Int32, peer: Api.InputPeer, replyTo: Api.InputReplyTo?, media: Api.InputMedia, message: String, randomId: Int64, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, scheduleDate: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1967638886)
|
||||
buffer.appendInt32(1926021693)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
peer.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 9) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {replyTo!.serialize(buffer, true)}
|
||||
media.serialize(buffer, true)
|
||||
serializeString(message, buffer: buffer, boxed: false)
|
||||
serializeInt64(randomId, buffer: buffer, boxed: false)
|
||||
@ -6649,7 +6645,7 @@ public extension Api.functions.messages {
|
||||
}}
|
||||
if Int(flags) & Int(1 << 10) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)}
|
||||
return (FunctionDescription(name: "messages.sendMedia", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("replyToMsgId", String(describing: replyToMsgId)), ("topMsgId", String(describing: topMsgId)), ("media", String(describing: media)), ("message", String(describing: message)), ("randomId", String(describing: randomId)), ("replyMarkup", String(describing: replyMarkup)), ("entities", String(describing: entities)), ("scheduleDate", String(describing: scheduleDate)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
return (FunctionDescription(name: "messages.sendMedia", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("replyTo", String(describing: replyTo)), ("media", String(describing: media)), ("message", String(describing: message)), ("randomId", String(describing: randomId)), ("replyMarkup", String(describing: replyMarkup)), ("entities", String(describing: entities)), ("scheduleDate", String(describing: scheduleDate)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -6660,13 +6656,12 @@ public extension Api.functions.messages {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func sendMessage(flags: Int32, peer: Api.InputPeer, replyToMsgId: Int32?, topMsgId: Int32?, message: String, randomId: Int64, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, scheduleDate: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
static func sendMessage(flags: Int32, peer: Api.InputPeer, replyTo: Api.InputReplyTo?, message: String, randomId: Int64, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, scheduleDate: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(482476935)
|
||||
buffer.appendInt32(671943023)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
peer.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 9) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {replyTo!.serialize(buffer, true)}
|
||||
serializeString(message, buffer: buffer, boxed: false)
|
||||
serializeInt64(randomId, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)}
|
||||
@ -6677,7 +6672,7 @@ public extension Api.functions.messages {
|
||||
}}
|
||||
if Int(flags) & Int(1 << 10) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)}
|
||||
return (FunctionDescription(name: "messages.sendMessage", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("replyToMsgId", String(describing: replyToMsgId)), ("topMsgId", String(describing: topMsgId)), ("message", String(describing: message)), ("randomId", String(describing: randomId)), ("replyMarkup", String(describing: replyMarkup)), ("entities", String(describing: entities)), ("scheduleDate", String(describing: scheduleDate)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
return (FunctionDescription(name: "messages.sendMessage", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("replyTo", String(describing: replyTo)), ("message", String(describing: message)), ("randomId", String(describing: randomId)), ("replyMarkup", String(describing: replyMarkup)), ("entities", String(describing: entities)), ("scheduleDate", String(describing: scheduleDate)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -6688,13 +6683,12 @@ public extension Api.functions.messages {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func sendMultiMedia(flags: Int32, peer: Api.InputPeer, replyToMsgId: Int32?, topMsgId: Int32?, multiMedia: [Api.InputSingleMedia], scheduleDate: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
static func sendMultiMedia(flags: Int32, peer: Api.InputPeer, replyTo: Api.InputReplyTo?, multiMedia: [Api.InputSingleMedia], scheduleDate: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-1225713124)
|
||||
buffer.appendInt32(1164872071)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
peer.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 9) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {replyTo!.serialize(buffer, true)}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(multiMedia.count))
|
||||
for item in multiMedia {
|
||||
@ -6702,7 +6696,7 @@ public extension Api.functions.messages {
|
||||
}
|
||||
if Int(flags) & Int(1 << 10) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)}
|
||||
return (FunctionDescription(name: "messages.sendMultiMedia", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("replyToMsgId", String(describing: replyToMsgId)), ("topMsgId", String(describing: topMsgId)), ("multiMedia", String(describing: multiMedia)), ("scheduleDate", String(describing: scheduleDate)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
return (FunctionDescription(name: "messages.sendMultiMedia", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("replyTo", String(describing: replyTo)), ("multiMedia", String(describing: multiMedia)), ("scheduleDate", String(describing: scheduleDate)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -6755,13 +6749,13 @@ public extension Api.functions.messages {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func sendScreenshotNotification(peer: Api.InputPeer, replyToMsgId: Int32, randomId: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
static func sendScreenshotNotification(peer: Api.InputPeer, replyTo: Api.InputReplyTo, randomId: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-914493408)
|
||||
buffer.appendInt32(-1589618665)
|
||||
peer.serialize(buffer, true)
|
||||
serializeInt32(replyToMsgId, buffer: buffer, boxed: false)
|
||||
replyTo.serialize(buffer, true)
|
||||
serializeInt64(randomId, buffer: buffer, boxed: false)
|
||||
return (FunctionDescription(name: "messages.sendScreenshotNotification", parameters: [("peer", String(describing: peer)), ("replyToMsgId", String(describing: replyToMsgId)), ("randomId", String(describing: randomId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
return (FunctionDescription(name: "messages.sendScreenshotNotification", parameters: [("peer", String(describing: peer)), ("replyTo", String(describing: replyTo)), ("randomId", String(describing: randomId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -8583,6 +8577,26 @@ public extension Api.functions.stories {
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.stories {
|
||||
static func incrementStoryViews(userId: Api.InputUser, id: [Int32]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(571629863)
|
||||
userId.serialize(buffer, true)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(id.count))
|
||||
for item in id {
|
||||
serializeInt32(item, buffer: buffer, boxed: false)
|
||||
}
|
||||
return (FunctionDescription(name: "stories.incrementStoryViews", parameters: [("userId", String(describing: userId)), ("id", String(describing: id))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.stories {
|
||||
static func readStories(userId: Api.InputUser, maxId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Int32]>) {
|
||||
let buffer = Buffer()
|
||||
|
@ -250,6 +250,8 @@ func apiMessageAssociatedMessageIds(_ message: Api.Message) -> (replyIds: Refere
|
||||
var replyIds = ReferencedReplyMessageIds()
|
||||
replyIds.add(sourceId: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: id), targetId: targetId)
|
||||
return (replyIds, [])
|
||||
case .messageReplyStoryHeader:
|
||||
break
|
||||
}
|
||||
}
|
||||
case .messageEmpty:
|
||||
@ -262,6 +264,8 @@ func apiMessageAssociatedMessageIds(_ message: Api.Message) -> (replyIds: Refere
|
||||
var replyIds = ReferencedReplyMessageIds()
|
||||
replyIds.add(sourceId: MessageId(peerId: chatPeerId.peerId, namespace: Namespaces.Message.Cloud, id: id), targetId: targetId)
|
||||
return (replyIds, [])
|
||||
case .messageReplyStoryHeader:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -479,6 +483,8 @@ extension StoreMessage {
|
||||
}
|
||||
}
|
||||
attributes.append(ReplyMessageAttribute(messageId: MessageId(peerId: replyPeerId, namespace: Namespaces.Message.Cloud, id: replyToMsgId), threadMessageId: threadMessageId))
|
||||
case .messageReplyStoryHeader:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -728,6 +734,8 @@ extension StoreMessage {
|
||||
break
|
||||
}
|
||||
attributes.append(ReplyMessageAttribute(messageId: MessageId(peerId: replyPeerId, namespace: Namespaces.Message.Cloud, id: replyToMsgId), threadMessageId: threadMessageId))
|
||||
case .messageReplyStoryHeader:
|
||||
break
|
||||
}
|
||||
} else {
|
||||
switch action {
|
||||
|
@ -659,13 +659,13 @@ final class MediaReferenceRevalidationContext {
|
||||
}
|
||||
}
|
||||
|
||||
func story(accountPeerId: PeerId, postbox: Postbox, network: Network, background: Bool, peer: PeerReference, id: Int32) -> Signal<StoryListContext.Item, RevalidateMediaReferenceError> {
|
||||
func story(accountPeerId: PeerId, postbox: Postbox, network: Network, background: Bool, peer: PeerReference, id: Int32) -> Signal<Stories.StoredItem, RevalidateMediaReferenceError> {
|
||||
return self.genericItem(key: .story(peer: peer, id: id), background: background, request: { next, error in
|
||||
return (_internal_getStoryById(accountPeerId: accountPeerId, postbox: postbox, network: network, peer: peer, id: id)
|
||||
return (_internal_getStoriesById(accountPeerId: accountPeerId, postbox: postbox, network: network, peer: peer, ids: [id])
|
||||
|> castError(RevalidateMediaReferenceError.self)
|
||||
|> mapToSignal { result -> Signal<StoryListContext.Item, RevalidateMediaReferenceError> in
|
||||
if let result = result {
|
||||
return .single(result)
|
||||
|> mapToSignal { result -> Signal<Stories.StoredItem, RevalidateMediaReferenceError> in
|
||||
if let item = result.first {
|
||||
return .single(item)
|
||||
} else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
@ -675,8 +675,8 @@ final class MediaReferenceRevalidationContext {
|
||||
error(.generic)
|
||||
})
|
||||
})
|
||||
|> mapToSignal { next -> Signal<StoryListContext.Item, RevalidateMediaReferenceError> in
|
||||
if let next = next as? StoryListContext.Item {
|
||||
|> mapToSignal { next -> Signal<Stories.StoredItem, RevalidateMediaReferenceError> in
|
||||
if let next = next as? Stories.StoredItem {
|
||||
return .single(next)
|
||||
} else {
|
||||
return .fail(.generic)
|
||||
@ -834,10 +834,14 @@ func revalidateMediaResourceReference(accountPeerId: PeerId, postbox: Postbox, n
|
||||
case let .story(peer, id, _):
|
||||
return revalidationContext.story(accountPeerId: accountPeerId, postbox: postbox, network: network, background: info.preferBackgroundReferenceRevalidation, peer: peer, id: id)
|
||||
|> mapToSignal { storyItem -> Signal<RevalidatedMediaResource, RevalidateMediaReferenceError> in
|
||||
if let updatedResource = findUpdatedMediaResource(media: storyItem.media._asMedia(), previousMedia: nil, resource: resource) {
|
||||
return .single(RevalidatedMediaResource(updatedResource: updatedResource, updatedReference: nil))
|
||||
guard case let .item(item) = storyItem, let media = item.media else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
if let updatedResource = findUpdatedMediaResource(media: media, previousMedia: nil, resource: resource) {
|
||||
return .single(RevalidatedMediaResource(updatedResource: updatedResource, updatedReference: nil))
|
||||
} else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
return .fail(.generic)
|
||||
}
|
||||
case let .standalone(media):
|
||||
if let file = media as? TelegramMediaFile {
|
||||
|
@ -104,9 +104,6 @@ private func sendMessageContent(account: Account, peerId: PeerId, attributes: [M
|
||||
}
|
||||
}
|
||||
|
||||
if let _ = replyMessageId {
|
||||
flags |= Int32(1 << 0)
|
||||
}
|
||||
if let _ = messageEntities {
|
||||
flags |= Int32(1 << 3)
|
||||
}
|
||||
@ -120,12 +117,28 @@ private func sendMessageContent(account: Account, peerId: PeerId, attributes: [M
|
||||
let sendMessageRequest: Signal<Api.Updates, NoError>
|
||||
switch content {
|
||||
case let .text(text):
|
||||
sendMessageRequest = account.network.request(Api.functions.messages.sendMessage(flags: flags, peer: inputPeer, replyToMsgId: replyMessageId, topMsgId: nil, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer))
|
||||
var replyTo: Api.InputReplyTo?
|
||||
if let replyMessageId = replyMessageId {
|
||||
flags |= 1 << 0
|
||||
|
||||
let replyFlags: Int32 = 0
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil)
|
||||
}
|
||||
|
||||
sendMessageRequest = account.network.request(Api.functions.messages.sendMessage(flags: flags, peer: inputPeer, replyTo: replyTo, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer))
|
||||
|> `catch` { _ -> Signal<Api.Updates, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
case let .media(inputMedia, text):
|
||||
sendMessageRequest = account.network.request(Api.functions.messages.sendMedia(flags: flags, peer: inputPeer, replyToMsgId: replyMessageId, topMsgId: nil, media: inputMedia, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer))
|
||||
var replyTo: Api.InputReplyTo?
|
||||
if let replyMessageId = replyMessageId {
|
||||
flags |= 1 << 0
|
||||
|
||||
let replyFlags: Int32 = 0
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil)
|
||||
}
|
||||
|
||||
sendMessageRequest = account.network.request(Api.functions.messages.sendMedia(flags: flags, peer: inputPeer, replyTo: replyTo, media: inputMedia, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer))
|
||||
|> `catch` { _ -> Signal<Api.Updates, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|
@ -4377,7 +4377,7 @@ func replayFinalState(
|
||||
)))
|
||||
|
||||
for storyItem in stories {
|
||||
if let parsedItem = _internal_parseApiStoryItem(transaction: transaction, peerId: peerId, apiStory: storyItem) {
|
||||
if let parsedItem = Stories.StoredItem(apiStoryItem: storyItem, peerId: peerId, transaction: transaction) {
|
||||
storyUpdates.append(InternalStoryUpdate.added(peerId: peerId, item: parsedItem))
|
||||
} else {
|
||||
storyUpdates.append(InternalStoryUpdate.deleted(peerId: peerId, id: storyItem.id))
|
||||
@ -4385,6 +4385,20 @@ func replayFinalState(
|
||||
}
|
||||
}
|
||||
case let .UpdateReadStories(peerId, maxId):
|
||||
var appliedMaxReadId = maxId
|
||||
if let currentState = transaction.getPeerStoryState(peerId: peerId)?.get(Stories.PeerState.self) {
|
||||
appliedMaxReadId = max(appliedMaxReadId, currentState.maxReadId)
|
||||
}
|
||||
|
||||
var subscriptionsOpaqueState: String?
|
||||
if let state = transaction.getSubscriptionsStoriesState()?.get(Stories.SubscriptionsState.self) {
|
||||
subscriptionsOpaqueState = state.opaqueState
|
||||
}
|
||||
transaction.setPeerStoryState(peerId: peerId, state: CodableEntry(Stories.PeerState(
|
||||
subscriptionsOpaqueState: subscriptionsOpaqueState,
|
||||
maxReadId: appliedMaxReadId
|
||||
)))
|
||||
|
||||
storyUpdates.append(InternalStoryUpdate.read(peerId: peerId, maxId: maxId))
|
||||
}
|
||||
}
|
||||
|
@ -855,9 +855,6 @@ public final class PendingMessageManager {
|
||||
}
|
||||
} else {
|
||||
flags |= (1 << 7)
|
||||
if let _ = replyMessageId {
|
||||
flags |= Int32(1 << 0)
|
||||
}
|
||||
|
||||
var sendAsInputPeer: Api.InputPeer?
|
||||
if let sendAsPeerId = sendAsPeerId, let sendAsPeer = transaction.getPeer(sendAsPeerId), let inputPeer = apiInputPeerOrSelf(sendAsPeer, accountPeerId: accountPeerId) {
|
||||
@ -913,7 +910,18 @@ public final class PendingMessageManager {
|
||||
topMsgId = Int32(clamping: threadId)
|
||||
}
|
||||
|
||||
sendMessageRequest = network.request(Api.functions.messages.sendMultiMedia(flags: flags, peer: inputPeer, replyToMsgId: replyMessageId, topMsgId: topMsgId, multiMedia: singleMedias, scheduleDate: scheduleTime, sendAs: sendAsInputPeer))
|
||||
var replyTo: Api.InputReplyTo?
|
||||
if let replyMessageId = replyMessageId {
|
||||
flags |= 1 << 0
|
||||
|
||||
var replyFlags: Int32 = 0
|
||||
if topMsgId != nil {
|
||||
replyFlags |= 1 << 0
|
||||
}
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId)
|
||||
}
|
||||
|
||||
sendMessageRequest = network.request(Api.functions.messages.sendMultiMedia(flags: flags, peer: inputPeer, replyTo: replyTo, multiMedia: singleMedias, scheduleDate: scheduleTime, sendAs: sendAsInputPeer))
|
||||
}
|
||||
|
||||
return sendMessageRequest
|
||||
@ -1141,25 +1149,35 @@ public final class PendingMessageManager {
|
||||
flags |= Int32(1 << 15)
|
||||
}
|
||||
|
||||
var topMsgId: Int32?
|
||||
if let threadId = message.threadId {
|
||||
flags |= Int32(1 << 9)
|
||||
topMsgId = Int32(clamping: threadId)
|
||||
var replyTo: Api.InputReplyTo?
|
||||
if let replyMessageId = replyMessageId {
|
||||
flags |= 1 << 0
|
||||
|
||||
var replyFlags: Int32 = 0
|
||||
if message.threadId != nil {
|
||||
replyFlags |= 1 << 0
|
||||
}
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)))
|
||||
}
|
||||
|
||||
sendMessageRequest = network.requestWithAdditionalInfo(Api.functions.messages.sendMessage(flags: flags, peer: inputPeer, replyToMsgId: replyMessageId, topMsgId: topMsgId, message: message.text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer), info: .acknowledgement, tag: dependencyTag)
|
||||
sendMessageRequest = network.requestWithAdditionalInfo(Api.functions.messages.sendMessage(flags: flags, peer: inputPeer, replyTo: replyTo, message: message.text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer), info: .acknowledgement, tag: dependencyTag)
|
||||
case let .media(inputMedia, text):
|
||||
if bubbleUpEmojiOrStickersets {
|
||||
flags |= Int32(1 << 15)
|
||||
}
|
||||
|
||||
var topMsgId: Int32?
|
||||
if let threadId = message.threadId {
|
||||
flags |= Int32(1 << 9)
|
||||
topMsgId = Int32(clamping: threadId)
|
||||
var replyTo: Api.InputReplyTo?
|
||||
if let replyMessageId = replyMessageId {
|
||||
flags |= 1 << 0
|
||||
|
||||
var replyFlags: Int32 = 0
|
||||
if message.threadId != nil {
|
||||
replyFlags |= 1 << 0
|
||||
}
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)))
|
||||
}
|
||||
|
||||
sendMessageRequest = network.request(Api.functions.messages.sendMedia(flags: flags, peer: inputPeer, replyToMsgId: replyMessageId, topMsgId: topMsgId, media: inputMedia, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer), tag: dependencyTag)
|
||||
sendMessageRequest = network.request(Api.functions.messages.sendMedia(flags: flags, peer: inputPeer, replyTo: replyTo, media: inputMedia, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, sendAs: sendAsInputPeer), tag: dependencyTag)
|
||||
|> map(NetworkRequestResult.result)
|
||||
case let .forward(sourceInfo):
|
||||
var topMsgId: Int32?
|
||||
@ -1179,16 +1197,26 @@ public final class PendingMessageManager {
|
||||
flags |= Int32(1 << 11)
|
||||
}
|
||||
|
||||
var topMsgId: Int32?
|
||||
if let threadId = message.threadId {
|
||||
flags |= Int32(1 << 9)
|
||||
topMsgId = Int32(clamping: threadId)
|
||||
var replyTo: Api.InputReplyTo?
|
||||
if let replyMessageId = replyMessageId {
|
||||
flags |= 1 << 0
|
||||
|
||||
var replyFlags: Int32 = 0
|
||||
if message.threadId != nil {
|
||||
replyFlags |= 1 << 0
|
||||
}
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)))
|
||||
}
|
||||
|
||||
sendMessageRequest = network.request(Api.functions.messages.sendInlineBotResult(flags: flags, peer: inputPeer, replyToMsgId: replyMessageId, topMsgId: topMsgId, randomId: uniqueId, queryId: chatContextResult.queryId, id: chatContextResult.id, scheduleDate: scheduleTime, sendAs: sendAsInputPeer))
|
||||
sendMessageRequest = network.request(Api.functions.messages.sendInlineBotResult(flags: flags, peer: inputPeer, replyTo: replyTo, randomId: uniqueId, queryId: chatContextResult.queryId, id: chatContextResult.id, scheduleDate: scheduleTime, sendAs: sendAsInputPeer))
|
||||
|> map(NetworkRequestResult.result)
|
||||
case .messageScreenshot:
|
||||
sendMessageRequest = network.request(Api.functions.messages.sendScreenshotNotification(peer: inputPeer, replyToMsgId: replyMessageId ?? 0, randomId: uniqueId))
|
||||
var replyTo: Api.InputReplyTo
|
||||
|
||||
let replyFlags: Int32 = 0
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId ?? 0, topMsgId: nil)
|
||||
|
||||
sendMessageRequest = network.request(Api.functions.messages.sendScreenshotNotification(peer: inputPeer, replyTo: replyTo, randomId: uniqueId))
|
||||
|> map(NetworkRequestResult.result)
|
||||
case .secretMedia:
|
||||
assertionFailure()
|
||||
|
@ -63,7 +63,15 @@ public enum RequestWebViewError {
|
||||
private func keepWebViewSignal(network: Network, stateManager: AccountStateManager, flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, queryId: Int64, replyToMessageId: MessageId?, threadId: Int64?, sendAs: Api.InputPeer?) -> Signal<Never, KeepWebViewError> {
|
||||
let signal = Signal<Never, KeepWebViewError> { subscriber in
|
||||
let poll = Signal<Never, KeepWebViewError> { subscriber in
|
||||
let signal: Signal<Never, KeepWebViewError> = network.request(Api.functions.messages.prolongWebView(flags: flags, peer: peer, bot: bot, queryId: queryId, replyToMsgId: replyToMessageId?.id, topMsgId: threadId.flatMap(Int32.init(clamping:)), sendAs: sendAs))
|
||||
var replyTo: Api.InputReplyTo?
|
||||
if let replyToMessageId = replyToMessageId {
|
||||
var replyFlags: Int32 = 0
|
||||
if threadId != nil {
|
||||
replyFlags |= 1 << 0
|
||||
}
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyToMessageId.id, topMsgId: threadId.flatMap(Int32.init(clamping:)))
|
||||
}
|
||||
let signal: Signal<Never, KeepWebViewError> = network.request(Api.functions.messages.prolongWebView(flags: flags, peer: peer, bot: bot, queryId: queryId, replyTo: replyTo, sendAs: sendAs))
|
||||
|> mapError { _ -> KeepWebViewError in
|
||||
return .generic
|
||||
}
|
||||
@ -120,22 +128,25 @@ func _internal_requestWebView(postbox: Postbox, network: Network, stateManager:
|
||||
if let _ = serializedThemeParams {
|
||||
flags |= (1 << 2)
|
||||
}
|
||||
var replyToMsgId: Int32?
|
||||
if let replyToMessageId = replyToMessageId {
|
||||
flags |= (1 << 0)
|
||||
replyToMsgId = replyToMessageId.id
|
||||
}
|
||||
if let _ = payload {
|
||||
flags |= (1 << 3)
|
||||
}
|
||||
if fromMenu {
|
||||
flags |= (1 << 4)
|
||||
}
|
||||
if threadId != nil {
|
||||
flags |= (1 << 9)
|
||||
|
||||
var replyTo: Api.InputReplyTo?
|
||||
if let replyToMessageId = replyToMessageId {
|
||||
flags |= (1 << 0)
|
||||
|
||||
var replyFlags: Int32 = 0
|
||||
if threadId != nil {
|
||||
replyFlags |= 1 << 0
|
||||
}
|
||||
replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyToMessageId.id, topMsgId: threadId.flatMap(Int32.init(clamping:)))
|
||||
}
|
||||
|
||||
return network.request(Api.functions.messages.requestWebView(flags: flags, peer: inputPeer, bot: inputBot, url: url, startParam: payload, themeParams: serializedThemeParams, platform: botWebViewPlatform, replyToMsgId: replyToMsgId, topMsgId: threadId.flatMap(Int32.init(clamping:)), sendAs: nil))
|
||||
return network.request(Api.functions.messages.requestWebView(flags: flags, peer: inputPeer, bot: inputBot, url: url, startParam: payload, themeParams: serializedThemeParams, platform: botWebViewPlatform, replyTo: replyTo, sendAs: nil))
|
||||
|> mapError { _ -> RequestWebViewError in
|
||||
return .generic
|
||||
}
|
||||
|
@ -704,8 +704,12 @@ extension Api.StoryItem {
|
||||
extension Stories.Item.Views {
|
||||
init(apiViews: Api.StoryViews) {
|
||||
switch apiViews {
|
||||
case let .storyViews(recentViewers, viewsCount):
|
||||
self.init(seenCount: Int(viewsCount), seenPeerIds: recentViewers.map { PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) })
|
||||
case let .storyViews(_, viewsCount, recentViewers):
|
||||
var seenPeerIds: [PeerId] = []
|
||||
if let recentViewers = recentViewers {
|
||||
seenPeerIds = recentViewers.map { PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) }
|
||||
}
|
||||
self.init(seenCount: Int(viewsCount), seenPeerIds: seenPeerIds)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -769,69 +773,42 @@ extension Stories.StoredItem {
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_parseApiStoryItem(transaction: Transaction, peerId: PeerId, apiStory: Api.StoryItem) -> StoryListContext.Item? {
|
||||
switch apiStory {
|
||||
case let .storyItem(flags, id, date, caption, entities, media, privacy, views):
|
||||
let _ = flags
|
||||
let (parsedMedia, _, _, _) = textMediaAndExpirationTimerFromApiMedia(media, peerId)
|
||||
if let parsedMedia = parsedMedia {
|
||||
var parsedPrivacy: EngineStoryPrivacy?
|
||||
if let privacy = privacy {
|
||||
var base: EngineStoryPrivacy.Base = .everyone
|
||||
var additionalPeerIds: [EnginePeer.Id] = []
|
||||
for rule in privacy {
|
||||
switch rule {
|
||||
case .privacyValueAllowAll:
|
||||
base = .everyone
|
||||
case .privacyValueAllowContacts:
|
||||
base = .contacts
|
||||
case .privacyValueAllowCloseFriends:
|
||||
base = .closeFriends
|
||||
case let .privacyValueAllowUsers(users):
|
||||
for id in users {
|
||||
additionalPeerIds.append(EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: EnginePeer.Id.Id._internalFromInt64Value(id)))
|
||||
}
|
||||
case let .privacyValueAllowChatParticipants(chats):
|
||||
for id in chats {
|
||||
if let peer = transaction.getPeer(EnginePeer.Id(namespace: Namespaces.Peer.CloudGroup, id: EnginePeer.Id.Id._internalFromInt64Value(id))) {
|
||||
additionalPeerIds.append(peer.id)
|
||||
} else if let peer = transaction.getPeer(EnginePeer.Id(namespace: Namespaces.Peer.CloudChannel, id: EnginePeer.Id.Id._internalFromInt64Value(id))) {
|
||||
additionalPeerIds.append(peer.id)
|
||||
}
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
parsedPrivacy = EngineStoryPrivacy(base: base, additionallyIncludePeers: additionalPeerIds)
|
||||
}
|
||||
|
||||
let item = StoryListContext.Item(
|
||||
id: id,
|
||||
timestamp: date,
|
||||
media: EngineMedia(parsedMedia),
|
||||
text: caption ?? "",
|
||||
entities: entities.flatMap { entities in return messageTextEntitiesFromApiEntities(entities) } ?? [],
|
||||
views: views.flatMap { _internal_parseApiStoryViews(transaction: transaction, views: $0) },
|
||||
privacy: parsedPrivacy
|
||||
)
|
||||
return item
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case .storyItemSkipped:
|
||||
return nil
|
||||
case .storyItemDeleted:
|
||||
return nil
|
||||
func _internal_getStoriesById(accountPeerId: PeerId, postbox: Postbox, network: Network, peer: PeerReference, ids: [Int32]) -> Signal<[Stories.StoredItem], NoError> {
|
||||
guard let inputUser = peer.inputUser else {
|
||||
return .single([])
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_parseApiStoryViews(transaction: Transaction, views: Api.StoryViews) -> StoryListContext.Views {
|
||||
switch views {
|
||||
case let .storyViews(recentViewers, viewsCount):
|
||||
return StoryListContext.Views(seenCount: Int(viewsCount), seenPeers: recentViewers.compactMap { id -> EnginePeer? in
|
||||
return transaction.getPeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))).flatMap(EnginePeer.init)
|
||||
})
|
||||
|
||||
return network.request(Api.functions.stories.getStoriesByID(userId: inputUser, id: ids))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.stories.Stories?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { result -> Signal<[Stories.StoredItem], NoError> in
|
||||
guard let result = result else {
|
||||
return .single([])
|
||||
}
|
||||
return postbox.transaction { transaction -> [Stories.StoredItem] in
|
||||
switch result {
|
||||
case let .stories(_, stories, users):
|
||||
var peers: [Peer] = []
|
||||
var peerPresences: [PeerId: Api.User] = [:]
|
||||
|
||||
for user in users {
|
||||
let telegramUser = TelegramUser(user: user)
|
||||
peers.append(telegramUser)
|
||||
peerPresences[telegramUser.id] = user
|
||||
}
|
||||
|
||||
updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer in
|
||||
return updated
|
||||
})
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: peerPresences)
|
||||
|
||||
return stories.compactMap { apiStoryItem -> Stories.StoredItem? in
|
||||
return Stories.StoredItem(apiStoryItem: apiStoryItem, peerId: peer.id, transaction: transaction)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -879,42 +856,6 @@ func _internal_getStoriesById(accountPeerId: PeerId, postbox: Postbox, network:
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_getStoryById(accountPeerId: PeerId, postbox: Postbox, network: Network, peer: PeerReference, id: Int32) -> Signal<StoryListContext.Item?, NoError> {
|
||||
guard let inputUser = peer.inputUser else {
|
||||
return .single(nil)
|
||||
}
|
||||
return network.request(Api.functions.stories.getStoriesByID(userId: inputUser, id: [id]))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.stories.Stories?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { result -> Signal<StoryListContext.Item?, NoError> in
|
||||
guard let result = result else {
|
||||
return .single(nil)
|
||||
}
|
||||
return postbox.transaction { transaction -> StoryListContext.Item? in
|
||||
switch result {
|
||||
case let .stories(_, stories, users):
|
||||
var peers: [Peer] = []
|
||||
var peerPresences: [PeerId: Api.User] = [:]
|
||||
|
||||
for user in users {
|
||||
let telegramUser = TelegramUser(user: user)
|
||||
peers.append(telegramUser)
|
||||
peerPresences[telegramUser.id] = user
|
||||
}
|
||||
|
||||
updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer in
|
||||
return updated
|
||||
})
|
||||
updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: peerPresences)
|
||||
|
||||
return stories.first.flatMap { _internal_parseApiStoryItem(transaction: transaction, peerId: peer.id, apiStory: $0) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final class StoryViewList {
|
||||
public final class Item {
|
||||
public let peer: EnginePeer
|
||||
@ -978,18 +919,18 @@ func _internal_getStoryViewList(account: Account, id: Int32, offsetTimestamp: In
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_getStoryViews(account: Account, ids: [Int32]) -> Signal<[Int32: StoryListContext.Views], NoError> {
|
||||
func _internal_getStoryViews(account: Account, ids: [Int32]) -> Signal<[Int32: Stories.Item.Views], NoError> {
|
||||
return account.network.request(Api.functions.stories.getStoriesViews(id: ids))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.stories.StoryViews?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { result -> Signal<[Int32: StoryListContext.Views], NoError> in
|
||||
|> mapToSignal { result -> Signal<[Int32: Stories.Item.Views], NoError> in
|
||||
guard let result = result else {
|
||||
return .single([:])
|
||||
}
|
||||
return account.postbox.transaction { transaction -> [Int32: StoryListContext.Views] in
|
||||
var parsedViews: [Int32: StoryListContext.Views] = [:]
|
||||
return account.postbox.transaction { transaction -> [Int32: Stories.Item.Views] in
|
||||
var parsedViews: [Int32: Stories.Item.Views] = [:]
|
||||
switch result {
|
||||
case let .storyViews(views, users):
|
||||
var peers: [Peer] = []
|
||||
@ -1008,7 +949,7 @@ func _internal_getStoryViews(account: Account, ids: [Int32]) -> Signal<[Int32: S
|
||||
|
||||
for i in 0 ..< views.count {
|
||||
if i < ids.count {
|
||||
parsedViews[ids[i]] = _internal_parseApiStoryViews(transaction: transaction, views: views[i])
|
||||
parsedViews[ids[i]] = Stories.Item.Views(apiViews: views[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -774,7 +774,7 @@ public extension TelegramEngine {
|
||||
let resource = MediaResourceReference.media(media: .story(peer: peerReference, id: item.id, media: file), resource: file.resource)
|
||||
resultResources[EngineMediaResource.Id(resource.resource.id)] = StoryPreloadInfo(
|
||||
resource: resource,
|
||||
size: nil,
|
||||
size: file.preloadSize,
|
||||
priority: .top(position: nextPriority)
|
||||
)
|
||||
nextPriority += 1
|
||||
@ -788,10 +788,6 @@ public extension TelegramEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public func peerStoryFocusContext(id: EnginePeer.Id, focusItemId: Int32?) -> PeerStoryFocusContext {
|
||||
return PeerStoryFocusContext(account: self.account, peerId: id, focusItemId: focusItemId)
|
||||
}
|
||||
|
||||
public func refreshStories(peerId: EnginePeer.Id, ids: [Int32]) -> Signal<Never, NoError> {
|
||||
return _internal_getStoriesById(accountPeerId: self.account.peerId, postbox: self.account.postbox, network: self.account.network, peerId: peerId, ids: ids)
|
||||
|> mapToSignal { result -> Signal<Never, NoError> in
|
||||
@ -812,10 +808,6 @@ public extension TelegramEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public func peerStories(id: EnginePeer.Id) -> StoryListContext {
|
||||
return StoryListContext(account: self.account, scope: .peer(id))
|
||||
}
|
||||
|
||||
public func uploadStory(media: EngineStoryInputMedia, text: String, entities: [MessageTextEntity], privacy: EngineStoryPrivacy) -> Signal<Never, NoError> {
|
||||
return _internal_uploadStory(account: self.account, media: media, text: text, entities: entities, privacy: privacy)
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ private final class VisualMediaItem: SparseItemGrid.Item {
|
||||
}
|
||||
let localMonthTimestamp: Int32
|
||||
let peer: PeerReference
|
||||
let story: StoryListContext.Item
|
||||
let story: EngineStoryItem
|
||||
|
||||
override var id: AnyHashable {
|
||||
return AnyHashable(self.story.id)
|
||||
@ -95,7 +95,7 @@ private final class VisualMediaItem: SparseItemGrid.Item {
|
||||
return VisualMediaHoleAnchor(index: self.index, storyId: self.story.id, localMonthTimestamp: self.localMonthTimestamp)
|
||||
}
|
||||
|
||||
init(index: Int, peer: PeerReference, story: StoryListContext.Item, localMonthTimestamp: Int32) {
|
||||
init(index: Int, peer: PeerReference, story: EngineStoryItem, localMonthTimestamp: Int32) {
|
||||
self.indexValue = index
|
||||
self.peer = peer
|
||||
self.story = story
|
||||
@ -738,7 +738,7 @@ private final class SparseItemGridBindingImpl: SparseItemGridBinding {
|
||||
}
|
||||
}
|
||||
|
||||
public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
|
||||
/*public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
|
||||
public enum ContentType {
|
||||
case photoOrVideo
|
||||
case photo
|
||||
@ -815,7 +815,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
||||
private var animationTimer: SwiftSignalKit.Timer?
|
||||
|
||||
public private(set) var calendarSource: SparseMessageCalendar?
|
||||
private var listSource: StoryListContext
|
||||
private var listSource: StorySubscriptionsContext
|
||||
|
||||
public var openCurrentDate: (() -> Void)?
|
||||
public var paneDidScroll: (() -> Void)?
|
||||
@ -848,7 +848,6 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
|
||||
captureProtected: captureProtected
|
||||
)
|
||||
|
||||
self.listSource = context.engine.messages.peerStories(id: self.peerId)
|
||||
//self.listSource = context.engine.messages.allStories()
|
||||
self.calendarSource = nil
|
||||
|
||||
@ -1934,3 +1933,4 @@ private class MediaListSelectionRecognizer: UIPanGestureRecognizer {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -45,7 +45,7 @@ public final class StoryContentItem {
|
||||
public let centerInfoComponent: AnyComponent<Empty>?
|
||||
public let rightInfoComponent: AnyComponent<Empty>?
|
||||
public let peerId: EnginePeer.Id?
|
||||
public let storyItem: StoryListContext.Item
|
||||
public let storyItem: EngineStoryItem
|
||||
public let preload: Signal<Never, NoError>?
|
||||
public let delete: (() -> Void)?
|
||||
public let markAsSeen: (() -> Void)?
|
||||
@ -59,7 +59,7 @@ public final class StoryContentItem {
|
||||
centerInfoComponent: AnyComponent<Empty>?,
|
||||
rightInfoComponent: AnyComponent<Empty>?,
|
||||
peerId: EnginePeer.Id?,
|
||||
storyItem: StoryListContext.Item,
|
||||
storyItem: EngineStoryItem,
|
||||
preload: Signal<Never, NoError>?,
|
||||
delete: (() -> Void)?,
|
||||
markAsSeen: (() -> Void)?,
|
||||
|
@ -112,7 +112,7 @@ public final class StoryContentContextImpl: StoryContentContext {
|
||||
}
|
||||
|
||||
if let item = itemsView.items[focusedIndex].value.get(Stories.StoredItem.self), case let .item(item) = item, let media = item.media {
|
||||
let mappedItem = StoryListContext.Item(
|
||||
let mappedItem = EngineStoryItem(
|
||||
id: item.id,
|
||||
timestamp: item.timestamp,
|
||||
media: EngineMedia(media),
|
||||
@ -507,198 +507,3 @@ public final class StoryContentContextImpl: StoryContentContext {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum StoryChatContent {
|
||||
public static func peerStories(context: AccountContext, peerId: EnginePeer.Id, focusItem: Int32?) -> Signal<[StoryContentItemSlice], NoError> {
|
||||
let focusContext = context.engine.messages.peerStoryFocusContext(id: peerId, focusItemId: focusItem)
|
||||
return combineLatest(
|
||||
context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)),
|
||||
focusContext.state
|
||||
)
|
||||
|> mapToSignal { peer, state -> Signal<[StoryContentItemSlice], NoError> in
|
||||
let _ = focusContext
|
||||
|
||||
if let peer, let item = state.item, let media = item.media {
|
||||
let mappedItem = StoryListContext.Item(
|
||||
id: item.id,
|
||||
timestamp: item.timestamp,
|
||||
media: EngineMedia(media),
|
||||
text: item.text,
|
||||
entities: item.entities,
|
||||
views: nil,
|
||||
privacy: nil
|
||||
)
|
||||
|
||||
let slice = StoryContentItemSlice(
|
||||
id: AnyHashable(peerId),
|
||||
focusedItemId: AnyHashable(item.id),
|
||||
items: [
|
||||
StoryContentItem(
|
||||
id: AnyHashable(item.id),
|
||||
position: state.position,
|
||||
component: AnyComponent(StoryItemContentComponent(
|
||||
context: context,
|
||||
peer: peer,
|
||||
item: mappedItem
|
||||
)),
|
||||
centerInfoComponent: AnyComponent(StoryAuthorInfoComponent(
|
||||
context: context,
|
||||
peer: peer,
|
||||
timestamp: item.timestamp
|
||||
)),
|
||||
rightInfoComponent: AnyComponent(StoryAvatarInfoComponent(
|
||||
context: context,
|
||||
peer: peer
|
||||
)),
|
||||
peerId: peer.id,
|
||||
storyItem: mappedItem,
|
||||
preload: nil,
|
||||
delete: { [weak context] in
|
||||
guard let context else {
|
||||
return
|
||||
}
|
||||
let _ = context
|
||||
},
|
||||
markAsSeen: { [weak context] in
|
||||
guard let context else {
|
||||
return
|
||||
}
|
||||
let _ = context.engine.messages.markStoryAsSeen(peerId: peerId, id: item.id).start()
|
||||
},
|
||||
hasLike: false,
|
||||
isMy: peerId == context.account.peerId
|
||||
)
|
||||
],
|
||||
totalCount: state.count,
|
||||
previousItemId: state.previousId,
|
||||
nextItemId: state.nextId,
|
||||
update: { requestedItemSet, itemId in
|
||||
var focusItem: Int32?
|
||||
if let id = itemId.base as? Int32 {
|
||||
focusItem = id
|
||||
}
|
||||
|
||||
return StoryChatContent.peerStories(context: context, peerId: peerId, focusItem: focusItem)
|
||||
|> mapToSignal { result in
|
||||
if let first = result.first {
|
||||
return .single(first)
|
||||
} else {
|
||||
return .never()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
return .single([slice])
|
||||
} else {
|
||||
return .single([])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static func subscriptionsStories(context: AccountContext, peerId: EnginePeer.Id?) -> Signal<[StoryContentItemSlice], NoError> {
|
||||
return context.engine.messages.storySubscriptions()
|
||||
|> mapToSignal { subscriptions -> Signal<[StoryContentItemSlice], NoError> in
|
||||
var signals: [Signal<[StoryContentItemSlice], NoError>] = []
|
||||
for item in subscriptions.items {
|
||||
signals.append(peerStories(context: context, peerId: item.peer.id, focusItem: nil))
|
||||
}
|
||||
return combineLatest(queue: .mainQueue(), signals)
|
||||
|> map { peerItems -> [StoryContentItemSlice] in
|
||||
var result: [StoryContentItemSlice] = []
|
||||
|
||||
for item in peerItems {
|
||||
result.append(contentsOf: item)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static func stories(context: AccountContext, storyList: StoryListContext, focusItem: Int32?) -> Signal<[StoryContentItemSlice], NoError> {
|
||||
return storyList.state
|
||||
|> map { state -> [StoryContentItemSlice] in
|
||||
var itemSlices: [StoryContentItemSlice] = []
|
||||
|
||||
for itemSet in state.itemSets {
|
||||
var items: [StoryContentItem] = []
|
||||
|
||||
guard let peer = itemSet.peer else {
|
||||
continue
|
||||
}
|
||||
let peerId = itemSet.peerId
|
||||
|
||||
for item in itemSet.items {
|
||||
items.append(StoryContentItem(
|
||||
id: AnyHashable(item.id),
|
||||
position: items.count,
|
||||
component: AnyComponent(StoryItemContentComponent(
|
||||
context: context,
|
||||
peer: peer,
|
||||
item: item
|
||||
)),
|
||||
centerInfoComponent: AnyComponent(StoryAuthorInfoComponent(
|
||||
context: context,
|
||||
peer: itemSet.peer,
|
||||
timestamp: item.timestamp
|
||||
)),
|
||||
rightInfoComponent: itemSet.peer.flatMap { author -> AnyComponent<Empty> in
|
||||
return AnyComponent(StoryAvatarInfoComponent(
|
||||
context: context,
|
||||
peer: author
|
||||
))
|
||||
},
|
||||
peerId: itemSet.peerId,
|
||||
storyItem: item,
|
||||
preload: nil,
|
||||
delete: { [weak storyList] in
|
||||
storyList?.delete(id: item.id)
|
||||
},
|
||||
markAsSeen: { [weak context] in
|
||||
guard let context else {
|
||||
return
|
||||
}
|
||||
let _ = context.engine.messages.markStoryAsSeen(peerId: peerId, id: item.id).start()
|
||||
},
|
||||
hasLike: false,
|
||||
isMy: itemSet.peerId == context.account.peerId
|
||||
))
|
||||
}
|
||||
|
||||
var sliceFocusedItemId: AnyHashable?
|
||||
if let focusItem, items.contains(where: { ($0.id.base as? Int32) == focusItem }) {
|
||||
sliceFocusedItemId = AnyHashable(focusItem)
|
||||
} else {
|
||||
if let id = itemSet.items.first(where: { $0.id > itemSet.maxReadId })?.id {
|
||||
sliceFocusedItemId = AnyHashable(id)
|
||||
}
|
||||
}
|
||||
|
||||
itemSlices.append(StoryContentItemSlice(
|
||||
id: AnyHashable(itemSet.peerId),
|
||||
focusedItemId: sliceFocusedItemId,
|
||||
items: items,
|
||||
totalCount: items.count,
|
||||
previousItemId: nil,
|
||||
nextItemId: nil,
|
||||
update: { requestedItemSet, itemId in
|
||||
var focusItem: Int32?
|
||||
if let id = itemId.base as? Int32 {
|
||||
focusItem = id
|
||||
}
|
||||
return StoryChatContent.stories(context: context, storyList: storyList, focusItem: focusItem)
|
||||
|> mapToSignal { result -> Signal<StoryContentItemSlice, NoError> in
|
||||
if let foundItemSet = result.first(where: { $0.id == requestedItemSet.id }) {
|
||||
return .single(foundItemSet)
|
||||
} else {
|
||||
return .never()
|
||||
}
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
return itemSlices
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ final class StoryItemContentComponent: Component {
|
||||
|
||||
let context: AccountContext
|
||||
let peer: EnginePeer
|
||||
let item: StoryListContext.Item
|
||||
let item: EngineStoryItem
|
||||
|
||||
init(context: AccountContext, peer: EnginePeer, item: StoryListContext.Item) {
|
||||
init(context: AccountContext, peer: EnginePeer, item: EngineStoryItem) {
|
||||
self.context = context
|
||||
self.peer = peer
|
||||
self.item = item
|
||||
|
@ -11,13 +11,13 @@ import TelegramCore
|
||||
|
||||
public final class StoryFooterPanelComponent: Component {
|
||||
public let context: AccountContext
|
||||
public let storyItem: StoryListContext.Item?
|
||||
public let storyItem: EngineStoryItem?
|
||||
public let deleteAction: () -> Void
|
||||
public let moreAction: (UIView, ContextGesture?) -> Void
|
||||
|
||||
public init(
|
||||
context: AccountContext,
|
||||
storyItem: StoryListContext.Item?,
|
||||
storyItem: EngineStoryItem?,
|
||||
deleteAction: @escaping () -> Void,
|
||||
moreAction: @escaping (UIView, ContextGesture?) -> Void
|
||||
) {
|
||||
|
@ -368,7 +368,8 @@ private final class PeerInfoPendingPane {
|
||||
let paneNode: PeerInfoPaneNode
|
||||
switch key {
|
||||
case .stories:
|
||||
let visualPaneNode = PeerInfoStoryPaneNode(context: context, chatControllerInteraction: chatControllerInteraction, peerId: peerId, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, contentType: .photoOrVideo, captureProtected: captureProtected)
|
||||
//let visualPaneNode = PeerInfoStoryPaneNode(context: context, chatControllerInteraction: chatControllerInteraction, peerId: peerId, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, contentType: .photoOrVideo, captureProtected: captureProtected)
|
||||
let visualPaneNode = PeerInfoVisualMediaPaneNode(context: context, chatControllerInteraction: chatControllerInteraction, peerId: peerId, chatLocation: chatLocation, chatLocationContextHolder: chatLocationContextHolder, contentType: .photoOrVideo, captureProtected: captureProtected)
|
||||
paneNode = visualPaneNode
|
||||
visualPaneNode.openCurrentDate = {
|
||||
openMediaCalendar()
|
||||
|
@ -367,7 +367,6 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
|
||||
switch mediaResult {
|
||||
case let .image(image, dimensions, caption):
|
||||
if let imageData = compressImageToJPEG(image, quality: 0.6) {
|
||||
//storyListContext.upload(media: .image(dimensions: dimensions, data: imageData), text: caption?.string ?? "", entities: [], privacy: privacy)
|
||||
let _ = self.context.engine.messages.uploadStory(media: .image(dimensions: dimensions, data: imageData), text: caption?.string ?? "", entities: [], privacy: privacy).start()
|
||||
Queue.mainQueue().after(0.2, { [weak chatListController] in
|
||||
chatListController?.animateStoryUploadRipple()
|
||||
|
Loading…
x
Reference in New Issue
Block a user