Story API update

This commit is contained in:
Ali 2023-08-25 20:41:36 +04:00
parent 89bddb319a
commit 961fb14d94
45 changed files with 11102 additions and 10739 deletions

View File

@ -795,7 +795,7 @@ public struct StoryCameraTransitionInCoordinator {
public protocol TelegramRootControllerInterface: NavigationController {
@discardableResult
func openStoryCamera(transitionIn: StoryCameraTransitionIn?, transitionedIn: @escaping () -> Void, transitionOut: @escaping (Bool) -> StoryCameraTransitionOut?) -> StoryCameraTransitionInCoordinator?
func openStoryCamera(transitionIn: StoryCameraTransitionIn?, transitionedIn: @escaping () -> Void, transitionOut: @escaping (Stories.PendingTarget?) -> StoryCameraTransitionOut?) -> StoryCameraTransitionInCoordinator?
func getContactsController() -> ViewController?
func getChatsController() -> ViewController?

View File

@ -458,7 +458,7 @@ public class AnimatedCountLabelView: UIView {
fromAlpha = CGFloat(presentation.opacity)
}
var offsetY: CGFloat
if currentValue > updatedValue || alwaysOneDirection {
if currentValue < updatedValue || alwaysOneDirection {
offsetY = -floor(currentTextNode.bounds.height * 0.6)
} else {
offsetY = floor(currentTextNode.bounds.height * 0.6)

View File

@ -2687,12 +2687,20 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
if let rootController = self.context.sharedContext.mainWindow?.viewController as? TelegramRootControllerInterface {
let coordinator = rootController.openStoryCamera(transitionIn: cameraTransitionIn, transitionedIn: {}, transitionOut: { [weak self] _ in
guard let self else {
let coordinator = rootController.openStoryCamera(transitionIn: cameraTransitionIn, transitionedIn: {}, transitionOut: { [weak self] target in
guard let self, let target else {
return nil
}
if let componentView = self.chatListHeaderView() {
if let (transitionView, _) = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
let peerId: EnginePeer.Id
switch target {
case .myStories:
peerId = self.context.account.peerId
case let .peer(id):
peerId = id
}
if let (transitionView, _) = componentView.storyPeerListView()?.transitionViewForItem(peerId: peerId) {
return StoryCameraTransitionOut(
destinationView: transitionView,
destinationRect: transitionView.bounds,
@ -2985,9 +2993,11 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
}
}
private(set) var storyUploadProgress: Float?
private func updateStoryUploadProgress(_ progress: Float?) {
self.storyUploadProgress = progress.flatMap { max(0.027, min(0.99, $0)) }
private(set) var storyUploadProgress: [PeerId: Float] = [:]
private func updateStoryUploadProgress(_ progress: [PeerId: Float]) {
self.storyUploadProgress = progress.mapValues {
max(0.027, min(0.99, $0))
}
if let navigationBarView = self.chatListDisplayNode.navigationBarView.view as? ChatListNavigationBar.View {
navigationBarView.updateStoryUploadProgress(storyUploadProgress: self.storyUploadProgress)
@ -5578,12 +5588,20 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
if let current = self.storyCameraTransitionInCoordinator {
coordinator = current
} else {
coordinator = rootController.openStoryCamera(transitionIn: nil, transitionedIn: {}, transitionOut: { [weak self] finished in
guard let self else {
coordinator = rootController.openStoryCamera(transitionIn: nil, transitionedIn: {}, transitionOut: { [weak self] target in
guard let self, let target else {
return nil
}
if finished, let componentView = self.chatListHeaderView() {
if let (transitionView, _) = componentView.storyPeerListView()?.transitionViewForItem(peerId: self.context.account.peerId) {
if let componentView = self.chatListHeaderView() {
let peerId: EnginePeer.Id
switch target {
case .myStories:
peerId = self.context.account.peerId
case let .peer(id):
peerId = id
}
if let (transitionView, _) = componentView.storyPeerListView()?.transitionViewForItem(peerId: peerId) {
return StoryCameraTransitionOut(
destinationView: transitionView,
destinationRect: transitionView.bounds,

View File

@ -2042,7 +2042,7 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
secondaryTransition: self.inlineStackContainerTransitionFraction,
storySubscriptions: effectiveStorySubscriptions,
storiesIncludeHidden: self.location == .chatList(groupId: .archive),
uploadProgress: self.controller?.storyUploadProgress,
uploadProgress: self.controller?.storyUploadProgress ?? [:],
tabsNode: tabsNode,
tabsNodeIsSearch: tabsNodeIsSearch,
accessoryPanelContainer: self.controller?.accessoryPanelContainer,

View File

@ -342,7 +342,7 @@ final class ContactsControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
secondaryTransition: 0.0,
storySubscriptions: nil,
storiesIncludeHidden: true,
uploadProgress: nil,
uploadProgress: [:],
tabsNode: tabsNode,
tabsNodeIsSearch: tabsNodeIsSearch,
accessoryPanelContainer: nil,

View File

@ -337,7 +337,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1279654347] = { return Api.InputMedia.parse_inputMediaPhoto($0) }
dict[-440664550] = { return Api.InputMedia.parse_inputMediaPhotoExternal($0) }
dict[261416433] = { return Api.InputMedia.parse_inputMediaPoll($0) }
dict[-1702447729] = { return Api.InputMedia.parse_inputMediaStory($0) }
dict[-1979852936] = { return Api.InputMedia.parse_inputMediaStory($0) }
dict[1530447553] = { return Api.InputMedia.parse_inputMediaUploadedDocument($0) }
dict[505969924] = { return Api.InputMedia.parse_inputMediaUploadedPhoto($0) }
dict[-1052959727] = { return Api.InputMedia.parse_inputMediaVenue($0) }
@ -533,7 +533,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-156940077] = { return Api.MessageMedia.parse_messageMediaInvoice($0) }
dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) }
dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) }
dict[-877523576] = { return Api.MessageMedia.parse_messageMediaStory($0) }
dict[1758159491] = { return Api.MessageMedia.parse_messageMediaStory($0) }
dict[-1618676578] = { return Api.MessageMedia.parse_messageMediaUnsupported($0) }
dict[784356159] = { return Api.MessageMedia.parse_messageMediaVenue($0) }
dict[-1557277184] = { return Api.MessageMedia.parse_messageMediaWebPage($0) }
@ -626,6 +626,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-118740917] = { return Api.PeerLocated.parse_peerSelfLocated($0) }
dict[-1721619444] = { return Api.PeerNotifySettings.parse_peerNotifySettings($0) }
dict[-1525149427] = { return Api.PeerSettings.parse_peerSettings($0) }
dict[-1707742823] = { return Api.PeerStories.parse_peerStories($0) }
dict[-1770029977] = { return Api.PhoneCall.parse_phoneCall($0) }
dict[912311057] = { return Api.PhoneCall.parse_phoneCallAccepted($0) }
dict[1355435489] = { return Api.PhoneCall.parse_phoneCallDiscarded($0) }
@ -910,18 +911,18 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1667805217] = { return Api.Update.parse_updateReadHistoryInbox($0) }
dict[791617983] = { return Api.Update.parse_updateReadHistoryOutbox($0) }
dict[1757493555] = { return Api.Update.parse_updateReadMessagesContents($0) }
dict[-21679014] = { return Api.Update.parse_updateReadStories($0) }
dict[-145845461] = { return Api.Update.parse_updateReadStories($0) }
dict[821314523] = { return Api.Update.parse_updateRecentEmojiStatuses($0) }
dict[1870160884] = { return Api.Update.parse_updateRecentReactions($0) }
dict[-1706939360] = { return Api.Update.parse_updateRecentStickers($0) }
dict[-1821035490] = { return Api.Update.parse_updateSavedGifs($0) }
dict[1960361625] = { return Api.Update.parse_updateSavedRingtones($0) }
dict[-475579104] = { return Api.Update.parse_updateSentStoryReaction($0) }
dict[2103604867] = { return Api.Update.parse_updateSentStoryReaction($0) }
dict[-337352679] = { return Api.Update.parse_updateServiceNotification($0) }
dict[834816008] = { return Api.Update.parse_updateStickerSets($0) }
dict[196268545] = { return Api.Update.parse_updateStickerSetsOrder($0) }
dict[738741697] = { return Api.Update.parse_updateStoriesStealthMode($0) }
dict[542785843] = { return Api.Update.parse_updateStory($0) }
dict[1974712216] = { return Api.Update.parse_updateStory($0) }
dict[468923833] = { return Api.Update.parse_updateStoryID($0) }
dict[-2112423005] = { return Api.Update.parse_updateTheme($0) }
dict[8703322] = { return Api.Update.parse_updateTranscribedAudio($0) }
@ -945,7 +946,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1831650802] = { return Api.UrlAuthResult.parse_urlAuthResultRequest($0) }
dict[-1414139616] = { return Api.User.parse_user($0) }
dict[-742634630] = { return Api.User.parse_userEmpty($0) }
dict[1340198022] = { return Api.UserFull.parse_userFull($0) }
dict[-1179571092] = { return Api.UserFull.parse_userFull($0) }
dict[-2100168954] = { return Api.UserProfilePhoto.parse_userProfilePhoto($0) }
dict[1326562017] = { return Api.UserProfilePhoto.parse_userProfilePhotoEmpty($0) }
dict[164646985] = { return Api.UserStatus.parse_userStatusEmpty($0) }
@ -954,7 +955,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[9203775] = { return Api.UserStatus.parse_userStatusOffline($0) }
dict[-306628279] = { return Api.UserStatus.parse_userStatusOnline($0) }
dict[-496024847] = { return Api.UserStatus.parse_userStatusRecently($0) }
dict[-2045664768] = { return Api.UserStories.parse_userStories($0) }
dict[-1274595769] = { return Api.Username.parse_username($0) }
dict[-567037804] = { return Api.VideoSize.parse_videoSize($0) }
dict[-128171716] = { return Api.VideoSize.parse_videoSizeEmojiMarkup($0) }
@ -969,7 +969,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-350980120] = { return Api.WebPage.parse_webPageEmpty($0) }
dict[1930545681] = { return Api.WebPage.parse_webPageNotModified($0) }
dict[-981018084] = { return Api.WebPage.parse_webPagePending($0) }
dict[-1818605967] = { return Api.WebPageAttribute.parse_webPageAttributeStory($0) }
dict[781501415] = { return Api.WebPageAttribute.parse_webPageAttributeStory($0) }
dict[1421174295] = { return Api.WebPageAttribute.parse_webPageAttributeTheme($0) }
dict[211046684] = { return Api.WebViewMessageSent.parse_webViewMessageSent($0) }
dict[202659196] = { return Api.WebViewResult.parse_webViewResultUrl($0) }
@ -1172,12 +1172,12 @@ 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[1369278878] = { return Api.stories.AllStories.parse_allStories($0) }
dict[1862033025] = { return Api.stories.AllStories.parse_allStories($0) }
dict[291044926] = { return Api.stories.AllStories.parse_allStoriesNotModified($0) }
dict[1340440049] = { return Api.stories.Stories.parse_stories($0) }
dict[-890861720] = { return Api.stories.PeerStories.parse_peerStories($0) }
dict[1574486984] = { return Api.stories.Stories.parse_stories($0) }
dict[-560009955] = { return Api.stories.StoryViews.parse_storyViews($0) }
dict[1189722604] = { return Api.stories.StoryViewsList.parse_storyViewsList($0) }
dict[933691231] = { return Api.stories.UserStories.parse_userStories($0) }
dict[543450958] = { return Api.updates.ChannelDifference.parse_channelDifference($0) }
dict[1041346555] = { return Api.updates.ChannelDifference.parse_channelDifferenceEmpty($0) }
dict[-1531132162] = { return Api.updates.ChannelDifference.parse_channelDifferenceTooLong($0) }
@ -1623,6 +1623,8 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.PeerSettings:
_1.serialize(buffer, boxed)
case let _1 as Api.PeerStories:
_1.serialize(buffer, boxed)
case let _1 as Api.PhoneCall:
_1.serialize(buffer, boxed)
case let _1 as Api.PhoneCallDiscardReason:
@ -1773,8 +1775,6 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.UserStatus:
_1.serialize(buffer, boxed)
case let _1 as Api.UserStories:
_1.serialize(buffer, boxed)
case let _1 as Api.Username:
_1.serialize(buffer, boxed)
case let _1 as Api.VideoSize:
@ -2053,14 +2053,14 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.stories.AllStories:
_1.serialize(buffer, boxed)
case let _1 as Api.stories.PeerStories:
_1.serialize(buffer, boxed)
case let _1 as Api.stories.Stories:
_1.serialize(buffer, boxed)
case let _1 as Api.stories.StoryViews:
_1.serialize(buffer, boxed)
case let _1 as Api.stories.StoryViewsList:
_1.serialize(buffer, boxed)
case let _1 as Api.stories.UserStories:
_1.serialize(buffer, boxed)
case let _1 as Api.updates.ChannelDifference:
_1.serialize(buffer, boxed)
case let _1 as Api.updates.Difference:

View File

@ -744,7 +744,7 @@ public extension Api {
case messageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, receiptMsgId: Int32?, currency: String, totalAmount: Int64, startParam: String, extendedMedia: Api.MessageExtendedMedia?)
case messageMediaPhoto(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?)
case messageMediaPoll(poll: Api.Poll, results: Api.PollResults)
case messageMediaStory(flags: Int32, userId: Int64, id: Int32, story: Api.StoryItem?)
case messageMediaStory(flags: Int32, peer: Api.Peer, id: Int32, story: Api.StoryItem?)
case messageMediaUnsupported
case messageMediaVenue(geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String)
case messageMediaWebPage(webpage: Api.WebPage)
@ -834,12 +834,12 @@ public extension Api {
poll.serialize(buffer, true)
results.serialize(buffer, true)
break
case .messageMediaStory(let flags, let userId, let id, let story):
case .messageMediaStory(let flags, let peer, let id, let story):
if boxed {
buffer.appendInt32(-877523576)
buffer.appendInt32(1758159491)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(userId, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(id, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {story!.serialize(buffer, true)}
break
@ -891,8 +891,8 @@ public extension Api {
return ("messageMediaPhoto", [("flags", flags as Any), ("photo", photo as Any), ("ttlSeconds", ttlSeconds as Any)])
case .messageMediaPoll(let poll, let results):
return ("messageMediaPoll", [("poll", poll as Any), ("results", results as Any)])
case .messageMediaStory(let flags, let userId, let id, let story):
return ("messageMediaStory", [("flags", flags as Any), ("userId", userId as Any), ("id", id as Any), ("story", story as Any)])
case .messageMediaStory(let flags, let peer, let id, let story):
return ("messageMediaStory", [("flags", flags as Any), ("peer", peer as Any), ("id", id as Any), ("story", story as Any)])
case .messageMediaUnsupported:
return ("messageMediaUnsupported", [])
case .messageMediaVenue(let geo, let title, let address, let provider, let venueId, let venueType):
@ -1096,8 +1096,10 @@ public extension Api {
public static func parse_messageMediaStory(_ reader: BufferReader) -> MessageMedia? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
var _2: Api.Peer?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _3: Int32?
_3 = reader.readInt32()
var _4: Api.StoryItem?
@ -1109,7 +1111,7 @@ public extension Api {
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.MessageMedia.messageMediaStory(flags: _1!, userId: _2!, id: _3!, story: _4)
return Api.MessageMedia.messageMediaStory(flags: _1!, peer: _2!, id: _3!, story: _4)
}
else {
return nil

View File

@ -900,6 +900,62 @@ public extension Api {
}
}
public extension Api {
enum PeerStories: TypeConstructorDescription {
case peerStories(flags: Int32, peer: Api.Peer, maxReadId: Int32?, stories: [Api.StoryItem])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .peerStories(let flags, let peer, let maxReadId, let stories):
if boxed {
buffer.appendInt32(-1707742823)
}
serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(maxReadId!, buffer: buffer, boxed: false)}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(stories.count))
for item in stories {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .peerStories(let flags, let peer, let maxReadId, let stories):
return ("peerStories", [("flags", flags as Any), ("peer", peer as Any), ("maxReadId", maxReadId as Any), ("stories", stories as Any)])
}
}
public static func parse_peerStories(_ reader: BufferReader) -> PeerStories? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.Peer?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _3: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() }
var _4: [Api.StoryItem]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StoryItem.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.PeerStories.peerStories(flags: _1!, peer: _2!, maxReadId: _3, stories: _4!)
}
else {
return nil
}
}
}
}
public extension Api {
enum PhoneCall: TypeConstructorDescription {
case phoneCall(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, gAOrB: Buffer, keyFingerprint: Int64, protocol: Api.PhoneCallProtocol, connections: [Api.PhoneConnection], startDate: Int32)

View File

@ -1151,18 +1151,18 @@ public extension Api {
case updateReadHistoryInbox(flags: Int32, folderId: Int32?, peer: Api.Peer, maxId: Int32, stillUnreadCount: Int32, pts: Int32, ptsCount: Int32)
case updateReadHistoryOutbox(peer: Api.Peer, maxId: Int32, pts: Int32, ptsCount: Int32)
case updateReadMessagesContents(messages: [Int32], pts: Int32, ptsCount: Int32)
case updateReadStories(userId: Int64, maxId: Int32)
case updateReadStories(peer: Api.Peer, maxId: Int32)
case updateRecentEmojiStatuses
case updateRecentReactions
case updateRecentStickers
case updateSavedGifs
case updateSavedRingtones
case updateSentStoryReaction(userId: Int64, storyId: Int32, reaction: Api.Reaction)
case updateSentStoryReaction(peer: Api.Peer, storyId: Int32, reaction: Api.Reaction)
case updateServiceNotification(flags: Int32, inboxDate: Int32?, type: String, message: String, media: Api.MessageMedia, entities: [Api.MessageEntity])
case updateStickerSets(flags: Int32)
case updateStickerSetsOrder(flags: Int32, order: [Int64])
case updateStoriesStealthMode(stealthMode: Api.StoriesStealthMode)
case updateStory(userId: Int64, story: Api.StoryItem)
case updateStory(peer: Api.Peer, story: Api.StoryItem)
case updateStoryID(id: Int32, randomId: Int64)
case updateTheme(theme: Api.Theme)
case updateTranscribedAudio(flags: Int32, peer: Api.Peer, msgId: Int32, transcriptionId: Int64, text: String)
@ -1994,11 +1994,11 @@ public extension Api {
serializeInt32(pts, buffer: buffer, boxed: false)
serializeInt32(ptsCount, buffer: buffer, boxed: false)
break
case .updateReadStories(let userId, let maxId):
case .updateReadStories(let peer, let maxId):
if boxed {
buffer.appendInt32(-21679014)
buffer.appendInt32(-145845461)
}
serializeInt64(userId, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(maxId, buffer: buffer, boxed: false)
break
case .updateRecentEmojiStatuses:
@ -2031,11 +2031,11 @@ public extension Api {
}
break
case .updateSentStoryReaction(let userId, let storyId, let reaction):
case .updateSentStoryReaction(let peer, let storyId, let reaction):
if boxed {
buffer.appendInt32(-475579104)
buffer.appendInt32(2103604867)
}
serializeInt64(userId, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(storyId, buffer: buffer, boxed: false)
reaction.serialize(buffer, true)
break
@ -2077,11 +2077,11 @@ public extension Api {
}
stealthMode.serialize(buffer, true)
break
case .updateStory(let userId, let story):
case .updateStory(let peer, let story):
if boxed {
buffer.appendInt32(542785843)
buffer.appendInt32(1974712216)
}
serializeInt64(userId, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
story.serialize(buffer, true)
break
case .updateStoryID(let id, let randomId):
@ -2359,8 +2359,8 @@ public extension Api {
return ("updateReadHistoryOutbox", [("peer", peer as Any), ("maxId", maxId as Any), ("pts", pts as Any), ("ptsCount", ptsCount as Any)])
case .updateReadMessagesContents(let messages, let pts, let ptsCount):
return ("updateReadMessagesContents", [("messages", messages as Any), ("pts", pts as Any), ("ptsCount", ptsCount as Any)])
case .updateReadStories(let userId, let maxId):
return ("updateReadStories", [("userId", userId as Any), ("maxId", maxId as Any)])
case .updateReadStories(let peer, let maxId):
return ("updateReadStories", [("peer", peer as Any), ("maxId", maxId as Any)])
case .updateRecentEmojiStatuses:
return ("updateRecentEmojiStatuses", [])
case .updateRecentReactions:
@ -2371,8 +2371,8 @@ public extension Api {
return ("updateSavedGifs", [])
case .updateSavedRingtones:
return ("updateSavedRingtones", [])
case .updateSentStoryReaction(let userId, let storyId, let reaction):
return ("updateSentStoryReaction", [("userId", userId as Any), ("storyId", storyId as Any), ("reaction", reaction as Any)])
case .updateSentStoryReaction(let peer, let storyId, let reaction):
return ("updateSentStoryReaction", [("peer", peer as Any), ("storyId", storyId as Any), ("reaction", reaction as Any)])
case .updateServiceNotification(let flags, let inboxDate, let type, let message, let media, let entities):
return ("updateServiceNotification", [("flags", flags as Any), ("inboxDate", inboxDate as Any), ("type", type as Any), ("message", message as Any), ("media", media as Any), ("entities", entities as Any)])
case .updateStickerSets(let flags):
@ -2381,8 +2381,8 @@ public extension Api {
return ("updateStickerSetsOrder", [("flags", flags as Any), ("order", order as Any)])
case .updateStoriesStealthMode(let stealthMode):
return ("updateStoriesStealthMode", [("stealthMode", stealthMode as Any)])
case .updateStory(let userId, let story):
return ("updateStory", [("userId", userId as Any), ("story", story as Any)])
case .updateStory(let peer, let story):
return ("updateStory", [("peer", peer as Any), ("story", story as Any)])
case .updateStoryID(let id, let randomId):
return ("updateStoryID", [("id", id as Any), ("randomId", randomId as Any)])
case .updateTheme(let theme):
@ -4085,14 +4085,16 @@ public extension Api {
}
}
public static func parse_updateReadStories(_ reader: BufferReader) -> Update? {
var _1: Int64?
_1 = reader.readInt64()
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.Update.updateReadStories(userId: _1!, maxId: _2!)
return Api.Update.updateReadStories(peer: _1!, maxId: _2!)
}
else {
return nil
@ -4114,8 +4116,10 @@ public extension Api {
return Api.Update.updateSavedRingtones
}
public static func parse_updateSentStoryReaction(_ reader: BufferReader) -> Update? {
var _1: Int64?
_1 = reader.readInt64()
var _1: Api.Peer?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _2: Int32?
_2 = reader.readInt32()
var _3: Api.Reaction?
@ -4126,7 +4130,7 @@ public extension Api {
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.Update.updateSentStoryReaction(userId: _1!, storyId: _2!, reaction: _3!)
return Api.Update.updateSentStoryReaction(peer: _1!, storyId: _2!, reaction: _3!)
}
else {
return nil
@ -4203,8 +4207,10 @@ public extension Api {
}
}
public static func parse_updateStory(_ reader: BufferReader) -> Update? {
var _1: Int64?
_1 = reader.readInt64()
var _1: Api.Peer?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _2: Api.StoryItem?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.StoryItem
@ -4212,7 +4218,7 @@ public extension Api {
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.Update.updateStory(userId: _1!, story: _2!)
return Api.Update.updateStory(peer: _1!, story: _2!)
}
else {
return nil

View File

@ -590,13 +590,13 @@ public extension Api {
}
public extension Api {
enum UserFull: TypeConstructorDescription {
case userFull(flags: Int32, id: Int64, about: String?, settings: Api.PeerSettings, personalPhoto: Api.Photo?, profilePhoto: Api.Photo?, fallbackPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, botInfo: Api.BotInfo?, pinnedMsgId: Int32?, commonChatsCount: Int32, folderId: Int32?, ttlPeriod: Int32?, themeEmoticon: String?, privateForwardName: String?, botGroupAdminRights: Api.ChatAdminRights?, botBroadcastAdminRights: Api.ChatAdminRights?, premiumGifts: [Api.PremiumGiftOption]?, wallpaper: Api.WallPaper?, stories: Api.UserStories?)
case userFull(flags: Int32, id: Int64, about: String?, settings: Api.PeerSettings, personalPhoto: Api.Photo?, profilePhoto: Api.Photo?, fallbackPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, botInfo: Api.BotInfo?, pinnedMsgId: Int32?, commonChatsCount: Int32, folderId: Int32?, ttlPeriod: Int32?, themeEmoticon: String?, privateForwardName: String?, botGroupAdminRights: Api.ChatAdminRights?, botBroadcastAdminRights: Api.ChatAdminRights?, premiumGifts: [Api.PremiumGiftOption]?, wallpaper: Api.WallPaper?, stories: Api.PeerStories?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .userFull(let flags, let id, let about, let settings, let personalPhoto, let profilePhoto, let fallbackPhoto, let notifySettings, let botInfo, let pinnedMsgId, let commonChatsCount, let folderId, let ttlPeriod, let themeEmoticon, let privateForwardName, let botGroupAdminRights, let botBroadcastAdminRights, let premiumGifts, let wallpaper, let stories):
if boxed {
buffer.appendInt32(1340198022)
buffer.appendInt32(-1179571092)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(id, buffer: buffer, boxed: false)
@ -692,9 +692,9 @@ public extension Api {
if Int(_1!) & Int(1 << 24) != 0 {if let signature = reader.readInt32() {
_19 = Api.parse(reader, signature: signature) as? Api.WallPaper
} }
var _20: Api.UserStories?
var _20: Api.PeerStories?
if Int(_1!) & Int(1 << 25) != 0 {if let signature = reader.readInt32() {
_20 = Api.parse(reader, signature: signature) as? Api.UserStories
_20 = Api.parse(reader, signature: signature) as? Api.PeerStories
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
@ -890,60 +890,6 @@ public extension Api {
}
}
public extension Api {
enum UserStories: TypeConstructorDescription {
case userStories(flags: Int32, userId: Int64, maxReadId: Int32?, stories: [Api.StoryItem])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .userStories(let flags, let userId, let maxReadId, let stories):
if boxed {
buffer.appendInt32(-2045664768)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(userId, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(maxReadId!, buffer: buffer, boxed: false)}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(stories.count))
for item in stories {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .userStories(let flags, let userId, let maxReadId, let stories):
return ("userStories", [("flags", flags as Any), ("userId", userId as Any), ("maxReadId", maxReadId as Any), ("stories", stories as Any)])
}
}
public static func parse_userStories(_ reader: BufferReader) -> UserStories? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
var _3: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() }
var _4: [Api.StoryItem]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StoryItem.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.UserStories.userStories(flags: _1!, userId: _2!, maxReadId: _3, stories: _4!)
}
else {
return nil
}
}
}
}
public extension Api {
enum Username: TypeConstructorDescription {
case username(flags: Int32, username: String)
@ -1420,3 +1366,191 @@ public extension Api {
}
}
public extension Api {
enum WebPage: TypeConstructorDescription {
case webPage(flags: Int32, id: Int64, url: String, displayUrl: String, hash: Int32, type: String?, siteName: String?, title: String?, description: String?, photo: Api.Photo?, embedUrl: String?, embedType: String?, embedWidth: Int32?, embedHeight: Int32?, duration: Int32?, author: String?, document: Api.Document?, cachedPage: Api.Page?, attributes: [Api.WebPageAttribute]?)
case webPageEmpty(id: Int64)
case webPageNotModified(flags: Int32, cachedPageViews: Int32?)
case webPagePending(id: Int64, date: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .webPage(let flags, let id, let url, let displayUrl, let hash, let type, let siteName, let title, let description, let photo, let embedUrl, let embedType, let embedWidth, let embedHeight, let duration, let author, let document, let cachedPage, let attributes):
if boxed {
buffer.appendInt32(-392411726)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(id, buffer: buffer, boxed: false)
serializeString(url, buffer: buffer, boxed: false)
serializeString(displayUrl, buffer: buffer, boxed: false)
serializeInt32(hash, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(type!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {serializeString(siteName!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 3) != 0 {serializeString(description!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 4) != 0 {photo!.serialize(buffer, true)}
if Int(flags) & Int(1 << 5) != 0 {serializeString(embedUrl!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 5) != 0 {serializeString(embedType!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 6) != 0 {serializeInt32(embedWidth!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 6) != 0 {serializeInt32(embedHeight!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 7) != 0 {serializeInt32(duration!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 8) != 0 {serializeString(author!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 9) != 0 {document!.serialize(buffer, true)}
if Int(flags) & Int(1 << 10) != 0 {cachedPage!.serialize(buffer, true)}
if Int(flags) & Int(1 << 12) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(attributes!.count))
for item in attributes! {
item.serialize(buffer, true)
}}
break
case .webPageEmpty(let id):
if boxed {
buffer.appendInt32(-350980120)
}
serializeInt64(id, buffer: buffer, boxed: false)
break
case .webPageNotModified(let flags, let cachedPageViews):
if boxed {
buffer.appendInt32(1930545681)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(cachedPageViews!, buffer: buffer, boxed: false)}
break
case .webPagePending(let id, let date):
if boxed {
buffer.appendInt32(-981018084)
}
serializeInt64(id, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .webPage(let flags, let id, let url, let displayUrl, let hash, let type, let siteName, let title, let description, let photo, let embedUrl, let embedType, let embedWidth, let embedHeight, let duration, let author, let document, let cachedPage, let attributes):
return ("webPage", [("flags", flags as Any), ("id", id as Any), ("url", url as Any), ("displayUrl", displayUrl as Any), ("hash", hash as Any), ("type", type as Any), ("siteName", siteName as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("embedUrl", embedUrl as Any), ("embedType", embedType as Any), ("embedWidth", embedWidth as Any), ("embedHeight", embedHeight as Any), ("duration", duration as Any), ("author", author as Any), ("document", document as Any), ("cachedPage", cachedPage as Any), ("attributes", attributes as Any)])
case .webPageEmpty(let id):
return ("webPageEmpty", [("id", id as Any)])
case .webPageNotModified(let flags, let cachedPageViews):
return ("webPageNotModified", [("flags", flags as Any), ("cachedPageViews", cachedPageViews as Any)])
case .webPagePending(let id, let date):
return ("webPagePending", [("id", id as Any), ("date", date as Any)])
}
}
public static func parse_webPage(_ reader: BufferReader) -> WebPage? {
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?
if Int(_1!) & Int(1 << 0) != 0 {_6 = parseString(reader) }
var _7: String?
if Int(_1!) & Int(1 << 1) != 0 {_7 = parseString(reader) }
var _8: String?
if Int(_1!) & Int(1 << 2) != 0 {_8 = parseString(reader) }
var _9: String?
if Int(_1!) & Int(1 << 3) != 0 {_9 = parseString(reader) }
var _10: Api.Photo?
if Int(_1!) & Int(1 << 4) != 0 {if let signature = reader.readInt32() {
_10 = Api.parse(reader, signature: signature) as? Api.Photo
} }
var _11: String?
if Int(_1!) & Int(1 << 5) != 0 {_11 = parseString(reader) }
var _12: String?
if Int(_1!) & Int(1 << 5) != 0 {_12 = parseString(reader) }
var _13: Int32?
if Int(_1!) & Int(1 << 6) != 0 {_13 = reader.readInt32() }
var _14: Int32?
if Int(_1!) & Int(1 << 6) != 0 {_14 = reader.readInt32() }
var _15: Int32?
if Int(_1!) & Int(1 << 7) != 0 {_15 = reader.readInt32() }
var _16: String?
if Int(_1!) & Int(1 << 8) != 0 {_16 = parseString(reader) }
var _17: Api.Document?
if Int(_1!) & Int(1 << 9) != 0 {if let signature = reader.readInt32() {
_17 = Api.parse(reader, signature: signature) as? Api.Document
} }
var _18: Api.Page?
if Int(_1!) & Int(1 << 10) != 0 {if let signature = reader.readInt32() {
_18 = Api.parse(reader, signature: signature) as? Api.Page
} }
var _19: [Api.WebPageAttribute]?
if Int(_1!) & Int(1 << 12) != 0 {if let _ = reader.readInt32() {
_19 = Api.parseVector(reader, elementSignature: 0, elementType: Api.WebPageAttribute.self)
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 2) == 0) || _8 != nil
let _c9 = (Int(_1!) & Int(1 << 3) == 0) || _9 != nil
let _c10 = (Int(_1!) & Int(1 << 4) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 5) == 0) || _11 != nil
let _c12 = (Int(_1!) & Int(1 << 5) == 0) || _12 != nil
let _c13 = (Int(_1!) & Int(1 << 6) == 0) || _13 != nil
let _c14 = (Int(_1!) & Int(1 << 6) == 0) || _14 != nil
let _c15 = (Int(_1!) & Int(1 << 7) == 0) || _15 != nil
let _c16 = (Int(_1!) & Int(1 << 8) == 0) || _16 != nil
let _c17 = (Int(_1!) & Int(1 << 9) == 0) || _17 != nil
let _c18 = (Int(_1!) & Int(1 << 10) == 0) || _18 != nil
let _c19 = (Int(_1!) & Int(1 << 12) == 0) || _19 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 {
return Api.WebPage.webPage(flags: _1!, id: _2!, url: _3!, displayUrl: _4!, hash: _5!, type: _6, siteName: _7, title: _8, description: _9, photo: _10, embedUrl: _11, embedType: _12, embedWidth: _13, embedHeight: _14, duration: _15, author: _16, document: _17, cachedPage: _18, attributes: _19)
}
else {
return nil
}
}
public static func parse_webPageEmpty(_ reader: BufferReader) -> WebPage? {
var _1: Int64?
_1 = reader.readInt64()
let _c1 = _1 != nil
if _c1 {
return Api.WebPage.webPageEmpty(id: _1!)
}
else {
return nil
}
}
public static func parse_webPageNotModified(_ reader: BufferReader) -> WebPage? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
if _c1 && _c2 {
return Api.WebPage.webPageNotModified(flags: _1!, cachedPageViews: _2)
}
else {
return nil
}
}
public static func parse_webPagePending(_ reader: BufferReader) -> WebPage? {
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.WebPage.webPagePending(id: _1!, date: _2!)
}
else {
return nil
}
}
}
}

View File

@ -1,204 +1,16 @@
public extension Api {
enum WebPage: TypeConstructorDescription {
case webPage(flags: Int32, id: Int64, url: String, displayUrl: String, hash: Int32, type: String?, siteName: String?, title: String?, description: String?, photo: Api.Photo?, embedUrl: String?, embedType: String?, embedWidth: Int32?, embedHeight: Int32?, duration: Int32?, author: String?, document: Api.Document?, cachedPage: Api.Page?, attributes: [Api.WebPageAttribute]?)
case webPageEmpty(id: Int64)
case webPageNotModified(flags: Int32, cachedPageViews: Int32?)
case webPagePending(id: Int64, date: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .webPage(let flags, let id, let url, let displayUrl, let hash, let type, let siteName, let title, let description, let photo, let embedUrl, let embedType, let embedWidth, let embedHeight, let duration, let author, let document, let cachedPage, let attributes):
if boxed {
buffer.appendInt32(-392411726)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(id, buffer: buffer, boxed: false)
serializeString(url, buffer: buffer, boxed: false)
serializeString(displayUrl, buffer: buffer, boxed: false)
serializeInt32(hash, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(type!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 1) != 0 {serializeString(siteName!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 3) != 0 {serializeString(description!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 4) != 0 {photo!.serialize(buffer, true)}
if Int(flags) & Int(1 << 5) != 0 {serializeString(embedUrl!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 5) != 0 {serializeString(embedType!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 6) != 0 {serializeInt32(embedWidth!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 6) != 0 {serializeInt32(embedHeight!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 7) != 0 {serializeInt32(duration!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 8) != 0 {serializeString(author!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 9) != 0 {document!.serialize(buffer, true)}
if Int(flags) & Int(1 << 10) != 0 {cachedPage!.serialize(buffer, true)}
if Int(flags) & Int(1 << 12) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(attributes!.count))
for item in attributes! {
item.serialize(buffer, true)
}}
break
case .webPageEmpty(let id):
if boxed {
buffer.appendInt32(-350980120)
}
serializeInt64(id, buffer: buffer, boxed: false)
break
case .webPageNotModified(let flags, let cachedPageViews):
if boxed {
buffer.appendInt32(1930545681)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(cachedPageViews!, buffer: buffer, boxed: false)}
break
case .webPagePending(let id, let date):
if boxed {
buffer.appendInt32(-981018084)
}
serializeInt64(id, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .webPage(let flags, let id, let url, let displayUrl, let hash, let type, let siteName, let title, let description, let photo, let embedUrl, let embedType, let embedWidth, let embedHeight, let duration, let author, let document, let cachedPage, let attributes):
return ("webPage", [("flags", flags as Any), ("id", id as Any), ("url", url as Any), ("displayUrl", displayUrl as Any), ("hash", hash as Any), ("type", type as Any), ("siteName", siteName as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("embedUrl", embedUrl as Any), ("embedType", embedType as Any), ("embedWidth", embedWidth as Any), ("embedHeight", embedHeight as Any), ("duration", duration as Any), ("author", author as Any), ("document", document as Any), ("cachedPage", cachedPage as Any), ("attributes", attributes as Any)])
case .webPageEmpty(let id):
return ("webPageEmpty", [("id", id as Any)])
case .webPageNotModified(let flags, let cachedPageViews):
return ("webPageNotModified", [("flags", flags as Any), ("cachedPageViews", cachedPageViews as Any)])
case .webPagePending(let id, let date):
return ("webPagePending", [("id", id as Any), ("date", date as Any)])
}
}
public static func parse_webPage(_ reader: BufferReader) -> WebPage? {
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?
if Int(_1!) & Int(1 << 0) != 0 {_6 = parseString(reader) }
var _7: String?
if Int(_1!) & Int(1 << 1) != 0 {_7 = parseString(reader) }
var _8: String?
if Int(_1!) & Int(1 << 2) != 0 {_8 = parseString(reader) }
var _9: String?
if Int(_1!) & Int(1 << 3) != 0 {_9 = parseString(reader) }
var _10: Api.Photo?
if Int(_1!) & Int(1 << 4) != 0 {if let signature = reader.readInt32() {
_10 = Api.parse(reader, signature: signature) as? Api.Photo
} }
var _11: String?
if Int(_1!) & Int(1 << 5) != 0 {_11 = parseString(reader) }
var _12: String?
if Int(_1!) & Int(1 << 5) != 0 {_12 = parseString(reader) }
var _13: Int32?
if Int(_1!) & Int(1 << 6) != 0 {_13 = reader.readInt32() }
var _14: Int32?
if Int(_1!) & Int(1 << 6) != 0 {_14 = reader.readInt32() }
var _15: Int32?
if Int(_1!) & Int(1 << 7) != 0 {_15 = reader.readInt32() }
var _16: String?
if Int(_1!) & Int(1 << 8) != 0 {_16 = parseString(reader) }
var _17: Api.Document?
if Int(_1!) & Int(1 << 9) != 0 {if let signature = reader.readInt32() {
_17 = Api.parse(reader, signature: signature) as? Api.Document
} }
var _18: Api.Page?
if Int(_1!) & Int(1 << 10) != 0 {if let signature = reader.readInt32() {
_18 = Api.parse(reader, signature: signature) as? Api.Page
} }
var _19: [Api.WebPageAttribute]?
if Int(_1!) & Int(1 << 12) != 0 {if let _ = reader.readInt32() {
_19 = Api.parseVector(reader, elementSignature: 0, elementType: Api.WebPageAttribute.self)
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 2) == 0) || _8 != nil
let _c9 = (Int(_1!) & Int(1 << 3) == 0) || _9 != nil
let _c10 = (Int(_1!) & Int(1 << 4) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 5) == 0) || _11 != nil
let _c12 = (Int(_1!) & Int(1 << 5) == 0) || _12 != nil
let _c13 = (Int(_1!) & Int(1 << 6) == 0) || _13 != nil
let _c14 = (Int(_1!) & Int(1 << 6) == 0) || _14 != nil
let _c15 = (Int(_1!) & Int(1 << 7) == 0) || _15 != nil
let _c16 = (Int(_1!) & Int(1 << 8) == 0) || _16 != nil
let _c17 = (Int(_1!) & Int(1 << 9) == 0) || _17 != nil
let _c18 = (Int(_1!) & Int(1 << 10) == 0) || _18 != nil
let _c19 = (Int(_1!) & Int(1 << 12) == 0) || _19 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 {
return Api.WebPage.webPage(flags: _1!, id: _2!, url: _3!, displayUrl: _4!, hash: _5!, type: _6, siteName: _7, title: _8, description: _9, photo: _10, embedUrl: _11, embedType: _12, embedWidth: _13, embedHeight: _14, duration: _15, author: _16, document: _17, cachedPage: _18, attributes: _19)
}
else {
return nil
}
}
public static func parse_webPageEmpty(_ reader: BufferReader) -> WebPage? {
var _1: Int64?
_1 = reader.readInt64()
let _c1 = _1 != nil
if _c1 {
return Api.WebPage.webPageEmpty(id: _1!)
}
else {
return nil
}
}
public static func parse_webPageNotModified(_ reader: BufferReader) -> WebPage? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
if _c1 && _c2 {
return Api.WebPage.webPageNotModified(flags: _1!, cachedPageViews: _2)
}
else {
return nil
}
}
public static func parse_webPagePending(_ reader: BufferReader) -> WebPage? {
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.WebPage.webPagePending(id: _1!, date: _2!)
}
else {
return nil
}
}
}
}
public extension Api {
indirect enum WebPageAttribute: TypeConstructorDescription {
case webPageAttributeStory(flags: Int32, userId: Int64, id: Int32, story: Api.StoryItem?)
case webPageAttributeStory(flags: Int32, peer: Api.Peer, id: Int32, story: Api.StoryItem?)
case webPageAttributeTheme(flags: Int32, documents: [Api.Document]?, settings: Api.ThemeSettings?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .webPageAttributeStory(let flags, let userId, let id, let story):
case .webPageAttributeStory(let flags, let peer, let id, let story):
if boxed {
buffer.appendInt32(-1818605967)
buffer.appendInt32(781501415)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(userId, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(id, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {story!.serialize(buffer, true)}
break
@ -219,8 +31,8 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .webPageAttributeStory(let flags, let userId, let id, let story):
return ("webPageAttributeStory", [("flags", flags as Any), ("userId", userId as Any), ("id", id as Any), ("story", story as Any)])
case .webPageAttributeStory(let flags, let peer, let id, let story):
return ("webPageAttributeStory", [("flags", flags as Any), ("peer", peer as Any), ("id", id as Any), ("story", story as Any)])
case .webPageAttributeTheme(let flags, let documents, let settings):
return ("webPageAttributeTheme", [("flags", flags as Any), ("documents", documents as Any), ("settings", settings as Any)])
}
@ -229,8 +41,10 @@ public extension Api {
public static func parse_webPageAttributeStory(_ reader: BufferReader) -> WebPageAttribute? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
var _2: Api.Peer?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.Peer
}
var _3: Int32?
_3 = reader.readInt32()
var _4: Api.StoryItem?
@ -242,7 +56,7 @@ public extension Api {
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.WebPageAttribute.webPageAttributeStory(flags: _1!, userId: _2!, id: _3!, story: _4)
return Api.WebPageAttribute.webPageAttributeStory(flags: _1!, peer: _2!, id: _3!, story: _4)
}
else {
return nil
@ -1326,3 +1140,153 @@ public extension Api.account {
}
}
public extension Api.account {
enum TmpPassword: TypeConstructorDescription {
case tmpPassword(tmpPassword: Buffer, validUntil: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .tmpPassword(let tmpPassword, let validUntil):
if boxed {
buffer.appendInt32(-614138572)
}
serializeBytes(tmpPassword, buffer: buffer, boxed: false)
serializeInt32(validUntil, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .tmpPassword(let tmpPassword, let validUntil):
return ("tmpPassword", [("tmpPassword", tmpPassword as Any), ("validUntil", validUntil as Any)])
}
}
public static func parse_tmpPassword(_ reader: BufferReader) -> TmpPassword? {
var _1: Buffer?
_1 = parseBytes(reader)
var _2: Int32?
_2 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.account.TmpPassword.tmpPassword(tmpPassword: _1!, validUntil: _2!)
}
else {
return nil
}
}
}
}
public extension Api.account {
enum WallPapers: TypeConstructorDescription {
case wallPapers(hash: Int64, wallpapers: [Api.WallPaper])
case wallPapersNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .wallPapers(let hash, let wallpapers):
if boxed {
buffer.appendInt32(-842824308)
}
serializeInt64(hash, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(wallpapers.count))
for item in wallpapers {
item.serialize(buffer, true)
}
break
case .wallPapersNotModified:
if boxed {
buffer.appendInt32(471437699)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .wallPapers(let hash, let wallpapers):
return ("wallPapers", [("hash", hash as Any), ("wallpapers", wallpapers as Any)])
case .wallPapersNotModified:
return ("wallPapersNotModified", [])
}
}
public static func parse_wallPapers(_ reader: BufferReader) -> WallPapers? {
var _1: Int64?
_1 = reader.readInt64()
var _2: [Api.WallPaper]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.WallPaper.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.account.WallPapers.wallPapers(hash: _1!, wallpapers: _2!)
}
else {
return nil
}
}
public static func parse_wallPapersNotModified(_ reader: BufferReader) -> WallPapers? {
return Api.account.WallPapers.wallPapersNotModified
}
}
}
public extension Api.account {
enum WebAuthorizations: TypeConstructorDescription {
case webAuthorizations(authorizations: [Api.WebAuthorization], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .webAuthorizations(let authorizations, let users):
if boxed {
buffer.appendInt32(-313079300)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(authorizations.count))
for item in authorizations {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .webAuthorizations(let authorizations, let users):
return ("webAuthorizations", [("authorizations", authorizations as Any), ("users", users as Any)])
}
}
public static func parse_webAuthorizations(_ reader: BufferReader) -> WebAuthorizations? {
var _1: [Api.WebAuthorization]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.WebAuthorization.self)
}
var _2: [Api.User]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.account.WebAuthorizations.webAuthorizations(authorizations: _1!, users: _2!)
}
else {
return nil
}
}
}
}

View File

@ -1,153 +1,3 @@
public extension Api.account {
enum TmpPassword: TypeConstructorDescription {
case tmpPassword(tmpPassword: Buffer, validUntil: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .tmpPassword(let tmpPassword, let validUntil):
if boxed {
buffer.appendInt32(-614138572)
}
serializeBytes(tmpPassword, buffer: buffer, boxed: false)
serializeInt32(validUntil, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .tmpPassword(let tmpPassword, let validUntil):
return ("tmpPassword", [("tmpPassword", tmpPassword as Any), ("validUntil", validUntil as Any)])
}
}
public static func parse_tmpPassword(_ reader: BufferReader) -> TmpPassword? {
var _1: Buffer?
_1 = parseBytes(reader)
var _2: Int32?
_2 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.account.TmpPassword.tmpPassword(tmpPassword: _1!, validUntil: _2!)
}
else {
return nil
}
}
}
}
public extension Api.account {
enum WallPapers: TypeConstructorDescription {
case wallPapers(hash: Int64, wallpapers: [Api.WallPaper])
case wallPapersNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .wallPapers(let hash, let wallpapers):
if boxed {
buffer.appendInt32(-842824308)
}
serializeInt64(hash, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(wallpapers.count))
for item in wallpapers {
item.serialize(buffer, true)
}
break
case .wallPapersNotModified:
if boxed {
buffer.appendInt32(471437699)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .wallPapers(let hash, let wallpapers):
return ("wallPapers", [("hash", hash as Any), ("wallpapers", wallpapers as Any)])
case .wallPapersNotModified:
return ("wallPapersNotModified", [])
}
}
public static func parse_wallPapers(_ reader: BufferReader) -> WallPapers? {
var _1: Int64?
_1 = reader.readInt64()
var _2: [Api.WallPaper]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.WallPaper.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.account.WallPapers.wallPapers(hash: _1!, wallpapers: _2!)
}
else {
return nil
}
}
public static func parse_wallPapersNotModified(_ reader: BufferReader) -> WallPapers? {
return Api.account.WallPapers.wallPapersNotModified
}
}
}
public extension Api.account {
enum WebAuthorizations: TypeConstructorDescription {
case webAuthorizations(authorizations: [Api.WebAuthorization], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .webAuthorizations(let authorizations, let users):
if boxed {
buffer.appendInt32(-313079300)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(authorizations.count))
for item in authorizations {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .webAuthorizations(let authorizations, let users):
return ("webAuthorizations", [("authorizations", authorizations as Any), ("users", users as Any)])
}
}
public static func parse_webAuthorizations(_ reader: BufferReader) -> WebAuthorizations? {
var _1: [Api.WebAuthorization]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.WebAuthorization.self)
}
var _2: [Api.User]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.account.WebAuthorizations.webAuthorizations(authorizations: _1!, users: _2!)
}
else {
return nil
}
}
}
}
public extension Api.auth {
enum Authorization: TypeConstructorDescription {
case authorization(flags: Int32, otherwiseReloginDays: Int32?, tmpSessions: Int32?, futureAuthToken: Buffer?, user: Api.User)
@ -1062,3 +912,199 @@ public extension Api.channels {
}
}
public extension Api.channels {
enum SendAsPeers: TypeConstructorDescription {
case sendAsPeers(peers: [Api.SendAsPeer], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .sendAsPeers(let peers, let chats, let users):
if boxed {
buffer.appendInt32(-191450938)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(peers.count))
for item in peers {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .sendAsPeers(let peers, let chats, let users):
return ("sendAsPeers", [("peers", peers as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_sendAsPeers(_ reader: BufferReader) -> SendAsPeers? {
var _1: [Api.SendAsPeer]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SendAsPeer.self)
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.channels.SendAsPeers.sendAsPeers(peers: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.chatlists {
enum ChatlistInvite: TypeConstructorDescription {
case chatlistInvite(flags: Int32, title: String, emoticon: String?, peers: [Api.Peer], chats: [Api.Chat], users: [Api.User])
case chatlistInviteAlready(filterId: Int32, missingPeers: [Api.Peer], alreadyPeers: [Api.Peer], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .chatlistInvite(let flags, let title, let emoticon, let peers, let chats, let users):
if boxed {
buffer.appendInt32(500007837)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(emoticon!, buffer: buffer, boxed: false)}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(peers.count))
for item in peers {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
case .chatlistInviteAlready(let filterId, let missingPeers, let alreadyPeers, let chats, let users):
if boxed {
buffer.appendInt32(-91752871)
}
serializeInt32(filterId, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(missingPeers.count))
for item in missingPeers {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(alreadyPeers.count))
for item in alreadyPeers {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .chatlistInvite(let flags, let title, let emoticon, let peers, let chats, let users):
return ("chatlistInvite", [("flags", flags as Any), ("title", title as Any), ("emoticon", emoticon as Any), ("peers", peers as Any), ("chats", chats as Any), ("users", users as Any)])
case .chatlistInviteAlready(let filterId, let missingPeers, let alreadyPeers, let chats, let users):
return ("chatlistInviteAlready", [("filterId", filterId as Any), ("missingPeers", missingPeers as Any), ("alreadyPeers", alreadyPeers as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_chatlistInvite(_ reader: BufferReader) -> ChatlistInvite? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: String?
if Int(_1!) & Int(1 << 0) != 0 {_3 = parseString(reader) }
var _4: [Api.Peer]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Peer.self)
}
var _5: [Api.Chat]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _6: [Api.User]?
if let _ = reader.readInt32() {
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.chatlists.ChatlistInvite.chatlistInvite(flags: _1!, title: _2!, emoticon: _3, peers: _4!, chats: _5!, users: _6!)
}
else {
return nil
}
}
public static func parse_chatlistInviteAlready(_ reader: BufferReader) -> ChatlistInvite? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.Peer]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Peer.self)
}
var _3: [Api.Peer]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Peer.self)
}
var _4: [Api.Chat]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _5: [Api.User]?
if let _ = reader.readInt32() {
_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
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.chatlists.ChatlistInvite.chatlistInviteAlready(filterId: _1!, missingPeers: _2!, alreadyPeers: _3!, chats: _4!, users: _5!)
}
else {
return nil
}
}
}
}

View File

@ -1,199 +1,3 @@
public extension Api.channels {
enum SendAsPeers: TypeConstructorDescription {
case sendAsPeers(peers: [Api.SendAsPeer], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .sendAsPeers(let peers, let chats, let users):
if boxed {
buffer.appendInt32(-191450938)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(peers.count))
for item in peers {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .sendAsPeers(let peers, let chats, let users):
return ("sendAsPeers", [("peers", peers as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_sendAsPeers(_ reader: BufferReader) -> SendAsPeers? {
var _1: [Api.SendAsPeer]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SendAsPeer.self)
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.channels.SendAsPeers.sendAsPeers(peers: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.chatlists {
enum ChatlistInvite: TypeConstructorDescription {
case chatlistInvite(flags: Int32, title: String, emoticon: String?, peers: [Api.Peer], chats: [Api.Chat], users: [Api.User])
case chatlistInviteAlready(filterId: Int32, missingPeers: [Api.Peer], alreadyPeers: [Api.Peer], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .chatlistInvite(let flags, let title, let emoticon, let peers, let chats, let users):
if boxed {
buffer.appendInt32(500007837)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(emoticon!, buffer: buffer, boxed: false)}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(peers.count))
for item in peers {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
case .chatlistInviteAlready(let filterId, let missingPeers, let alreadyPeers, let chats, let users):
if boxed {
buffer.appendInt32(-91752871)
}
serializeInt32(filterId, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(missingPeers.count))
for item in missingPeers {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(alreadyPeers.count))
for item in alreadyPeers {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .chatlistInvite(let flags, let title, let emoticon, let peers, let chats, let users):
return ("chatlistInvite", [("flags", flags as Any), ("title", title as Any), ("emoticon", emoticon as Any), ("peers", peers as Any), ("chats", chats as Any), ("users", users as Any)])
case .chatlistInviteAlready(let filterId, let missingPeers, let alreadyPeers, let chats, let users):
return ("chatlistInviteAlready", [("filterId", filterId as Any), ("missingPeers", missingPeers as Any), ("alreadyPeers", alreadyPeers as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_chatlistInvite(_ reader: BufferReader) -> ChatlistInvite? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: String?
if Int(_1!) & Int(1 << 0) != 0 {_3 = parseString(reader) }
var _4: [Api.Peer]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Peer.self)
}
var _5: [Api.Chat]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _6: [Api.User]?
if let _ = reader.readInt32() {
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.chatlists.ChatlistInvite.chatlistInvite(flags: _1!, title: _2!, emoticon: _3, peers: _4!, chats: _5!, users: _6!)
}
else {
return nil
}
}
public static func parse_chatlistInviteAlready(_ reader: BufferReader) -> ChatlistInvite? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.Peer]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Peer.self)
}
var _3: [Api.Peer]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Peer.self)
}
var _4: [Api.Chat]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _5: [Api.User]?
if let _ = reader.readInt32() {
_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
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.chatlists.ChatlistInvite.chatlistInviteAlready(filterId: _1!, missingPeers: _2!, alreadyPeers: _3!, chats: _4!, users: _5!)
}
else {
return nil
}
}
}
}
public extension Api.chatlists {
enum ChatlistUpdates: TypeConstructorDescription {
case chatlistUpdates(missingPeers: [Api.Peer], chats: [Api.Chat], users: [Api.User])
@ -1478,3 +1282,143 @@ public extension Api.help {
}
}
public extension Api.help {
enum RecentMeUrls: TypeConstructorDescription {
case recentMeUrls(urls: [Api.RecentMeUrl], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .recentMeUrls(let urls, let chats, let users):
if boxed {
buffer.appendInt32(235081943)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(urls.count))
for item in urls {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .recentMeUrls(let urls, let chats, let users):
return ("recentMeUrls", [("urls", urls as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_recentMeUrls(_ reader: BufferReader) -> RecentMeUrls? {
var _1: [Api.RecentMeUrl]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.RecentMeUrl.self)
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.help.RecentMeUrls.recentMeUrls(urls: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.help {
enum Support: TypeConstructorDescription {
case support(phoneNumber: String, user: Api.User)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .support(let phoneNumber, let user):
if boxed {
buffer.appendInt32(398898678)
}
serializeString(phoneNumber, buffer: buffer, boxed: false)
user.serialize(buffer, true)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .support(let phoneNumber, let user):
return ("support", [("phoneNumber", phoneNumber as Any), ("user", user as Any)])
}
}
public static func parse_support(_ reader: BufferReader) -> Support? {
var _1: String?
_1 = parseString(reader)
var _2: Api.User?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.User
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.help.Support.support(phoneNumber: _1!, user: _2!)
}
else {
return nil
}
}
}
}
public extension Api.help {
enum SupportName: TypeConstructorDescription {
case supportName(name: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .supportName(let name):
if boxed {
buffer.appendInt32(-1945767479)
}
serializeString(name, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .supportName(let name):
return ("supportName", [("name", name as Any)])
}
}
public static func parse_supportName(_ reader: BufferReader) -> SupportName? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.help.SupportName.supportName(name: _1!)
}
else {
return nil
}
}
}
}

View File

@ -1,143 +1,3 @@
public extension Api.help {
enum RecentMeUrls: TypeConstructorDescription {
case recentMeUrls(urls: [Api.RecentMeUrl], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .recentMeUrls(let urls, let chats, let users):
if boxed {
buffer.appendInt32(235081943)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(urls.count))
for item in urls {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .recentMeUrls(let urls, let chats, let users):
return ("recentMeUrls", [("urls", urls as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_recentMeUrls(_ reader: BufferReader) -> RecentMeUrls? {
var _1: [Api.RecentMeUrl]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.RecentMeUrl.self)
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.help.RecentMeUrls.recentMeUrls(urls: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.help {
enum Support: TypeConstructorDescription {
case support(phoneNumber: String, user: Api.User)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .support(let phoneNumber, let user):
if boxed {
buffer.appendInt32(398898678)
}
serializeString(phoneNumber, buffer: buffer, boxed: false)
user.serialize(buffer, true)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .support(let phoneNumber, let user):
return ("support", [("phoneNumber", phoneNumber as Any), ("user", user as Any)])
}
}
public static func parse_support(_ reader: BufferReader) -> Support? {
var _1: String?
_1 = parseString(reader)
var _2: Api.User?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.User
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.help.Support.support(phoneNumber: _1!, user: _2!)
}
else {
return nil
}
}
}
}
public extension Api.help {
enum SupportName: TypeConstructorDescription {
case supportName(name: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .supportName(let name):
if boxed {
buffer.appendInt32(-1945767479)
}
serializeString(name, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .supportName(let name):
return ("supportName", [("name", name as Any)])
}
}
public static func parse_supportName(_ reader: BufferReader) -> SupportName? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.help.SupportName.supportName(name: _1!)
}
else {
return nil
}
}
}
}
public extension Api.help {
enum TermsOfService: TypeConstructorDescription {
case termsOfService(flags: Int32, id: Api.DataJSON, text: String, entities: [Api.MessageEntity], minAgeConfirm: Int32?)
@ -1430,3 +1290,89 @@ public extension Api.messages {
}
}
public extension Api.messages {
enum ExportedChatInvite: TypeConstructorDescription {
case exportedChatInvite(invite: Api.ExportedChatInvite, users: [Api.User])
case exportedChatInviteReplaced(invite: Api.ExportedChatInvite, newInvite: Api.ExportedChatInvite, users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .exportedChatInvite(let invite, let users):
if boxed {
buffer.appendInt32(410107472)
}
invite.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
case .exportedChatInviteReplaced(let invite, let newInvite, let users):
if boxed {
buffer.appendInt32(572915951)
}
invite.serialize(buffer, true)
newInvite.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .exportedChatInvite(let invite, let users):
return ("exportedChatInvite", [("invite", invite as Any), ("users", users as Any)])
case .exportedChatInviteReplaced(let invite, let newInvite, let users):
return ("exportedChatInviteReplaced", [("invite", invite as Any), ("newInvite", newInvite as Any), ("users", users as Any)])
}
}
public static func parse_exportedChatInvite(_ reader: BufferReader) -> ExportedChatInvite? {
var _1: Api.ExportedChatInvite?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.ExportedChatInvite
}
var _2: [Api.User]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.messages.ExportedChatInvite.exportedChatInvite(invite: _1!, users: _2!)
}
else {
return nil
}
}
public static func parse_exportedChatInviteReplaced(_ reader: BufferReader) -> ExportedChatInvite? {
var _1: Api.ExportedChatInvite?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.ExportedChatInvite
}
var _2: Api.ExportedChatInvite?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.ExportedChatInvite
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.messages.ExportedChatInvite.exportedChatInviteReplaced(invite: _1!, newInvite: _2!, users: _3!)
}
else {
return nil
}
}
}
}

View File

@ -1,89 +1,3 @@
public extension Api.messages {
enum ExportedChatInvite: TypeConstructorDescription {
case exportedChatInvite(invite: Api.ExportedChatInvite, users: [Api.User])
case exportedChatInviteReplaced(invite: Api.ExportedChatInvite, newInvite: Api.ExportedChatInvite, users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .exportedChatInvite(let invite, let users):
if boxed {
buffer.appendInt32(410107472)
}
invite.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
case .exportedChatInviteReplaced(let invite, let newInvite, let users):
if boxed {
buffer.appendInt32(572915951)
}
invite.serialize(buffer, true)
newInvite.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .exportedChatInvite(let invite, let users):
return ("exportedChatInvite", [("invite", invite as Any), ("users", users as Any)])
case .exportedChatInviteReplaced(let invite, let newInvite, let users):
return ("exportedChatInviteReplaced", [("invite", invite as Any), ("newInvite", newInvite as Any), ("users", users as Any)])
}
}
public static func parse_exportedChatInvite(_ reader: BufferReader) -> ExportedChatInvite? {
var _1: Api.ExportedChatInvite?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.ExportedChatInvite
}
var _2: [Api.User]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.messages.ExportedChatInvite.exportedChatInvite(invite: _1!, users: _2!)
}
else {
return nil
}
}
public static func parse_exportedChatInviteReplaced(_ reader: BufferReader) -> ExportedChatInvite? {
var _1: Api.ExportedChatInvite?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.ExportedChatInvite
}
var _2: Api.ExportedChatInvite?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.ExportedChatInvite
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.messages.ExportedChatInvite.exportedChatInviteReplaced(invite: _1!, newInvite: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.messages {
enum ExportedChatInvites: TypeConstructorDescription {
case exportedChatInvites(count: Int32, invites: [Api.ExportedChatInvite], users: [Api.User])
@ -1526,3 +1440,65 @@ public extension Api.messages {
}
}
public extension Api.messages {
enum SentEncryptedMessage: TypeConstructorDescription {
case sentEncryptedFile(date: Int32, file: Api.EncryptedFile)
case sentEncryptedMessage(date: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .sentEncryptedFile(let date, let file):
if boxed {
buffer.appendInt32(-1802240206)
}
serializeInt32(date, buffer: buffer, boxed: false)
file.serialize(buffer, true)
break
case .sentEncryptedMessage(let date):
if boxed {
buffer.appendInt32(1443858741)
}
serializeInt32(date, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .sentEncryptedFile(let date, let file):
return ("sentEncryptedFile", [("date", date as Any), ("file", file as Any)])
case .sentEncryptedMessage(let date):
return ("sentEncryptedMessage", [("date", date as Any)])
}
}
public static func parse_sentEncryptedFile(_ reader: BufferReader) -> SentEncryptedMessage? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.EncryptedFile?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.EncryptedFile
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.messages.SentEncryptedMessage.sentEncryptedFile(date: _1!, file: _2!)
}
else {
return nil
}
}
public static func parse_sentEncryptedMessage(_ reader: BufferReader) -> SentEncryptedMessage? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return Api.messages.SentEncryptedMessage.sentEncryptedMessage(date: _1!)
}
else {
return nil
}
}
}
}

View File

@ -1,65 +1,3 @@
public extension Api.messages {
enum SentEncryptedMessage: TypeConstructorDescription {
case sentEncryptedFile(date: Int32, file: Api.EncryptedFile)
case sentEncryptedMessage(date: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .sentEncryptedFile(let date, let file):
if boxed {
buffer.appendInt32(-1802240206)
}
serializeInt32(date, buffer: buffer, boxed: false)
file.serialize(buffer, true)
break
case .sentEncryptedMessage(let date):
if boxed {
buffer.appendInt32(1443858741)
}
serializeInt32(date, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .sentEncryptedFile(let date, let file):
return ("sentEncryptedFile", [("date", date as Any), ("file", file as Any)])
case .sentEncryptedMessage(let date):
return ("sentEncryptedMessage", [("date", date as Any)])
}
}
public static func parse_sentEncryptedFile(_ reader: BufferReader) -> SentEncryptedMessage? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.EncryptedFile?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.EncryptedFile
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.messages.SentEncryptedMessage.sentEncryptedFile(date: _1!, file: _2!)
}
else {
return nil
}
}
public static func parse_sentEncryptedMessage(_ reader: BufferReader) -> SentEncryptedMessage? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return Api.messages.SentEncryptedMessage.sentEncryptedMessage(date: _1!)
}
else {
return nil
}
}
}
}
public extension Api.messages {
enum SponsoredMessages: TypeConstructorDescription {
case sponsoredMessages(flags: Int32, postsBetween: Int32?, messages: [Api.SponsoredMessage], chats: [Api.Chat], users: [Api.User])
@ -1590,3 +1528,191 @@ public extension Api.stats {
}
}
public extension Api.stats {
enum MegagroupStats: TypeConstructorDescription {
case megagroupStats(period: Api.StatsDateRangeDays, members: Api.StatsAbsValueAndPrev, messages: Api.StatsAbsValueAndPrev, viewers: Api.StatsAbsValueAndPrev, posters: Api.StatsAbsValueAndPrev, growthGraph: Api.StatsGraph, membersGraph: Api.StatsGraph, newMembersBySourceGraph: Api.StatsGraph, languagesGraph: Api.StatsGraph, messagesGraph: Api.StatsGraph, actionsGraph: Api.StatsGraph, topHoursGraph: Api.StatsGraph, weekdaysGraph: Api.StatsGraph, topPosters: [Api.StatsGroupTopPoster], topAdmins: [Api.StatsGroupTopAdmin], topInviters: [Api.StatsGroupTopInviter], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .megagroupStats(let period, let members, let messages, let viewers, let posters, let growthGraph, let membersGraph, let newMembersBySourceGraph, let languagesGraph, let messagesGraph, let actionsGraph, let topHoursGraph, let weekdaysGraph, let topPosters, let topAdmins, let topInviters, let users):
if boxed {
buffer.appendInt32(-276825834)
}
period.serialize(buffer, true)
members.serialize(buffer, true)
messages.serialize(buffer, true)
viewers.serialize(buffer, true)
posters.serialize(buffer, true)
growthGraph.serialize(buffer, true)
membersGraph.serialize(buffer, true)
newMembersBySourceGraph.serialize(buffer, true)
languagesGraph.serialize(buffer, true)
messagesGraph.serialize(buffer, true)
actionsGraph.serialize(buffer, true)
topHoursGraph.serialize(buffer, true)
weekdaysGraph.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(topPosters.count))
for item in topPosters {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(topAdmins.count))
for item in topAdmins {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(topInviters.count))
for item in topInviters {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .megagroupStats(let period, let members, let messages, let viewers, let posters, let growthGraph, let membersGraph, let newMembersBySourceGraph, let languagesGraph, let messagesGraph, let actionsGraph, let topHoursGraph, let weekdaysGraph, let topPosters, let topAdmins, let topInviters, let users):
return ("megagroupStats", [("period", period as Any), ("members", members as Any), ("messages", messages as Any), ("viewers", viewers as Any), ("posters", posters as Any), ("growthGraph", growthGraph as Any), ("membersGraph", membersGraph as Any), ("newMembersBySourceGraph", newMembersBySourceGraph as Any), ("languagesGraph", languagesGraph as Any), ("messagesGraph", messagesGraph as Any), ("actionsGraph", actionsGraph as Any), ("topHoursGraph", topHoursGraph as Any), ("weekdaysGraph", weekdaysGraph as Any), ("topPosters", topPosters as Any), ("topAdmins", topAdmins as Any), ("topInviters", topInviters as Any), ("users", users as Any)])
}
}
public static func parse_megagroupStats(_ reader: BufferReader) -> MegagroupStats? {
var _1: Api.StatsDateRangeDays?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.StatsDateRangeDays
}
var _2: Api.StatsAbsValueAndPrev?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.StatsAbsValueAndPrev
}
var _3: Api.StatsAbsValueAndPrev?
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.StatsAbsValueAndPrev
}
var _4: Api.StatsAbsValueAndPrev?
if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.StatsAbsValueAndPrev
}
var _5: Api.StatsAbsValueAndPrev?
if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.StatsAbsValueAndPrev
}
var _6: Api.StatsGraph?
if let signature = reader.readInt32() {
_6 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _7: Api.StatsGraph?
if let signature = reader.readInt32() {
_7 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _8: Api.StatsGraph?
if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _9: Api.StatsGraph?
if let signature = reader.readInt32() {
_9 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _10: Api.StatsGraph?
if let signature = reader.readInt32() {
_10 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _11: Api.StatsGraph?
if let signature = reader.readInt32() {
_11 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _12: Api.StatsGraph?
if let signature = reader.readInt32() {
_12 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _13: Api.StatsGraph?
if let signature = reader.readInt32() {
_13 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _14: [Api.StatsGroupTopPoster]?
if let _ = reader.readInt32() {
_14 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StatsGroupTopPoster.self)
}
var _15: [Api.StatsGroupTopAdmin]?
if let _ = reader.readInt32() {
_15 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StatsGroupTopAdmin.self)
}
var _16: [Api.StatsGroupTopInviter]?
if let _ = reader.readInt32() {
_16 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StatsGroupTopInviter.self)
}
var _17: [Api.User]?
if let _ = reader.readInt32() {
_17 = 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
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
let _c8 = _8 != nil
let _c9 = _9 != nil
let _c10 = _10 != nil
let _c11 = _11 != nil
let _c12 = _12 != nil
let _c13 = _13 != nil
let _c14 = _14 != nil
let _c15 = _15 != nil
let _c16 = _16 != nil
let _c17 = _17 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 {
return Api.stats.MegagroupStats.megagroupStats(period: _1!, members: _2!, messages: _3!, viewers: _4!, posters: _5!, growthGraph: _6!, membersGraph: _7!, newMembersBySourceGraph: _8!, languagesGraph: _9!, messagesGraph: _10!, actionsGraph: _11!, topHoursGraph: _12!, weekdaysGraph: _13!, topPosters: _14!, topAdmins: _15!, topInviters: _16!, users: _17!)
}
else {
return nil
}
}
}
}
public extension Api.stats {
enum MessageStats: TypeConstructorDescription {
case messageStats(viewsGraph: Api.StatsGraph)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageStats(let viewsGraph):
if boxed {
buffer.appendInt32(-1986399595)
}
viewsGraph.serialize(buffer, true)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageStats(let viewsGraph):
return ("messageStats", [("viewsGraph", viewsGraph as Any)])
}
}
public static func parse_messageStats(_ reader: BufferReader) -> MessageStats? {
var _1: Api.StatsGraph?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
let _c1 = _1 != nil
if _c1 {
return Api.stats.MessageStats.messageStats(viewsGraph: _1!)
}
else {
return nil
}
}
}
}

View File

@ -1,191 +1,3 @@
public extension Api.stats {
enum MegagroupStats: TypeConstructorDescription {
case megagroupStats(period: Api.StatsDateRangeDays, members: Api.StatsAbsValueAndPrev, messages: Api.StatsAbsValueAndPrev, viewers: Api.StatsAbsValueAndPrev, posters: Api.StatsAbsValueAndPrev, growthGraph: Api.StatsGraph, membersGraph: Api.StatsGraph, newMembersBySourceGraph: Api.StatsGraph, languagesGraph: Api.StatsGraph, messagesGraph: Api.StatsGraph, actionsGraph: Api.StatsGraph, topHoursGraph: Api.StatsGraph, weekdaysGraph: Api.StatsGraph, topPosters: [Api.StatsGroupTopPoster], topAdmins: [Api.StatsGroupTopAdmin], topInviters: [Api.StatsGroupTopInviter], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .megagroupStats(let period, let members, let messages, let viewers, let posters, let growthGraph, let membersGraph, let newMembersBySourceGraph, let languagesGraph, let messagesGraph, let actionsGraph, let topHoursGraph, let weekdaysGraph, let topPosters, let topAdmins, let topInviters, let users):
if boxed {
buffer.appendInt32(-276825834)
}
period.serialize(buffer, true)
members.serialize(buffer, true)
messages.serialize(buffer, true)
viewers.serialize(buffer, true)
posters.serialize(buffer, true)
growthGraph.serialize(buffer, true)
membersGraph.serialize(buffer, true)
newMembersBySourceGraph.serialize(buffer, true)
languagesGraph.serialize(buffer, true)
messagesGraph.serialize(buffer, true)
actionsGraph.serialize(buffer, true)
topHoursGraph.serialize(buffer, true)
weekdaysGraph.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(topPosters.count))
for item in topPosters {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(topAdmins.count))
for item in topAdmins {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(topInviters.count))
for item in topInviters {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .megagroupStats(let period, let members, let messages, let viewers, let posters, let growthGraph, let membersGraph, let newMembersBySourceGraph, let languagesGraph, let messagesGraph, let actionsGraph, let topHoursGraph, let weekdaysGraph, let topPosters, let topAdmins, let topInviters, let users):
return ("megagroupStats", [("period", period as Any), ("members", members as Any), ("messages", messages as Any), ("viewers", viewers as Any), ("posters", posters as Any), ("growthGraph", growthGraph as Any), ("membersGraph", membersGraph as Any), ("newMembersBySourceGraph", newMembersBySourceGraph as Any), ("languagesGraph", languagesGraph as Any), ("messagesGraph", messagesGraph as Any), ("actionsGraph", actionsGraph as Any), ("topHoursGraph", topHoursGraph as Any), ("weekdaysGraph", weekdaysGraph as Any), ("topPosters", topPosters as Any), ("topAdmins", topAdmins as Any), ("topInviters", topInviters as Any), ("users", users as Any)])
}
}
public static func parse_megagroupStats(_ reader: BufferReader) -> MegagroupStats? {
var _1: Api.StatsDateRangeDays?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.StatsDateRangeDays
}
var _2: Api.StatsAbsValueAndPrev?
if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.StatsAbsValueAndPrev
}
var _3: Api.StatsAbsValueAndPrev?
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.StatsAbsValueAndPrev
}
var _4: Api.StatsAbsValueAndPrev?
if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.StatsAbsValueAndPrev
}
var _5: Api.StatsAbsValueAndPrev?
if let signature = reader.readInt32() {
_5 = Api.parse(reader, signature: signature) as? Api.StatsAbsValueAndPrev
}
var _6: Api.StatsGraph?
if let signature = reader.readInt32() {
_6 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _7: Api.StatsGraph?
if let signature = reader.readInt32() {
_7 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _8: Api.StatsGraph?
if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _9: Api.StatsGraph?
if let signature = reader.readInt32() {
_9 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _10: Api.StatsGraph?
if let signature = reader.readInt32() {
_10 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _11: Api.StatsGraph?
if let signature = reader.readInt32() {
_11 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _12: Api.StatsGraph?
if let signature = reader.readInt32() {
_12 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _13: Api.StatsGraph?
if let signature = reader.readInt32() {
_13 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
var _14: [Api.StatsGroupTopPoster]?
if let _ = reader.readInt32() {
_14 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StatsGroupTopPoster.self)
}
var _15: [Api.StatsGroupTopAdmin]?
if let _ = reader.readInt32() {
_15 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StatsGroupTopAdmin.self)
}
var _16: [Api.StatsGroupTopInviter]?
if let _ = reader.readInt32() {
_16 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StatsGroupTopInviter.self)
}
var _17: [Api.User]?
if let _ = reader.readInt32() {
_17 = 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
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
let _c8 = _8 != nil
let _c9 = _9 != nil
let _c10 = _10 != nil
let _c11 = _11 != nil
let _c12 = _12 != nil
let _c13 = _13 != nil
let _c14 = _14 != nil
let _c15 = _15 != nil
let _c16 = _16 != nil
let _c17 = _17 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 {
return Api.stats.MegagroupStats.megagroupStats(period: _1!, members: _2!, messages: _3!, viewers: _4!, posters: _5!, growthGraph: _6!, membersGraph: _7!, newMembersBySourceGraph: _8!, languagesGraph: _9!, messagesGraph: _10!, actionsGraph: _11!, topHoursGraph: _12!, weekdaysGraph: _13!, topPosters: _14!, topAdmins: _15!, topInviters: _16!, users: _17!)
}
else {
return nil
}
}
}
}
public extension Api.stats {
enum MessageStats: TypeConstructorDescription {
case messageStats(viewsGraph: Api.StatsGraph)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageStats(let viewsGraph):
if boxed {
buffer.appendInt32(-1986399595)
}
viewsGraph.serialize(buffer, true)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageStats(let viewsGraph):
return ("messageStats", [("viewsGraph", viewsGraph as Any)])
}
}
public static func parse_messageStats(_ reader: BufferReader) -> MessageStats? {
var _1: Api.StatsGraph?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.StatsGraph
}
let _c1 = _1 != nil
if _c1 {
return Api.stats.MessageStats.messageStats(viewsGraph: _1!)
}
else {
return nil
}
}
}
}
public extension Api.stickers {
enum SuggestedShortName: TypeConstructorDescription {
case suggestedShortName(shortName: String)
@ -360,21 +172,26 @@ public extension Api.storage {
}
public extension Api.stories {
enum AllStories: TypeConstructorDescription {
case allStories(flags: Int32, count: Int32, state: String, userStories: [Api.UserStories], users: [Api.User], stealthMode: Api.StoriesStealthMode)
case allStories(flags: Int32, count: Int32, state: String, peerStories: [Api.PeerStories], chats: [Api.Chat], users: [Api.User], stealthMode: Api.StoriesStealthMode)
case allStoriesNotModified(flags: Int32, state: String, stealthMode: Api.StoriesStealthMode)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .allStories(let flags, let count, let state, let userStories, let users, let stealthMode):
case .allStories(let flags, let count, let state, let peerStories, let chats, let users, let stealthMode):
if boxed {
buffer.appendInt32(1369278878)
buffer.appendInt32(1862033025)
}
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))
for item in userStories {
buffer.appendInt32(Int32(peerStories.count))
for item in peerStories {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
@ -397,8 +214,8 @@ public extension Api.stories {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .allStories(let flags, let count, let state, let userStories, let users, let stealthMode):
return ("allStories", [("flags", flags as Any), ("count", count as Any), ("state", state as Any), ("userStories", userStories as Any), ("users", users as Any), ("stealthMode", stealthMode as Any)])
case .allStories(let flags, let count, let state, let peerStories, let chats, let users, let stealthMode):
return ("allStories", [("flags", flags as Any), ("count", count as Any), ("state", state as Any), ("peerStories", peerStories as Any), ("chats", chats as Any), ("users", users as Any), ("stealthMode", stealthMode as Any)])
case .allStoriesNotModified(let flags, let state, let stealthMode):
return ("allStoriesNotModified", [("flags", flags as Any), ("state", state as Any), ("stealthMode", stealthMode as Any)])
}
@ -411,17 +228,21 @@ public extension Api.stories {
_2 = reader.readInt32()
var _3: String?
_3 = parseString(reader)
var _4: [Api.UserStories]?
var _4: [Api.PeerStories]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.UserStories.self)
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PeerStories.self)
}
var _5: [Api.User]?
var _5: [Api.Chat]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _6: Api.StoriesStealthMode?
var _6: [Api.User]?
if let _ = reader.readInt32() {
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
var _7: Api.StoriesStealthMode?
if let signature = reader.readInt32() {
_6 = Api.parse(reader, signature: signature) as? Api.StoriesStealthMode
_7 = Api.parse(reader, signature: signature) as? Api.StoriesStealthMode
}
let _c1 = _1 != nil
let _c2 = _2 != nil
@ -429,8 +250,9 @@ public extension Api.stories {
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.stories.AllStories.allStories(flags: _1!, count: _2!, state: _3!, userStories: _4!, users: _5!, stealthMode: _6!)
let _c7 = _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.stories.AllStories.allStories(flags: _1!, count: _2!, state: _3!, peerStories: _4!, chats: _5!, users: _6!, stealthMode: _7!)
}
else {
return nil
@ -459,19 +281,19 @@ public extension Api.stories {
}
}
public extension Api.stories {
enum Stories: TypeConstructorDescription {
case stories(count: Int32, stories: [Api.StoryItem], users: [Api.User])
enum PeerStories: TypeConstructorDescription {
case peerStories(stories: Api.PeerStories, chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .stories(let count, let stories, let users):
case .peerStories(let stories, let chats, let users):
if boxed {
buffer.appendInt32(1340440049)
buffer.appendInt32(-890861720)
}
serializeInt32(count, buffer: buffer, boxed: false)
stories.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(stories.count))
for item in stories {
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
@ -485,8 +307,71 @@ public extension Api.stories {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .stories(let count, let stories, let users):
return ("stories", [("count", count as Any), ("stories", stories as Any), ("users", users as Any)])
case .peerStories(let stories, let chats, let users):
return ("peerStories", [("stories", stories as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_peerStories(_ reader: BufferReader) -> PeerStories? {
var _1: Api.PeerStories?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.PeerStories
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.stories.PeerStories.peerStories(stories: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}
public extension Api.stories {
enum Stories: TypeConstructorDescription {
case stories(count: Int32, stories: [Api.StoryItem], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .stories(let count, let stories, let chats, let users):
if boxed {
buffer.appendInt32(1574486984)
}
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(stories.count))
for item in stories {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .stories(let count, let stories, let chats, let users):
return ("stories", [("count", count as Any), ("stories", stories as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
@ -497,15 +382,20 @@ public extension Api.stories {
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StoryItem.self)
}
var _3: [Api.User]?
var _3: [Api.Chat]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _4: [Api.User]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.stories.Stories.stories(count: _1!, stories: _2!, users: _3!)
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.stories.Stories.stories(count: _1!, stories: _2!, chats: _3!, users: _4!)
}
else {
return nil
@ -634,54 +524,6 @@ public extension Api.stories {
}
}
public extension Api.stories {
enum UserStories: TypeConstructorDescription {
case userStories(stories: Api.UserStories, users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .userStories(let stories, let users):
if boxed {
buffer.appendInt32(933691231)
}
stories.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .userStories(let stories, let users):
return ("userStories", [("stories", stories as Any), ("users", users as Any)])
}
}
public static func parse_userStories(_ reader: BufferReader) -> UserStories? {
var _1: Api.UserStories?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.UserStories
}
var _2: [Api.User]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.stories.UserStories.userStories(stories: _1!, users: _2!)
}
else {
return nil
}
}
}
}
public extension Api.updates {
enum ChannelDifference: TypeConstructorDescription {
case channelDifference(flags: Int32, pts: Int32, timeout: Int32?, newMessages: [Api.Message], otherUpdates: [Api.Update], chats: [Api.Chat], users: [Api.User])
@ -1308,3 +1150,61 @@ public extension Api.upload {
}
}
public extension Api.users {
enum UserFull: TypeConstructorDescription {
case userFull(fullUser: Api.UserFull, chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .userFull(let fullUser, let chats, let users):
if boxed {
buffer.appendInt32(997004590)
}
fullUser.serialize(buffer, true)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .userFull(let fullUser, let chats, let users):
return ("userFull", [("fullUser", fullUser as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_userFull(_ reader: BufferReader) -> UserFull? {
var _1: Api.UserFull?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.UserFull
}
var _2: [Api.Chat]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _3: [Api.User]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.users.UserFull.userFull(fullUser: _1!, chats: _2!, users: _3!)
}
else {
return nil
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -282,7 +282,7 @@ public extension Api {
case inputMediaPhoto(flags: Int32, id: Api.InputPhoto, ttlSeconds: Int32?)
case inputMediaPhotoExternal(flags: Int32, url: String, ttlSeconds: Int32?)
case inputMediaPoll(flags: Int32, poll: Api.Poll, correctAnswers: [Buffer]?, solution: String?, solutionEntities: [Api.MessageEntity]?)
case inputMediaStory(userId: Api.InputUser, id: Int32)
case inputMediaStory(peer: Api.InputPeer, id: Int32)
case inputMediaUploadedDocument(flags: Int32, file: Api.InputFile, thumb: Api.InputFile?, mimeType: String, attributes: [Api.DocumentAttribute], stickers: [Api.InputDocument]?, ttlSeconds: Int32?)
case inputMediaUploadedPhoto(flags: Int32, file: Api.InputFile, stickers: [Api.InputDocument]?, ttlSeconds: Int32?)
case inputMediaVenue(geoPoint: Api.InputGeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String)
@ -398,11 +398,11 @@ public extension Api {
item.serialize(buffer, true)
}}
break
case .inputMediaStory(let userId, let id):
case .inputMediaStory(let peer, let id):
if boxed {
buffer.appendInt32(-1702447729)
buffer.appendInt32(-1979852936)
}
userId.serialize(buffer, true)
peer.serialize(buffer, true)
serializeInt32(id, buffer: buffer, boxed: false)
break
case .inputMediaUploadedDocument(let flags, let file, let thumb, let mimeType, let attributes, let stickers, let ttlSeconds):
@ -478,8 +478,8 @@ public extension Api {
return ("inputMediaPhotoExternal", [("flags", flags as Any), ("url", url as Any), ("ttlSeconds", ttlSeconds as Any)])
case .inputMediaPoll(let flags, let poll, let correctAnswers, let solution, let solutionEntities):
return ("inputMediaPoll", [("flags", flags as Any), ("poll", poll as Any), ("correctAnswers", correctAnswers as Any), ("solution", solution as Any), ("solutionEntities", solutionEntities as Any)])
case .inputMediaStory(let userId, let id):
return ("inputMediaStory", [("userId", userId as Any), ("id", id as Any)])
case .inputMediaStory(let peer, let id):
return ("inputMediaStory", [("peer", peer as Any), ("id", id as Any)])
case .inputMediaUploadedDocument(let flags, let file, let thumb, let mimeType, let attributes, let stickers, let ttlSeconds):
return ("inputMediaUploadedDocument", [("flags", flags as Any), ("file", file as Any), ("thumb", thumb as Any), ("mimeType", mimeType as Any), ("attributes", attributes as Any), ("stickers", stickers as Any), ("ttlSeconds", ttlSeconds as Any)])
case .inputMediaUploadedPhoto(let flags, let file, let stickers, let ttlSeconds):
@ -725,16 +725,16 @@ public extension Api {
}
}
public static func parse_inputMediaStory(_ reader: BufferReader) -> InputMedia? {
var _1: Api.InputUser?
var _1: Api.InputPeer?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.InputUser
_1 = Api.parse(reader, signature: signature) as? Api.InputPeer
}
var _2: Int32?
_2 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.InputMedia.inputMediaStory(userId: _1!, id: _2!)
return Api.InputMedia.inputMediaStory(peer: _1!, id: _2!)
}
else {
return nil

View File

@ -380,9 +380,9 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI
}
case let .messageMediaDice(value, emoticon):
return (TelegramMediaDice(emoji: emoticon, value: value), nil, nil, nil)
case let .messageMediaStory(flags, userId, id, _):
case let .messageMediaStory(flags, peerId, id, _):
let isMention = (flags & (1 << 1)) != 0
return (TelegramMediaStory(storyId: StoryId(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), id: id), isMention: isMention), nil, nil, nil)
return (TelegramMediaStory(storyId: StoryId(peerId: peerId.peerId, id: id), isMention: isMention), nil, nil, nil)
}
}

View File

@ -45,8 +45,8 @@ func telegramMediaWebpageFromApiWebpage(_ webpage: Api.WebPage, url: String?) ->
if let attributes = attributes {
webpageAttributes = attributes.compactMap(telegramMediaWebpageAttributeFromApiWebpageAttribute)
for attribute in attributes {
if case let .webPageAttributeStory(_, userId, id, _) = attribute {
story = TelegramMediaStory(storyId: StoryId(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), id: id), isMention: false)
if case let .webPageAttributeStory(_, peerId, id, _) = attribute {
story = TelegramMediaStory(storyId: StoryId(peerId: peerId.peerId, id: id), isMention: false)
}
}
}

View File

@ -88,12 +88,11 @@ func messageContentToUpload(accountPeerId: PeerId, network: Network, postbox: Po
} else if let contextResult = contextResult {
return .immediate(.content(PendingMessageUploadedContentAndReuploadInfo(content: .chatContextResult(contextResult), reuploadInfo: nil, cacheReferenceKey: nil)), .text)
} else if let media = media.first as? TelegramMediaStory {
//Signal<PendingMessageUploadedContentResult, PendingMessageUploadError>
return .signal(postbox.transaction { transaction -> PendingMessageUploadedContentResult in
guard let inputUser = transaction.getPeer(media.storyId.peerId).flatMap(apiInputUser) else {
guard let inputPeer = transaction.getPeer(media.storyId.peerId).flatMap(apiInputPeer) else {
return .progress(0.0)
}
return .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaStory(userId: inputUser, id: media.storyId.id), ""), reuploadInfo: nil, cacheReferenceKey: nil))
return .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaStory(peer: inputPeer, id: media.storyId.id), ""), reuploadInfo: nil, cacheReferenceKey: nil))
}
|> castError(PendingMessageUploadError.self), .text)
} else if let media = media.first, let mediaResult = mediaContentToUpload(accountPeerId: accountPeerId, network: network, postbox: postbox, auxiliaryMethods: auxiliaryMethods, transformOutgoingMessageMedia: transformOutgoingMessageMedia, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: revalidationContext, forceReupload: forceReupload, isGrouped: isGrouped, passFetchProgress: passFetchProgress, forceNoBigParts: forceNoBigParts, peerId: peerId, media: media, text: text, autoremoveMessageAttribute: autoremoveMessageAttribute, autoclearMessageAttribute: autoclearMessageAttribute, messageId: messageId, attributes: attributes) {

View File

@ -1673,14 +1673,14 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
updatedState.reloadConfig()
case let .updateMessageExtendedMedia(peer, msgId, extendedMedia):
updatedState.updateExtendedMedia(MessageId(peerId: peer.peerId, namespace: Namespaces.Message.Cloud, id: msgId), extendedMedia: extendedMedia)
case let .updateStory(userId, story):
updatedState.updateStory(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), story: story)
case let .updateReadStories(userId, id):
updatedState.readStories(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), maxId: id)
case let .updateStory(peerId, story):
updatedState.updateStory(peerId: peerId.peerId, story: story)
case let .updateReadStories(peerId, id):
updatedState.readStories(peerId: peerId.peerId, maxId: id)
case let .updateStoriesStealthMode(stealthMode):
updatedState.updateStoryStealthMode(stealthMode)
case let .updateSentStoryReaction(userId, storyId, reaction):
updatedState.updateStorySentReaction(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), id: storyId, reaction: reaction)
case let .updateSentStoryReaction(peerId, storyId, reaction):
updatedState.updateStorySentReaction(peerId: peerId.peerId, id: storyId, reaction: reaction)
default:
break
}

View File

@ -1304,17 +1304,17 @@ public final class AccountViewTracker {
self.nextUpdatedUnsupportedMediaDisposableId += 1
if let account = self.account {
let signal = account.postbox.transaction { transaction -> [(PeerId, Api.InputUser)] in
return addedPeerIds.compactMap { id -> (PeerId, Api.InputUser)? in
if let user = transaction.getPeer(id).flatMap(apiInputUser) {
let signal = account.postbox.transaction { transaction -> [(PeerId, Api.InputPeer)] in
return addedPeerIds.compactMap { id -> (PeerId, Api.InputPeer)? in
if let user = transaction.getPeer(id).flatMap(apiInputPeer) {
return (id, user)
} else {
return nil
}
}
}
|> mapToSignal { inputUsers -> Signal<Never, NoError> in
guard !inputUsers.isEmpty else {
|> mapToSignal { inputPeers -> Signal<Never, NoError> in
guard !inputPeers.isEmpty else {
return .complete()
}
@ -1322,10 +1322,10 @@ public final class AccountViewTracker {
let batchCount = 100
var startIndex = 0
while startIndex < inputUsers.count {
var slice: [(PeerId, Api.InputUser)] = []
for i in startIndex ..< min(startIndex + batchCount, inputUsers.count) {
slice.append(inputUsers[i])
while startIndex < inputPeers.count {
var slice: [(PeerId, Api.InputPeer)] = []
for i in startIndex ..< min(startIndex + batchCount, inputPeers.count) {
slice.append(inputPeers[i])
}
startIndex += batchCount
requests.append(account.network.request(Api.functions.users.getStoriesMaxIDs(id: slice.map(\.1)))

View File

@ -119,10 +119,10 @@ func managedSynchronizeViewStoriesOperations(postbox: Postbox, network: Network,
}
private func pushStoriesAreSeen(postbox: Postbox, network: Network, stateManager: AccountStateManager, peer: Peer, operation: SynchronizeViewStoriesOperation) -> Signal<Void, NoError> {
guard let inputPeer = apiInputUser(peer) else {
guard let inputPeer = apiInputPeer(peer) else {
return .complete()
}
return network.request(Api.functions.stories.readStories(userId: inputPeer, maxId: operation.storyId))
return network.request(Api.functions.stories.readStories(peer: inputPeer, maxId: operation.storyId))
|> `catch` { _ -> Signal<[Int32], NoError> in
return .single([])
}

View File

@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
public class Serialization: NSObject, MTSerialization {
public func currentLayer() -> UInt {
return 162
return 163
}
public func parseMessage(_ data: Data!) -> Any! {

View File

@ -88,9 +88,9 @@ extension Api.MessageMedia {
var preCachedStories: [StoryId: Api.StoryItem]? {
switch self {
case let .messageMediaStory(_, userId, id, story):
case let .messageMediaStory(_, peerId, id, story):
if let story = story {
return [StoryId(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), id: id): story]
return [StoryId(peerId: peerId.peerId, id: id): story]
} else {
return nil
}

View File

@ -4,8 +4,44 @@ import Postbox
import TelegramApi
public extension Stories {
enum PendingTarget: Codable {
private enum CodingKeys: String, CodingKey {
case discriminator = "tt"
case peerId = "peerId"
}
case myStories
case peer(PeerId)
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
switch try container.decode(Int32.self, forKey: .discriminator) {
case 0:
self = .myStories
case 1:
self = .peer(try container.decode(PeerId.self, forKey: .peerId))
default:
self = .myStories
}
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
switch self {
case .myStories:
try container.encode(0 as Int32, forKey: .discriminator)
case let .peer(peerId):
try container.encode(1 as Int32, forKey: .discriminator)
try container.encode(peerId, forKey: .peerId)
}
}
}
final class PendingItem: Equatable, Codable {
private enum CodingKeys: CodingKey {
case target
case stableId
case timestamp
case media
@ -20,6 +56,7 @@ public extension Stories {
case randomId
}
public let target: PendingTarget
public let stableId: Int32
public let timestamp: Int32
public let media: Media
@ -34,6 +71,7 @@ public extension Stories {
public let randomId: Int64
public init(
target: PendingTarget,
stableId: Int32,
timestamp: Int32,
media: Media,
@ -47,6 +85,7 @@ public extension Stories {
period: Int32,
randomId: Int64
) {
self.target = target
self.stableId = stableId
self.timestamp = timestamp
self.media = media
@ -64,6 +103,7 @@ public extension Stories {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.target = try container.decodeIfPresent(PendingTarget.self, forKey: .target) ?? .myStories
self.stableId = try container.decode(Int32.self, forKey: .stableId)
self.timestamp = try container.decode(Int32.self, forKey: .timestamp)
@ -88,6 +128,8 @@ public extension Stories {
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.target, forKey: .target)
try container.encode(self.stableId, forKey: .stableId)
try container.encode(self.timestamp, forKey: .timestamp)
@ -199,9 +241,9 @@ final class PendingStoryManager {
return self.allStoriesEventsPipe.signal()
}
private let allStoriesUploadProgressPromise = Promise<Float?>(nil)
private var allStoriesUploadProgressValue: Float? = nil
var allStoriesUploadProgress: Signal<Float?, NoError> {
private let allStoriesUploadProgressPromise = Promise<[PeerId: Float]>([:])
private var allStoriesUploadProgressValue: [PeerId: Float] = [:]
var allStoriesUploadProgress: Signal<[PeerId: Float], NoError> {
return self.allStoriesUploadProgressPromise.get()
}
@ -301,8 +343,15 @@ final class PendingStoryManager {
})
self.currentPendingItemContext = pendingItemContext
let toPeerId: PeerId
switch firstItem.target {
case .myStories:
toPeerId = self.accountPeerId
case let .peer(peerId):
toPeerId = peerId
}
let stableId = firstItem.stableId
pendingItemContext.disposable = (_internal_uploadStoryImpl(postbox: self.postbox, network: self.network, accountPeerId: self.accountPeerId, stateManager: self.stateManager, messageMediaPreuploadManager: self.messageMediaPreuploadManager, revalidationContext: self.revalidationContext, auxiliaryMethods: self.auxiliaryMethods, stableId: stableId, media: firstItem.media, mediaAreas: firstItem.mediaAreas, text: firstItem.text, entities: firstItem.entities, embeddedStickers: firstItem.embeddedStickers, pin: firstItem.pin, privacy: firstItem.privacy, isForwardingDisabled: firstItem.isForwardingDisabled, period: Int(firstItem.period), randomId: firstItem.randomId)
pendingItemContext.disposable = (_internal_uploadStoryImpl(postbox: self.postbox, network: self.network, accountPeerId: self.accountPeerId, stateManager: self.stateManager, messageMediaPreuploadManager: self.messageMediaPreuploadManager, revalidationContext: self.revalidationContext, auxiliaryMethods: self.auxiliaryMethods, toPeerId: toPeerId, stableId: stableId, media: firstItem.media, mediaAreas: firstItem.mediaAreas, text: firstItem.text, entities: firstItem.entities, embeddedStickers: firstItem.embeddedStickers, pin: firstItem.pin, privacy: firstItem.privacy, isForwardingDisabled: firstItem.isForwardingDisabled, period: Int(firstItem.period), randomId: firstItem.randomId)
|> deliverOn(self.queue)).start(next: { [weak self] event in
guard let `self` = self else {
return
@ -327,17 +376,26 @@ final class PendingStoryManager {
}
private func processContextsUpdated() {
let currentProgress = self.currentPendingItemContext?.progress
var currentProgress: [PeerId: Float] = [:]
if let currentPendingItemContext = self.currentPendingItemContext {
switch currentPendingItemContext.item.target {
case .myStories:
currentProgress[self.accountPeerId] = currentPendingItemContext.progress
case let .peer(id):
currentProgress[id] = currentPendingItemContext.progress
}
}
if self.allStoriesUploadProgressValue != currentProgress {
let previousProgress = self.allStoriesUploadProgressValue
self.allStoriesUploadProgressValue = currentProgress
if previousProgress != nil && currentProgress == nil {
if !previousProgress.isEmpty && currentProgress.isEmpty {
// Hack: the UI is updated after 2 Postbox queries
let signal: Signal<Float?, NoError> = Signal { subscriber in
let signal: Signal<[PeerId: Float], NoError> = Signal { subscriber in
Postbox.sharedQueue.justDispatch {
Postbox.sharedQueue.justDispatch {
subscriber.putNext(nil)
subscriber.putNext([:])
}
}
return EmptyDisposable
@ -358,7 +416,7 @@ final class PendingStoryManager {
private let impl: QueueLocalObject<Impl>
private let accountPeerId: PeerId
public var allStoriesUploadProgress: Signal<Float?, NoError> {
public var allStoriesUploadProgress: Signal<[PeerId: Float], NoError> {
return self.impl.signalWith { impl, subscriber in
return impl.allStoriesUploadProgress.start(next: subscriber.putNext)
}
@ -391,7 +449,7 @@ final class PendingStoryManager {
})
}
func lookUpPendingStoryIdMapping(stableId: Int32) -> Int32? {
return _internal_lookUpPendingStoryIdMapping(accountPeerId: self.accountPeerId, stableId: stableId)
func lookUpPendingStoryIdMapping(peerId: PeerId, stableId: Int32) -> Int32? {
return _internal_lookUpPendingStoryIdMapping(peerId: peerId, stableId: stableId)
}
}

View File

@ -806,7 +806,7 @@ private func apiInputPrivacyRules(privacy: EngineStoryPrivacy, transaction: Tran
return privacyRules
}
func _internal_uploadStory(account: Account, media: EngineStoryInputMedia, mediaAreas: [MediaArea], text: String, entities: [MessageTextEntity], pin: Bool, privacy: EngineStoryPrivacy, isForwardingDisabled: Bool, period: Int, randomId: Int64) -> Signal<Int32, NoError> {
func _internal_uploadStory(account: Account, target: Stories.PendingTarget, media: EngineStoryInputMedia, mediaAreas: [MediaArea], text: String, entities: [MessageTextEntity], pin: Bool, privacy: EngineStoryPrivacy, isForwardingDisabled: Bool, period: Int, randomId: Int64) -> Signal<Int32, NoError> {
let inputMedia = prepareUploadStoryContent(account: account, media: media)
return (account.postbox.transaction { transaction in
@ -821,6 +821,7 @@ func _internal_uploadStory(account: Account, media: EngineStoryInputMedia, media
stableId = Int32.random(in: 2000000 ..< Int32.max)
}
currentState.items.append(Stories.PendingItem(
target: target,
stableId: stableId,
timestamp: Int32(Date().timeIntervalSince1970),
media: inputMedia,
@ -855,176 +856,186 @@ func _internal_cancelStoryUpload(account: Account, stableId: Int32) {
}
private struct PendingStoryIdMappingKey: Hashable {
var accountPeerId: PeerId
var peerId: PeerId
var stableId: Int32
}
private let pendingStoryIdMapping = Atomic<[PendingStoryIdMappingKey: Int32]>(value: [:])
func _internal_lookUpPendingStoryIdMapping(accountPeerId: PeerId, stableId: Int32) -> Int32? {
func _internal_lookUpPendingStoryIdMapping(peerId: PeerId, stableId: Int32) -> Int32? {
return pendingStoryIdMapping.with { dict in
return dict[PendingStoryIdMappingKey(accountPeerId: accountPeerId, stableId: stableId)]
return dict[PendingStoryIdMappingKey(peerId: peerId, stableId: stableId)]
}
}
private func _internal_putPendingStoryIdMapping(accountPeerId: PeerId, stableId: Int32, id: Int32) {
private func _internal_putPendingStoryIdMapping(peerId: PeerId, stableId: Int32, id: Int32) {
let _ = pendingStoryIdMapping.modify { dict in
var dict = dict
dict[PendingStoryIdMappingKey(accountPeerId: accountPeerId, stableId: stableId)] = id
dict[PendingStoryIdMappingKey(peerId: peerId, stableId: stableId)] = id
return dict
}
}
func _internal_uploadStoryImpl(postbox: Postbox, network: Network, accountPeerId: PeerId, stateManager: AccountStateManager, messageMediaPreuploadManager: MessageMediaPreuploadManager, revalidationContext: MediaReferenceRevalidationContext, auxiliaryMethods: AccountAuxiliaryMethods, stableId: Int32, media: Media, mediaAreas: [MediaArea], text: String, entities: [MessageTextEntity], embeddedStickers: [TelegramMediaFile], pin: Bool, privacy: EngineStoryPrivacy, isForwardingDisabled: Bool, period: Int, randomId: Int64) -> Signal<StoryUploadResult, NoError> {
let passFetchProgress = media is TelegramMediaFile
let (contentSignal, originalMedia) = uploadedStoryContent(postbox: postbox, network: network, media: media, embeddedStickers: embeddedStickers, accountPeerId: accountPeerId, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: revalidationContext, auxiliaryMethods: auxiliaryMethods, passFetchProgress: passFetchProgress)
return contentSignal
|> mapToSignal { result -> Signal<StoryUploadResult, NoError> in
switch result {
case let .progress(progress):
return .single(.progress(progress))
case let .content(content):
return postbox.transaction { transaction -> Signal<StoryUploadResult, NoError> in
let privacyRules = apiInputPrivacyRules(privacy: privacy, transaction: transaction)
switch content.content {
case let .media(inputMedia, _):
var flags: Int32 = 0
var apiCaption: String?
var apiEntities: [Api.MessageEntity]?
if pin {
flags |= 1 << 2
}
if !text.isEmpty {
flags |= 1 << 0
apiCaption = text
func _internal_uploadStoryImpl(postbox: Postbox, network: Network, accountPeerId: PeerId, stateManager: AccountStateManager, messageMediaPreuploadManager: MessageMediaPreuploadManager, revalidationContext: MediaReferenceRevalidationContext, auxiliaryMethods: AccountAuxiliaryMethods, toPeerId: PeerId, stableId: Int32, media: Media, mediaAreas: [MediaArea], text: String, entities: [MessageTextEntity], embeddedStickers: [TelegramMediaFile], pin: Bool, privacy: EngineStoryPrivacy, isForwardingDisabled: Bool, period: Int, randomId: Int64) -> Signal<StoryUploadResult, NoError> {
return postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(toPeerId).flatMap(apiInputPeer)
}
|> mapToSignal { inputPeer -> Signal<StoryUploadResult, NoError> in
guard let inputPeer else {
return .single(.completed(nil))
}
let passFetchProgress = media is TelegramMediaFile
let (contentSignal, originalMedia) = uploadedStoryContent(postbox: postbox, network: network, media: media, embeddedStickers: embeddedStickers, accountPeerId: accountPeerId, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: revalidationContext, auxiliaryMethods: auxiliaryMethods, passFetchProgress: passFetchProgress)
return contentSignal
|> mapToSignal { result -> Signal<StoryUploadResult, NoError> in
switch result {
case let .progress(progress):
return .single(.progress(progress))
case let .content(content):
return postbox.transaction { transaction -> Signal<StoryUploadResult, NoError> in
let privacyRules = apiInputPrivacyRules(privacy: privacy, transaction: transaction)
switch content.content {
case let .media(inputMedia, _):
var flags: Int32 = 0
var apiCaption: String?
var apiEntities: [Api.MessageEntity]?
if !entities.isEmpty {
flags |= 1 << 1
var associatedPeers: [PeerId: Peer] = [:]
for entity in entities {
for entityPeerId in entity.associatedPeerIds {
if let peer = transaction.getPeer(entityPeerId) {
associatedPeers[peer.id] = peer
}
}
}
apiEntities = apiEntitiesFromMessageTextEntities(entities, associatedPeers: SimpleDictionary(associatedPeers))
if pin {
flags |= 1 << 2
}
}
flags |= 1 << 3
if isForwardingDisabled {
flags |= 1 << 4
}
let inputMediaAreas: [Api.MediaArea] = apiMediaAreasFromMediaAreas(mediaAreas)
if !inputMediaAreas.isEmpty {
flags |= 1 << 5
}
return network.request(Api.functions.stories.sendStory(
flags: flags,
media: inputMedia,
mediaAreas: inputMediaAreas,
caption: apiCaption,
entities: apiEntities,
privacyRules: privacyRules,
randomId: randomId,
period: Int32(period)
))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
return .single(nil)
}
|> mapToSignal { updates -> Signal<StoryUploadResult, NoError> in
return postbox.transaction { transaction -> StoryUploadResult in
var currentState: Stories.LocalState
if let value = transaction.getLocalStoryState()?.get(Stories.LocalState.self) {
currentState = value
} else {
currentState = Stories.LocalState(items: [])
}
if let index = currentState.items.firstIndex(where: { $0.stableId == stableId }) {
currentState.items.remove(at: index)
transaction.setLocalStoryState(state: CodableEntry(currentState))
}
if !text.isEmpty {
flags |= 1 << 0
apiCaption = text
var id: Int32?
if let updates = updates {
for update in updates.allUpdates {
if case let .updateStory(_, story) = update {
switch story {
case let .storyItem(_, idValue, _, _, _, _, media, _, _, _, _):
if let parsedStory = Stories.StoredItem(apiStoryItem: story, peerId: accountPeerId, transaction: transaction) {
var items = transaction.getStoryItems(peerId: accountPeerId)
var updatedItems: [Stories.Item] = []
if items.firstIndex(where: { $0.id == id }) == nil, case let .item(item) = parsedStory {
let updatedItem = Stories.Item(
id: item.id,
timestamp: item.timestamp,
expirationTimestamp: item.expirationTimestamp,
media: item.media,
mediaAreas: item.mediaAreas,
text: item.text,
entities: item.entities,
views: item.views,
privacy: Stories.Item.Privacy(base: privacy.base, additionallyIncludePeers: privacy.additionallyIncludePeers),
isPinned: item.isPinned,
isExpired: item.isExpired,
isPublic: item.isPublic,
isCloseFriends: item.isCloseFriends,
isContacts: item.isContacts,
isSelectedContacts: item.isSelectedContacts,
isForwardingDisabled: item.isForwardingDisabled,
isEdited: item.isEdited,
myReaction: item.myReaction
)
if let entry = CodableEntry(Stories.StoredItem.item(updatedItem)) {
items.append(StoryItemsTableEntry(value: entry, id: item.id, expirationTimestamp: updatedItem.expirationTimestamp, isCloseFriends: updatedItem.isCloseFriends))
}
updatedItems.append(updatedItem)
}
transaction.setStoryItems(peerId: accountPeerId, items: items)
}
id = idValue
let (parsedMedia, _, _, _) = textMediaAndExpirationTimerFromApiMedia(media, accountPeerId)
if let parsedMedia = parsedMedia {
applyMediaResourceChanges(from: originalMedia, to: parsedMedia, postbox: postbox, force: originalMedia is TelegramMediaFile && parsedMedia is TelegramMediaFile)
}
default:
break
if !entities.isEmpty {
flags |= 1 << 1
var associatedPeers: [PeerId: Peer] = [:]
for entity in entities {
for entityPeerId in entity.associatedPeerIds {
if let peer = transaction.getPeer(entityPeerId) {
associatedPeers[peer.id] = peer
}
}
}
if let id = id {
_internal_putPendingStoryIdMapping(accountPeerId: accountPeerId, stableId: stableId, id: id)
apiEntities = apiEntitiesFromMessageTextEntities(entities, associatedPeers: SimpleDictionary(associatedPeers))
}
}
flags |= 1 << 3
if isForwardingDisabled {
flags |= 1 << 4
}
let inputMediaAreas: [Api.MediaArea] = apiMediaAreasFromMediaAreas(mediaAreas)
if !inputMediaAreas.isEmpty {
flags |= 1 << 5
}
return network.request(Api.functions.stories.sendStory(
flags: flags,
peer: inputPeer,
media: inputMedia,
mediaAreas: inputMediaAreas,
caption: apiCaption,
entities: apiEntities,
privacyRules: privacyRules,
randomId: randomId,
period: Int32(period)
))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
return .single(nil)
}
|> mapToSignal { updates -> Signal<StoryUploadResult, NoError> in
return postbox.transaction { transaction -> StoryUploadResult in
var currentState: Stories.LocalState
if let value = transaction.getLocalStoryState()?.get(Stories.LocalState.self) {
currentState = value
} else {
currentState = Stories.LocalState(items: [])
}
if let index = currentState.items.firstIndex(where: { $0.stableId == stableId }) {
currentState.items.remove(at: index)
transaction.setLocalStoryState(state: CodableEntry(currentState))
}
stateManager.addUpdates(updates)
var id: Int32?
if let updates = updates {
for update in updates.allUpdates {
if case let .updateStory(_, story) = update {
switch story {
case let .storyItem(_, idValue, _, _, _, _, media, _, _, _, _):
if let parsedStory = Stories.StoredItem(apiStoryItem: story, peerId: toPeerId, transaction: transaction) {
var items = transaction.getStoryItems(peerId: toPeerId)
var updatedItems: [Stories.Item] = []
if items.firstIndex(where: { $0.id == id }) == nil, case let .item(item) = parsedStory {
let updatedItem = Stories.Item(
id: item.id,
timestamp: item.timestamp,
expirationTimestamp: item.expirationTimestamp,
media: item.media,
mediaAreas: item.mediaAreas,
text: item.text,
entities: item.entities,
views: item.views,
privacy: Stories.Item.Privacy(base: privacy.base, additionallyIncludePeers: privacy.additionallyIncludePeers),
isPinned: item.isPinned,
isExpired: item.isExpired,
isPublic: item.isPublic,
isCloseFriends: item.isCloseFriends,
isContacts: item.isContacts,
isSelectedContacts: item.isSelectedContacts,
isForwardingDisabled: item.isForwardingDisabled,
isEdited: item.isEdited,
myReaction: item.myReaction
)
if let entry = CodableEntry(Stories.StoredItem.item(updatedItem)) {
items.append(StoryItemsTableEntry(value: entry, id: item.id, expirationTimestamp: updatedItem.expirationTimestamp, isCloseFriends: updatedItem.isCloseFriends))
}
updatedItems.append(updatedItem)
}
transaction.setStoryItems(peerId: toPeerId, items: items)
}
id = idValue
let (parsedMedia, _, _, _) = textMediaAndExpirationTimerFromApiMedia(media, toPeerId)
if let parsedMedia = parsedMedia {
applyMediaResourceChanges(from: originalMedia, to: parsedMedia, postbox: postbox, force: originalMedia is TelegramMediaFile && parsedMedia is TelegramMediaFile)
}
default:
break
}
}
}
if let id = id {
_internal_putPendingStoryIdMapping(peerId: toPeerId, stableId: stableId, id: id)
}
stateManager.addUpdates(updates)
}
return .completed(id)
}
return .completed(id)
}
default:
return .complete()
}
default:
return .complete()
}
|> switchToLatest
default:
return .complete()
}
|> switchToLatest
default:
return .complete()
}
}
}
func _internal_editStory(account: Account, id: Int32, media: EngineStoryInputMedia?, mediaAreas: [MediaArea]?, text: String?, entities: [MessageTextEntity]?, privacy: EngineStoryPrivacy?) -> Signal<StoryUploadResult, NoError> {
func _internal_editStory(account: Account, peerId: PeerId, id: Int32, media: EngineStoryInputMedia?, mediaAreas: [MediaArea]?, text: String?, entities: [MessageTextEntity]?, privacy: EngineStoryPrivacy?) -> Signal<StoryUploadResult, NoError> {
let contentSignal: Signal<PendingMessageUploadedContentResult?, NoError>
let originalMedia: Media?
if let media = media {
@ -1052,6 +1063,10 @@ func _internal_editStory(account: Account, id: Int32, media: EngineStoryInputMed
}
return account.postbox.transaction { transaction -> Signal<StoryUploadResult, NoError> in
guard let inputPeer = transaction.getPeer(peerId).flatMap(apiInputPeer) else {
return .single(.completed(nil))
}
var flags: Int32 = 0
var apiCaption: String?
var apiEntities: [Api.MessageEntity]?
@ -1088,6 +1103,7 @@ func _internal_editStory(account: Account, id: Int32, media: EngineStoryInputMed
return account.network.request(Api.functions.stories.editStory(
flags: flags,
peer: inputPeer,
id: id,
media: inputMedia,
mediaAreas: inputMediaAreas,
@ -1190,7 +1206,7 @@ func _internal_editStoryPrivacy(account: Account, id: Int32, privacy: EngineStor
var flags: Int32 = 0
flags |= 1 << 2
return account.network.request(Api.functions.stories.editStory(flags: flags, id: id, media: nil, mediaAreas: nil, caption: nil, entities: nil, privacyRules: inputRules))
return account.network.request(Api.functions.stories.editStory(flags: flags, peer: .inputPeerSelf, id: id, media: nil, mediaAreas: nil, caption: nil, entities: nil, privacyRules: inputRules))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
return .single(nil)
@ -1215,7 +1231,7 @@ public enum StoriesUploadAvailability {
}
func _internal_checkStoriesUploadAvailability(account: Account) -> Signal<StoriesUploadAvailability, NoError> {
return account.network.request(Api.functions.stories.canSendStory())
return account.network.request(Api.functions.stories.canSendStory(peer: .inputPeerSelf))
|> map { result -> StoriesUploadAvailability in
if result == .boolTrue {
return .available
@ -1237,9 +1253,13 @@ func _internal_checkStoriesUploadAvailability(account: Account) -> Signal<Storie
}
}
func _internal_deleteStories(account: Account, ids: [Int32]) -> Signal<Never, NoError> {
return account.postbox.transaction { transaction -> Void in
var items = transaction.getStoryItems(peerId: account.peerId)
func _internal_deleteStories(account: Account, peerId: PeerId, ids: [Int32]) -> Signal<Never, NoError> {
return account.postbox.transaction { transaction -> Api.InputPeer? in
guard let inputPeer = transaction.getPeer(peerId).flatMap(apiInputPeer) else {
return nil
}
var items = transaction.getStoryItems(peerId: peerId)
var updated = false
for id in ids {
if let index = items.firstIndex(where: { $0.id == id }) {
@ -1253,9 +1273,15 @@ func _internal_deleteStories(account: Account, ids: [Int32]) -> Signal<Never, No
account.stateManager.injectStoryUpdates(updates: ids.map { id in
return .deleted(peerId: account.peerId, id: id)
})
return inputPeer
}
|> mapToSignal { _ -> Signal<Never, NoError> in
return account.network.request(Api.functions.stories.deleteStories(id: ids))
|> mapToSignal { inputPeer -> Signal<Never, NoError> in
guard let inputPeer = inputPeer else {
return .complete()
}
return account.network.request(Api.functions.stories.deleteStories(peer: inputPeer, id: ids))
|> `catch` { _ -> Signal<[Int32], NoError> in
return .single([])
}
@ -1267,11 +1293,11 @@ func _internal_deleteStories(account: Account, ids: [Int32]) -> Signal<Never, No
func _internal_markStoryAsSeen(account: Account, peerId: PeerId, id: Int32, asPinned: Bool) -> Signal<Never, NoError> {
if asPinned {
return account.postbox.transaction { transaction -> Api.InputUser? in
return transaction.getPeer(peerId).flatMap(apiInputUser)
return account.postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}
|> mapToSignal { inputUser -> Signal<Never, NoError> in
guard let inputUser = inputUser else {
|> mapToSignal { inputPeer -> Signal<Never, NoError> in
guard let inputPeer = inputPeer else {
return .complete()
}
@ -1281,7 +1307,7 @@ func _internal_markStoryAsSeen(account: Account, peerId: PeerId, id: Int32, asPi
}
#endif
return account.network.request(Api.functions.stories.incrementStoryViews(userId: inputUser, id: [id]))
return account.network.request(Api.functions.stories.incrementStoryViews(peer: inputPeer, id: [id]))
|> `catch` { _ -> Signal<Api.Bool, NoError> in
return .single(.boolFalse)
}
@ -1310,8 +1336,12 @@ func _internal_markStoryAsSeen(account: Account, peerId: PeerId, id: Int32, asPi
}
}
func _internal_updateStoriesArePinned(account: Account, ids: [Int32: EngineStoryItem], isPinned: Bool) -> Signal<Never, NoError> {
return account.postbox.transaction { transaction -> Void in
func _internal_updateStoriesArePinned(account: Account, peerId: PeerId, ids: [Int32: EngineStoryItem], isPinned: Bool) -> Signal<Never, NoError> {
return account.postbox.transaction { transaction -> Api.InputPeer? in
guard let inputPeer = transaction.getPeer(peerId).flatMap(apiInputPeer) else {
return nil
}
var items = transaction.getStoryItems(peerId: account.peerId)
var updatedItems: [Stories.Item] = []
for (id, referenceItem) in ids {
@ -1374,9 +1404,15 @@ func _internal_updateStoriesArePinned(account: Account, ids: [Int32: EngineStory
})
}
}
return inputPeer
}
|> mapToSignal { _ -> Signal<Never, NoError> in
return account.network.request(Api.functions.stories.togglePinned(id: ids.keys.sorted(), pinned: isPinned ? .boolTrue : .boolFalse))
|> mapToSignal { inputPeer -> Signal<Never, NoError> in
guard let inputPeer = inputPeer else {
return .complete()
}
return account.network.request(Api.functions.stories.togglePinned(peer: inputPeer, id: ids.keys.sorted(), pinned: isPinned ? .boolTrue : .boolFalse))
|> `catch` { _ -> Signal<[Int32], NoError> in
return .single([])
}
@ -1512,11 +1548,9 @@ extension Stories.StoredItem {
}
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([])
}
let inputPeer = peer.inputPeer
return network.request(Api.functions.stories.getStoriesByID(userId: inputUser, id: ids))
return network.request(Api.functions.stories.getStoriesByID(peer: inputPeer, id: ids))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.stories.Stories?, NoError> in
return .single(nil)
@ -1527,8 +1561,8 @@ func _internal_getStoriesById(accountPeerId: PeerId, postbox: Postbox, network:
}
return postbox.transaction { transaction -> [Stories.StoredItem] in
switch result {
case let .stories(_, stories, users):
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
case let .stories(_, stories, chats, users):
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(transaction: transaction, chats: chats, users: users))
return stories.compactMap { apiStoryItem -> Stories.StoredItem? in
return Stories.StoredItem(apiStoryItem: apiStoryItem, peerId: peer.id, transaction: transaction)
@ -1539,15 +1573,15 @@ func _internal_getStoriesById(accountPeerId: PeerId, postbox: Postbox, network:
}
func _internal_getStoriesById(accountPeerId: PeerId, postbox: Postbox, source: FetchMessageHistoryHoleSource, peerId: PeerId, peerReference: PeerReference?, ids: [Int32], allowFloodWait: Bool) -> Signal<[Stories.StoredItem]?, NoError> {
return postbox.transaction { transaction -> Api.InputUser? in
return transaction.getPeer(peerId).flatMap(apiInputUser)
return postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}
|> mapToSignal { inputUser -> Signal<[Stories.StoredItem]?, NoError> in
guard let inputUser = inputUser ?? peerReference?.inputUser else {
|> mapToSignal { inputPeer -> Signal<[Stories.StoredItem]?, NoError> in
guard let inputPeer = inputPeer ?? peerReference?.inputPeer else {
return .single([])
}
return source.request(Api.functions.stories.getStoriesByID(userId: inputUser, id: ids), automaticFloodWait: allowFloodWait)
return source.request(Api.functions.stories.getStoriesByID(peer: inputPeer, id: ids), automaticFloodWait: allowFloodWait)
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.stories.Stories?, NoError> in
return .single(nil)
@ -1558,8 +1592,8 @@ func _internal_getStoriesById(accountPeerId: PeerId, postbox: Postbox, source: F
}
return postbox.transaction { transaction -> [Stories.StoredItem]? in
switch result {
case let .stories(_, stories, users):
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
case let .stories(_, stories, chats, users):
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(transaction: transaction, chats: chats, users: users))
return stories.compactMap { apiStoryItem -> Stories.StoredItem? in
return Stories.StoredItem(apiStoryItem: apiStoryItem, peerId: peerId, transaction: transaction)
@ -1647,14 +1681,14 @@ func _internal_updatePeerStoriesHidden(account: Account, id: PeerId, isHidden: B
}
func _internal_exportStoryLink(account: Account, peerId: EnginePeer.Id, id: Int32) -> Signal<String?, NoError> {
return account.postbox.transaction { transaction -> Api.InputUser? in
return transaction.getPeer(peerId).flatMap(apiInputUser)
return account.postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}
|> mapToSignal { inputUser -> Signal<String?, NoError> in
guard let inputUser = inputUser else {
|> mapToSignal { inputPeer -> Signal<String?, NoError> in
guard let inputPeer = inputPeer else {
return .single(nil)
}
return account.network.request(Api.functions.stories.exportStoryLink(userId: inputUser, id: id))
return account.network.request(Api.functions.stories.exportStoryLink(peer: inputPeer, id: id))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.ExportedStoryLink?, NoError> in
return .single(nil)
@ -1710,7 +1744,7 @@ func _internal_refreshStories(account: Account, peerId: PeerId, ids: [Int32]) ->
}
func _internal_refreshSeenStories(postbox: Postbox, network: Network) -> Signal<Never, NoError> {
return network.request(Api.functions.stories.getAllReadUserStories())
return network.request(Api.functions.stories.getAllReadPeerStories())
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
return .single(nil)
@ -1722,8 +1756,8 @@ func _internal_refreshSeenStories(postbox: Postbox, network: Network) -> Signal<
return postbox.transaction { transaction -> Void in
for update in updates.allUpdates {
switch update {
case let .updateReadStories(userId, maxId):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
case let .updateReadStories(peerIdValue, maxId):
let peerId = peerIdValue.peerId
var update = false
if let value = transaction.getPeerStoryState(peerId: peerId) {
update = value.maxSeenId < maxId
@ -1850,11 +1884,11 @@ public func _internal_setStoryNotificationWasDisplayed(transaction: Transaction,
}
func _internal_setStoryReaction(account: Account, peerId: EnginePeer.Id, id: Int32, reaction: MessageReaction.Reaction?) -> Signal<Never, NoError> {
return account.postbox.transaction { transaction -> Api.InputUser? in
return account.postbox.transaction { transaction -> Api.InputPeer? in
guard let peer = transaction.getPeer(peerId) else {
return nil
}
guard let inputUser = apiInputUser(peer) else {
guard let inputPeer = apiInputPeer(peer) else {
return nil
}
@ -1916,13 +1950,13 @@ func _internal_setStoryReaction(account: Account, peerId: EnginePeer.Id, id: Int
}
}
return inputUser
return inputPeer
}
|> mapToSignal { inputUser -> Signal<Never, NoError> in
guard let inputUser = inputUser else {
|> mapToSignal { inputPeer -> Signal<Never, NoError> in
guard let inputPeer = inputPeer else {
return .complete()
}
return account.network.request(Api.functions.stories.sendReaction(flags: 0, userId: inputUser, storyId: id, reaction: reaction?.apiReaction ?? .reactionEmpty))
return account.network.request(Api.functions.stories.sendReaction(flags: 0, peer: inputPeer, storyId: id, reaction: reaction?.apiReaction ?? .reactionEmpty))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
return .single(nil)

View File

@ -355,18 +355,18 @@ public final class StorySubscriptionsContext {
if isRefresh && !isHidden {
updatedStealthMode = stealthMode
}
case let .allStories(flags, _, state, userStories, users, stealthMode):
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: [], users: users)
case let .allStories(flags, _, state, peerStories, chats, users, stealthMode):
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
let hasMore: Bool = (flags & (1 << 0)) != 0
let (_, currentPeerItems) = transaction.getAllStorySubscriptions(key: subscriptionsKey)
var peerEntries: [PeerId] = []
for userStorySet in userStories {
switch userStorySet {
case let .userStories(_, userId, maxReadId, stories):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
for peerStorySet in peerStories {
switch peerStorySet {
case let .peerStories(_, peerIdValue, maxReadId, stories):
let peerId = peerIdValue.peerId
let previousPeerEntries: [StoryItemsTableEntry] = transaction.getStoryItems(peerId: peerId)
@ -608,11 +608,11 @@ public final class PeerStoryListContext {
let account = self.account
let accountPeerId = account.peerId
let isArchived = self.isArchived
self.requestDisposable = (self.account.postbox.transaction { transaction -> Api.InputUser? in
return transaction.getPeer(peerId).flatMap(apiInputUser)
self.requestDisposable = (self.account.postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}
|> mapToSignal { inputUser -> Signal<([EngineStoryItem], Int, PeerReference?, Bool), NoError> in
guard let inputUser = inputUser else {
|> mapToSignal { inputPeer -> Signal<([EngineStoryItem], Int, PeerReference?, Bool), NoError> in
guard let inputPeer = inputPeer else {
return .single(([], 0, nil, false))
}
@ -620,7 +620,7 @@ public final class PeerStoryListContext {
if isArchived {
signal = account.network.request(Api.functions.stories.getStoriesArchive(offsetId: Int32(loadMoreToken), limit: Int32(limit)))
} else {
signal = account.network.request(Api.functions.stories.getPinnedStories(userId: inputUser, offsetId: Int32(loadMoreToken), limit: Int32(limit)))
signal = account.network.request(Api.functions.stories.getPinnedStories(peer: inputPeer, offsetId: Int32(loadMoreToken), limit: Int32(limit)))
}
return signal
|> map { result -> Api.stories.Stories? in
@ -640,11 +640,11 @@ public final class PeerStoryListContext {
var hasMore: Bool = false
switch result {
case let .stories(count, stories, users):
case let .stories(count, stories, chats, users):
totalCount = Int(count)
hasMore = stories.count >= limit
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(users: users))
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: AccumulatedPeers(transaction: transaction, chats: chats, users: users))
for story in stories {
if let storedItem = Stories.StoredItem(apiStoryItem: story, peerId: peerId, transaction: transaction) {
@ -1165,16 +1165,16 @@ public final class PeerExpiringStoryListContext {
let account = self.account
let accountPeerId = account.peerId
let peerId = self.peerId
self.pollDisposable = (self.account.postbox.transaction { transaction -> Api.InputUser? in
return transaction.getPeer(peerId).flatMap(apiInputUser)
self.pollDisposable = (self.account.postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}
|> mapToSignal { inputUser -> Signal<Never, NoError> in
guard let inputUser = inputUser else {
|> mapToSignal { inputPeer -> Signal<Never, NoError> in
guard let inputPeer = inputPeer else {
return .complete()
}
return account.network.request(Api.functions.stories.getUserStories(userId: inputUser))
return account.network.request(Api.functions.stories.getPeerStories(peer: inputPeer))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.stories.UserStories?, NoError> in
|> `catch` { _ -> Signal<Api.stories.PeerStories?, NoError> in
return .single(nil)
}
|> mapToSignal { result -> Signal<Never, NoError> in
@ -1182,12 +1182,12 @@ public final class PeerExpiringStoryListContext {
var updatedPeerEntries: [StoryItemsTableEntry] = []
updatedPeerEntries.removeAll()
if let result = result, case let .userStories(stories, users) = result {
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: [], users: users)
if let result = result, case let .peerStories(stories, chats, users) = result {
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
switch stories {
case let .userStories(_, userId, maxReadId, stories):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
case let .peerStories(_, peerIdValue, maxReadId, stories):
let peerId = peerIdValue.peerId
let previousPeerEntries: [StoryItemsTableEntry] = transaction.getStoryItems(peerId: peerId)
@ -1331,16 +1331,16 @@ public final class PeerExpiringStoryListContext {
}
public func _internal_pollPeerStories(postbox: Postbox, network: Network, accountPeerId: PeerId, peerId: PeerId, peerReference: PeerReference? = nil) -> Signal<Never, NoError> {
return postbox.transaction { transaction -> Api.InputUser? in
return transaction.getPeer(peerId).flatMap(apiInputUser) ?? peerReference?.inputUser
return postbox.transaction { transaction -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer) ?? peerReference?.inputPeer
}
|> mapToSignal { inputUser -> Signal<Never, NoError> in
guard let inputUser = inputUser else {
|> mapToSignal { inputPeer -> Signal<Never, NoError> in
guard let inputPeer = inputPeer else {
return .complete()
}
return network.request(Api.functions.stories.getUserStories(userId: inputUser))
return network.request(Api.functions.stories.getPeerStories(peer: inputPeer))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.stories.UserStories?, NoError> in
|> `catch` { _ -> Signal<Api.stories.PeerStories?, NoError> in
return .single(nil)
}
|> mapToSignal { result -> Signal<Never, NoError> in
@ -1348,12 +1348,12 @@ public func _internal_pollPeerStories(postbox: Postbox, network: Network, accoun
var updatedPeerEntries: [StoryItemsTableEntry] = []
updatedPeerEntries.removeAll()
if let result = result, case let .userStories(stories, users) = result {
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: [], users: users)
if let result = result, case let .peerStories(stories, chats, users) = result {
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
switch stories {
case let .userStories(_, userId, maxReadId, stories):
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
case let .peerStories(_, peerIdValue, maxReadId, stories):
let peerId = peerIdValue.peerId
let previousPeerEntries: [StoryItemsTableEntry] = transaction.getStoryItems(peerId: peerId)

View File

@ -671,7 +671,12 @@ public extension TelegramEngine {
self.account.postbox.combinedView(keys: [
basicPeerKey,
storySubscriptionsKey,
PostboxViewKey.storiesState(key: .subscriptions(subscriptionsKey))
PostboxViewKey.storiesState(
key: .subscriptions(subscriptionsKey)
),
PostboxViewKey.storiesState(
key: .local
)
]))
|> mapToSignal { debugTimer, views -> Signal<EngineStorySubscriptions, NoError> in
guard let basicPeerView = views.views[basicPeerKey] as? BasicPeerView, let accountPeer = basicPeerView.peer else {
@ -714,7 +719,19 @@ public extension TelegramEngine {
additionalDataKeys.append(contentsOf: subscriptionPeerIds.map { peerId -> PostboxViewKey in
return PostboxViewKey.storiesState(key: .peer(peerId))
})
additionalDataKeys.append(contentsOf: subscriptionPeerIds.map { peerId -> PostboxViewKey in
var additionalPeerIds = subscriptionPeerIds
if let view = views.views[PostboxViewKey.storiesState(key: .local)] as? StoryStatesView, let localState = view.value?.get(Stories.LocalState.self) {
for item in localState.items {
if case let .peer(id) = item.target {
if !additionalPeerIds.contains(id) {
additionalPeerIds.append(id)
}
}
}
}
additionalDataKeys.append(contentsOf: additionalPeerIds.map { peerId -> PostboxViewKey in
return PostboxViewKey.basicPeer(peerId)
})
@ -733,9 +750,18 @@ public extension TelegramEngine {
hasMoreToken = ""
}
var localState: Stories.LocalState?
if let view = views.views[PostboxViewKey.storiesState(key: .local)] as? StoryStatesView {
localState = view.value?.get(Stories.LocalState.self)
}
var accountPendingItemCount = 0
if let view = views.views[PostboxViewKey.storiesState(key: .local)] as? StoryStatesView, let localState = view.value?.get(Stories.LocalState.self) {
accountPendingItemCount = localState.items.count
if let localState {
for item in localState.items {
if case .myStories = item.target {
accountPendingItemCount += 1
}
}
}
var accountItem: EngineStorySubscriptions.Item = EngineStorySubscriptions.Item(
@ -827,12 +853,20 @@ public extension TelegramEngine {
}
}
}
var pendingItemCount = 0
if let localState {
for item in localState.items {
if case .peer(peerId) = item.target {
pendingItemCount += 1
}
}
}
let item = EngineStorySubscriptions.Item(
peer: EnginePeer(peer),
hasUnseen: hasUnseen,
hasUnseenCloseFriends: hasUnseenCloseFriends,
hasPending: false,
hasPending: pendingItemCount != 0,
storyCount: itemsView.items.count,
unseenCount: unseenCount,
lastTimestamp: lastEntry.timestamp
@ -845,7 +879,38 @@ public extension TelegramEngine {
}
}
if let localState {
for item in localState.items {
if case let .peer(peerId) = item.target, !items.contains(where: { $0.peer.id == peerId }) {
guard let peerView = views.views[PostboxViewKey.basicPeer(peerId)] as? BasicPeerView else {
continue
}
guard let peer = peerView.peer else {
continue
}
let item = EngineStorySubscriptions.Item(
peer: EnginePeer(peer),
hasUnseen: false,
hasUnseenCloseFriends: false,
hasPending: true,
storyCount: 0,
unseenCount: 0,
lastTimestamp: 0
)
items.append(item)
}
}
}
items.sort(by: { lhs, rhs in
if lhs.hasPending != rhs.hasPending {
if lhs.hasPending {
return true
} else {
return false
}
}
if lhs.hasUnseen != rhs.hasUnseen {
if lhs.hasUnseen {
return true
@ -1049,8 +1114,8 @@ public extension TelegramEngine {
}
}
public func uploadStory(media: EngineStoryInputMedia, mediaAreas: [MediaArea], text: String, entities: [MessageTextEntity], pin: Bool, privacy: EngineStoryPrivacy, isForwardingDisabled: Bool, period: Int, randomId: Int64) -> Signal<Int32, NoError> {
return _internal_uploadStory(account: self.account, media: media, mediaAreas: mediaAreas, text: text, entities: entities, pin: pin, privacy: privacy, isForwardingDisabled: isForwardingDisabled, period: period, randomId: randomId)
public func uploadStory(target: Stories.PendingTarget, media: EngineStoryInputMedia, mediaAreas: [MediaArea], text: String, entities: [MessageTextEntity], pin: Bool, privacy: EngineStoryPrivacy, isForwardingDisabled: Bool, period: Int, randomId: Int64) -> Signal<Int32, NoError> {
return _internal_uploadStory(account: self.account, target: target, media: media, mediaAreas: mediaAreas, text: text, entities: entities, pin: pin, privacy: privacy, isForwardingDisabled: isForwardingDisabled, period: period, randomId: randomId)
}
public func allStoriesUploadEvents() -> Signal<(Int32, Int32), NoError> {
@ -1060,13 +1125,13 @@ public extension TelegramEngine {
return pendingStoryManager.allStoriesUploadEvents()
}
public func lookUpPendingStoryIdMapping(stableId: Int32) -> Int32? {
return self.account.pendingStoryManager?.lookUpPendingStoryIdMapping(stableId: stableId)
public func lookUpPendingStoryIdMapping(peerId: EnginePeer.Id, stableId: Int32) -> Int32? {
return self.account.pendingStoryManager?.lookUpPendingStoryIdMapping(peerId: peerId, stableId: stableId)
}
public func allStoriesUploadProgress() -> Signal<Float?, NoError> {
public func allStoriesUploadProgress() -> Signal<[EnginePeer.Id: Float], NoError> {
guard let pendingStoryManager = self.account.pendingStoryManager else {
return .single(nil)
return .single([:])
}
return pendingStoryManager.allStoriesUploadProgress
}
@ -1082,8 +1147,8 @@ public extension TelegramEngine {
_internal_cancelStoryUpload(account: self.account, stableId: stableId)
}
public func editStory(id: Int32, media: EngineStoryInputMedia?, mediaAreas: [MediaArea]?, text: String?, entities: [MessageTextEntity]?, privacy: EngineStoryPrivacy?) -> Signal<StoryUploadResult, NoError> {
return _internal_editStory(account: self.account, id: id, media: media, mediaAreas: mediaAreas, text: text, entities: entities, privacy: privacy)
public func editStory(peerId: EnginePeer.Id, id: Int32, media: EngineStoryInputMedia?, mediaAreas: [MediaArea]?, text: String?, entities: [MessageTextEntity]?, privacy: EngineStoryPrivacy?) -> Signal<StoryUploadResult, NoError> {
return _internal_editStory(account: self.account, peerId: peerId, id: id, media: media, mediaAreas: mediaAreas, text: text, entities: entities, privacy: privacy)
}
public func editStoryPrivacy(id: Int32, privacy: EngineStoryPrivacy) -> Signal<Never, NoError> {
@ -1094,16 +1159,16 @@ public extension TelegramEngine {
return _internal_checkStoriesUploadAvailability(account: self.account)
}
public func deleteStories(ids: [Int32]) -> Signal<Never, NoError> {
return _internal_deleteStories(account: self.account, ids: ids)
public func deleteStories(peerId: EnginePeer.Id, ids: [Int32]) -> Signal<Never, NoError> {
return _internal_deleteStories(account: self.account, peerId: peerId, ids: ids)
}
public func markStoryAsSeen(peerId: EnginePeer.Id, id: Int32, asPinned: Bool) -> Signal<Never, NoError> {
return _internal_markStoryAsSeen(account: self.account, peerId: peerId, id: id, asPinned: asPinned)
}
public func updateStoriesArePinned(ids: [Int32: EngineStoryItem], isPinned: Bool) -> Signal<Never, NoError> {
return _internal_updateStoriesArePinned(account: self.account, ids: ids, isPinned: isPinned)
public func updateStoriesArePinned(peerId: EnginePeer.Id, ids: [Int32: EngineStoryItem], isPinned: Bool) -> Signal<Never, NoError> {
return _internal_updateStoriesArePinned(account: self.account, peerId: peerId, ids: ids, isPinned: isPinned)
}
public func storyViewList(id: Int32, views: EngineStoryItem.Views, listMode: EngineStoryViewListContext.ListMode, sortMode: EngineStoryViewListContext.SortMode, searchQuery: String? = nil, parentSource: EngineStoryViewListContext? = nil) -> EngineStoryViewListContext {

View File

@ -172,8 +172,8 @@ func _internal_reportPeerMessages(account: Account, messageIds: [MessageId], rea
func _internal_reportPeerStory(account: Account, peerId: PeerId, storyId: Int32, reason: ReportReason, message: String) -> Signal<Void, NoError> {
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
if let peer = transaction.getPeer(peerId), let inputUser = apiInputUser(peer) {
return account.network.request(Api.functions.stories.report(userId: inputUser, id: [storyId], reason: reason.apiReason, message: message))
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
return account.network.request(Api.functions.stories.report(peer: inputPeer, id: [storyId], reason: reason.apiReason, message: message))
|> `catch` { _ -> Signal<Api.Bool, NoError> in
return .single(.boolFalse)
}

View File

@ -137,7 +137,7 @@ public final class ChatListHeaderComponent: Component {
public let storiesIncludeHidden: Bool
public let storiesFraction: CGFloat
public let storiesUnlocked: Bool
public let uploadProgress: Float?
public let uploadProgress: [EnginePeer.Id: Float]
public let context: AccountContext
public let theme: PresentationTheme
public let strings: PresentationStrings
@ -155,7 +155,7 @@ public final class ChatListHeaderComponent: Component {
storiesIncludeHidden: Bool,
storiesFraction: CGFloat,
storiesUnlocked: Bool,
uploadProgress: Float?,
uploadProgress: [EnginePeer.Id: Float],
context: AccountContext,
theme: PresentationTheme,
strings: PresentationStrings,

View File

@ -32,7 +32,7 @@ public final class ChatListNavigationBar: Component {
public let secondaryTransition: CGFloat
public let storySubscriptions: EngineStorySubscriptions?
public let storiesIncludeHidden: Bool
public let uploadProgress: Float?
public let uploadProgress: [EnginePeer.Id: Float]
public let tabsNode: ASDisplayNode?
public let tabsNodeIsSearch: Bool
public let accessoryPanelContainer: ASDisplayNode?
@ -53,7 +53,7 @@ public final class ChatListNavigationBar: Component {
secondaryTransition: CGFloat,
storySubscriptions: EngineStorySubscriptions?,
storiesIncludeHidden: Bool,
uploadProgress: Float?,
uploadProgress: [EnginePeer.Id: Float],
tabsNode: ASDisplayNode?,
tabsNodeIsSearch: Bool,
accessoryPanelContainer: ASDisplayNode?,
@ -508,7 +508,7 @@ public final class ChatListNavigationBar: Component {
}
}
public func updateStoryUploadProgress(storyUploadProgress: Float?) {
public func updateStoryUploadProgress(storyUploadProgress: [EnginePeer.Id: Float]) {
guard let component = self.component else {
return
}

View File

@ -1192,7 +1192,8 @@ final class MediaEditorScreenComponent: Component {
hideKeyboard: self.currentInputMode == .emoji,
forceIsEditing: self.currentInputMode == .emoji,
disabledPlaceholder: nil,
storyId: nil
isChannel: false,
storyItem: nil
)),
environment: {},
containerSize: CGSize(width: inputPanelAvailableWidth, height: inputPanelAvailableHeight)

View File

@ -292,7 +292,8 @@ final class StoryPreviewComponent: Component {
hideKeyboard: false,
forceIsEditing: false,
disabledPlaceholder: nil,
storyId: nil
isChannel: false,
storyItem: nil
)),
environment: {},
containerSize: CGSize(width: availableSize.width, height: 200.0)

View File

@ -34,6 +34,7 @@ swift_library(
"//submodules/StickerPeekUI",
"//submodules/Components/ReactionButtonListComponent",
"//submodules/TelegramUI/Components/AnimatedTextComponent",
"//submodules/AnimatedCountLabelNode",
],
visibility = [
"//visibility:public",

View File

@ -16,6 +16,7 @@ import TextFormat
import EmojiSuggestionsComponent
import AudioToolbox
import AnimatedTextComponent
import AnimatedCountLabelNode
public final class MessageInputPanelComponent: Component {
public struct ContextQueryTypes: OptionSet {
@ -138,7 +139,8 @@ public final class MessageInputPanelComponent: Component {
public let hideKeyboard: Bool
public let forceIsEditing: Bool
public let disabledPlaceholder: String?
public let storyId: Int32?
public let isChannel: Bool
public let storyItem: EngineStoryItem?
public init(
externalState: ExternalState,
@ -188,7 +190,8 @@ public final class MessageInputPanelComponent: Component {
hideKeyboard: Bool,
forceIsEditing: Bool,
disabledPlaceholder: String?,
storyId: Int32?
isChannel: Bool,
storyItem: EngineStoryItem?
) {
self.externalState = externalState
self.context = context
@ -237,7 +240,8 @@ public final class MessageInputPanelComponent: Component {
self.hideKeyboard = hideKeyboard
self.forceIsEditing = forceIsEditing
self.disabledPlaceholder = disabledPlaceholder
self.storyId = storyId
self.isChannel = isChannel
self.storyItem = storyItem
}
public static func ==(lhs: MessageInputPanelComponent, rhs: MessageInputPanelComponent) -> Bool {
@ -334,7 +338,10 @@ public final class MessageInputPanelComponent: Component {
if (lhs.likeOptionsAction == nil) != (rhs.likeOptionsAction == nil) {
return false
}
if lhs.storyId != rhs.storyId {
if lhs.isChannel != rhs.isChannel {
return false
}
if lhs.storyItem != rhs.storyItem {
return false
}
return true
@ -387,6 +394,10 @@ public final class MessageInputPanelComponent: Component {
private var viewForOverlayContent: ViewForOverlayContent?
private var currentEmojiSuggestionView: ComponentHostView<Empty>?
private var viewsIconView: UIImageView?
private var viewStatsCountText: AnimatedCountLabelView?
private var reactionStatsCountText: AnimatedCountLabelView?
private let hapticFeedback = HapticFeedback()
private var component: MessageInputPanelComponent?
@ -622,6 +633,11 @@ public final class MessageInputPanelComponent: Component {
let mediaInsets = UIEdgeInsets(top: insets.top, left: 9.0, bottom: insets.bottom, right: 41.0)
let baseFieldHeight: CGFloat = 40.0
var transition = transition
if transition.animation.isImmediate, let previousComponent = self.component, previousComponent.storyItem?.id == component.storyItem?.id, component.isChannel {
transition = transition.withAnimation(.curve(duration: 0.3, curve: .spring))
}
self.component = component
self.state = state
@ -790,14 +806,94 @@ public final class MessageInputPanelComponent: Component {
transition.setPosition(view: placeholderView, position: placeholderFrame.origin)
placeholderView.bounds = CGRect(origin: CGPoint(), size: placeholderFrame.size)
transition.setAlpha(view: placeholderView, alpha: (hasMediaRecording || hasMediaEditing || component.disabledPlaceholder != nil) ? 0.0 : 1.0)
transition.setAlpha(view: vibrancyPlaceholderView, alpha: (hasMediaRecording || hasMediaEditing || component.disabledPlaceholder != nil) ? 0.0 : 1.0)
transition.setAlpha(view: placeholderView, alpha: (hasMediaRecording || hasMediaEditing || component.disabledPlaceholder != nil || component.isChannel) ? 0.0 : 1.0)
transition.setAlpha(view: vibrancyPlaceholderView, alpha: (hasMediaRecording || hasMediaEditing || component.disabledPlaceholder != nil || component.isChannel) ? 0.0 : 1.0)
}
transition.setAlpha(view: self.fieldBackgroundView, alpha: component.disabledPlaceholder != nil ? 0.0 : 1.0)
transition.setAlpha(view: self.fieldBackgroundView, alpha: (component.disabledPlaceholder != nil || component.isChannel) ? 0.0 : 1.0)
let size = CGSize(width: availableSize.width, height: textFieldSize.height + insets.top + insets.bottom)
var rightButtonsOffsetX: CGFloat = 0.0
if component.isChannel, let storyItem = component.storyItem {
var viewsTransition = transition
let viewsIconView: UIImageView
if let current = self.viewsIconView {
viewsIconView = current
} else {
viewsTransition = viewsTransition.withAnimation(.none)
viewsIconView = UIImageView(image: UIImage(bundleImageName: "Stories/EmbeddedViewIcon"))
self.viewsIconView = viewsIconView
self.addSubview(viewsIconView)
}
let viewStatsCountText: AnimatedCountLabelView
if let current = self.viewStatsCountText {
viewStatsCountText = current
} else {
viewStatsCountText = AnimatedCountLabelView(frame: CGRect())
self.viewStatsCountText = viewStatsCountText
self.addSubview(viewStatsCountText)
}
let reactionStatsCountText: AnimatedCountLabelView
if let current = self.reactionStatsCountText {
reactionStatsCountText = current
} else {
reactionStatsCountText = AnimatedCountLabelView(frame: CGRect())
self.reactionStatsCountText = reactionStatsCountText
self.addSubview(reactionStatsCountText)
}
var viewCount = storyItem.views?.seenCount ?? 0
if viewCount == 0 {
viewCount = 1
}
var reactionCount = storyItem.views?.reactedCount ?? 0
if reactionCount == 0, storyItem.myReaction != nil {
reactionCount += 1
}
var regularSegments: [AnimatedCountLabelView.Segment] = []
regularSegments.append(.number(viewCount, NSAttributedString(string: "\(viewCount)", font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white)))
var reactionSegments: [AnimatedCountLabelView.Segment] = []
reactionSegments.append(.number(reactionCount, NSAttributedString(string: "\(reactionCount)", font: Font.with(size: 15.0, traits: .monospacedNumbers), textColor: .white)))
let viewStatsTextLayout = viewStatsCountText.update(size: CGSize(width: availableSize.width, height: size.height), segments: regularSegments, transition: viewsTransition.containedViewLayoutTransition)
let reactionStatsTextLayout = reactionStatsCountText.update(size: CGSize(width: availableSize.width, height: size.height), segments: reactionSegments, transition: viewsTransition.containedViewLayoutTransition)
var contentX: CGFloat = 16.0
if let image = viewsIconView.image {
let viewsIconFrame = CGRect(origin: CGPoint(x: contentX, y: size.height - insets.bottom - baseFieldHeight + floor((baseFieldHeight - image.size.height) * 0.5)), size: image.size)
viewsTransition.setPosition(view: viewsIconView, position: viewsIconFrame.center)
viewsTransition.setBounds(view: viewsIconView, bounds: CGRect(origin: CGPoint(), size: viewsIconFrame.size))
contentX += image.size.width + 5.0
}
transition.setFrame(view: viewStatsCountText, frame: CGRect(origin: CGPoint(x: contentX, y: size.height - insets.bottom - baseFieldHeight + floor((baseFieldHeight - viewStatsTextLayout.size.height) * 0.5)), size: viewStatsTextLayout.size))
transition.setFrame(view: reactionStatsCountText, frame: CGRect(origin: CGPoint(x: availableSize.width - 11.0 - reactionStatsTextLayout.size.width, y: size.height - insets.bottom - baseFieldHeight + floor((baseFieldHeight - reactionStatsTextLayout.size.height) * 0.5)), size: reactionStatsTextLayout.size))
rightButtonsOffsetX -= reactionStatsTextLayout.size.width + 4.0
} else {
if let viewsIconView = self.viewsIconView {
self.viewsIconView = nil
viewsIconView.removeFromSuperview()
}
if let viewStatsCountText = self.viewStatsCountText {
self.viewStatsCountText = nil
viewStatsCountText.removeFromSuperview()
}
if let reactionStatsCountText = self.reactionStatsCountText {
self.reactionStatsCountText = nil
reactionStatsCountText.removeFromSuperview()
}
}
if let textFieldView = self.textField.view as? TextFieldComponent.View {
if textFieldView.superview == nil {
self.addSubview(textFieldView)
@ -816,14 +912,14 @@ public final class MessageInputPanelComponent: Component {
}
let textFieldFrame = CGRect(origin: CGPoint(x: fieldBackgroundFrame.minX, y: fieldBackgroundFrame.maxY - textFieldSize.height), size: textFieldSize)
transition.setFrame(view: textFieldView, frame: textFieldFrame)
transition.setAlpha(view: textFieldView, alpha: (hasMediaRecording || hasMediaEditing || component.disabledPlaceholder != nil) ? 0.0 : 1.0)
transition.setAlpha(view: textFieldView, alpha: (hasMediaRecording || hasMediaEditing || component.disabledPlaceholder != nil || component.isChannel) ? 0.0 : 1.0)
if let viewForOverlayContent = self.viewForOverlayContent {
transition.setFrame(view: viewForOverlayContent, frame: textFieldFrame)
}
}
if let disabledPlaceholderText = component.disabledPlaceholder {
if let disabledPlaceholderText = component.disabledPlaceholder, !component.isChannel {
let disabledPlaceholder: ComponentView<Empty>
var disabledPlaceholderTransition = transition
if let current = self.disabledPlaceholder {
@ -892,7 +988,7 @@ public final class MessageInputPanelComponent: Component {
transition: transition,
component: AnyComponent(MessageInputActionButtonComponent(
mode: attachmentButtonMode,
storyId: component.storyId,
storyId: component.storyItem?.id,
action: { [weak self] mode, action, sendAction in
guard let self, let component = self.component, case .up = action else {
return
@ -1041,7 +1137,7 @@ public final class MessageInputPanelComponent: Component {
transition: transition,
component: AnyComponent(MessageInputActionButtonComponent(
mode: inputActionButtonMode,
storyId: component.storyId,
storyId: component.storyItem?.id,
action: { [weak self] mode, action, sendAction in
guard let self, let component = self.component else {
return
@ -1150,14 +1246,24 @@ public final class MessageInputPanelComponent: Component {
}
var inputActionButtonOriginX: CGFloat
if component.setMediaRecordingActive != nil || isEditing {
inputActionButtonOriginX = fieldBackgroundFrame.maxX + floorToScreenPixels((41.0 - inputActionButtonSize.width) * 0.5)
if rightButtonsOffsetX != 0.0 {
inputActionButtonOriginX = availableSize.width - 3.0 + rightButtonsOffsetX
if displayLikeAction {
inputActionButtonOriginX -= 39.0
}
if component.forwardAction != nil {
inputActionButtonOriginX -= 46.0
}
} else {
inputActionButtonOriginX = size.width
}
if hasLikeAction {
inputActionButtonOriginX += 3.0
if component.setMediaRecordingActive != nil || isEditing {
inputActionButtonOriginX = fieldBackgroundFrame.maxX + floorToScreenPixels((41.0 - inputActionButtonSize.width) * 0.5)
} else {
inputActionButtonOriginX = size.width
}
if hasLikeAction {
inputActionButtonOriginX += 3.0
}
}
if let inputActionButtonView = self.inputActionButton.view {
@ -1169,8 +1275,14 @@ public final class MessageInputPanelComponent: Component {
transition.setBounds(view: inputActionButtonView, bounds: CGRect(origin: CGPoint(), size: inputActionButtonFrame.size))
transition.setAlpha(view: inputActionButtonView, alpha: likeActionReplacesInputAction ? 0.0 : 1.0)
if hasLikeAction {
inputActionButtonOriginX += 41.0
if rightButtonsOffsetX != 0.0 {
if hasLikeAction {
inputActionButtonOriginX += 46.0
}
} else {
if hasLikeAction {
inputActionButtonOriginX += 41.0
}
}
}
@ -1178,7 +1290,7 @@ public final class MessageInputPanelComponent: Component {
transition: transition,
component: AnyComponent(MessageInputActionButtonComponent(
mode: .like(reaction: component.myReaction?.reaction, file: component.myReaction?.file, animationFileId: component.myReaction?.animationFileId),
storyId: component.storyId,
storyId: component.storyItem?.id,
action: { [weak self] _, action, _ in
guard let self, let component = self.component else {
return
@ -1213,7 +1325,7 @@ public final class MessageInputPanelComponent: Component {
self.addSubview(likeButtonView)
}
var likeButtonFrame = CGRect(origin: CGPoint(x: inputActionButtonOriginX, y: size.height - insets.bottom - baseFieldHeight + floor((baseFieldHeight - likeButtonSize.height) * 0.5)), size: likeButtonSize)
if component.forwardAction == nil {
if component.forwardAction == nil && rightButtonsOffsetX == 0.0 {
likeButtonFrame.origin.x += 3.0
}
transition.setPosition(view: likeButtonView, position: likeButtonFrame.center)

View File

@ -110,7 +110,7 @@ final class PeerInfoStoryGridScreenComponent: Component {
guard let paneNode = self.paneNode, !paneNode.selectedIds.isEmpty else {
return
}
let _ = component.context.engine.messages.deleteStories(ids: Array(paneNode.selectedIds)).start()
let _ = component.context.engine.messages.deleteStories(peerId: component.peerId, ids: Array(paneNode.selectedIds)).start()
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: environment.theme)
let text: String = presentationData.strings.StoryList_TooltipStoriesDeleted(Int32(paneNode.selectedIds.count))
@ -351,7 +351,7 @@ final class PeerInfoStoryGridScreenComponent: Component {
switch component.scope {
case .saved:
let selectedCount = paneNode.selectedItems.count
let _ = component.context.engine.messages.updateStoriesArePinned(ids: paneNode.selectedItems, isPinned: false).start()
let _ = component.context.engine.messages.updateStoriesArePinned(peerId: component.peerId, ids: paneNode.selectedItems, isPinned: false).start()
paneNode.setIsSelectionModeActive(false)
(self.environment?.controller() as? PeerInfoStoryGridScreen)?.updateTitle()
@ -367,7 +367,7 @@ final class PeerInfoStoryGridScreenComponent: Component {
action: { _ in return false }
), in: .current)
case .archive:
let _ = component.context.engine.messages.updateStoriesArePinned(ids: paneNode.selectedItems, isPinned: true).start()
let _ = component.context.engine.messages.updateStoriesArePinned(peerId: component.peerId, ids: paneNode.selectedItems, isPinned: true).start()
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: environment.theme)

View File

@ -55,9 +55,7 @@ public final class StoryContentContextImpl: StoryContentContext {
PostboxViewKey.storyItems(peerId: peerId),
PostboxViewKey.peerPresences(peerIds: Set([peerId]))
]
if peerId == context.account.peerId {
inputKeys.append(PostboxViewKey.storiesState(key: .local))
}
inputKeys.append(PostboxViewKey.storiesState(key: .local))
self.disposable = (combineLatest(queue: .mainQueue(),
self.currentFocusedIdUpdatedPromise.get(),
context.account.postbox.combinedView(
@ -179,30 +177,39 @@ public final class StoryContentContextImpl: StoryContentContext {
)
}
var totalCount = peerStoryItemsView.items.count
if peerId == context.account.peerId, let stateView = views.views[PostboxViewKey.storiesState(key: .local)] as? StoryStatesView, let localState = stateView.value?.get(Stories.LocalState.self) {
if let stateView = views.views[PostboxViewKey.storiesState(key: .local)] as? StoryStatesView, let localState = stateView.value?.get(Stories.LocalState.self) {
for item in localState.items {
mappedItems.append(EngineStoryItem(
id: item.stableId,
timestamp: item.timestamp,
expirationTimestamp: Int32.max,
media: EngineMedia(item.media),
mediaAreas: item.mediaAreas,
text: item.text,
entities: item.entities,
views: nil,
privacy: item.privacy,
isPinned: item.pin,
isExpired: false,
isPublic: item.privacy.base == .everyone,
isPending: true,
isCloseFriends: item.privacy.base == .closeFriends,
isContacts: item.privacy.base == .contacts,
isSelectedContacts: item.privacy.base == .nobody,
isForwardingDisabled: false,
isEdited: false,
myReaction: nil
))
totalCount += 1
var matches = false
if peerId == context.account.peerId, case .myStories = item.target {
matches = true
} else if case .peer(peerId) = item.target {
matches = true
}
if matches {
mappedItems.append(EngineStoryItem(
id: item.stableId,
timestamp: item.timestamp,
expirationTimestamp: Int32.max,
media: EngineMedia(item.media),
mediaAreas: item.mediaAreas,
text: item.text,
entities: item.entities,
views: nil,
privacy: item.privacy,
isPinned: item.pin,
isExpired: false,
isPublic: item.privacy.base == .everyone,
isPending: true,
isCloseFriends: item.privacy.base == .closeFriends,
isContacts: item.privacy.base == .contacts,
isSelectedContacts: item.privacy.base == .nobody,
isForwardingDisabled: false,
isEdited: false,
myReaction: nil
))
totalCount += 1
}
}
}
@ -215,7 +222,7 @@ public final class StoryContentContextImpl: StoryContentContext {
if let currentMappedItems = self.currentMappedItems {
if let previousIndex = currentMappedItems.firstIndex(where: { $0.id == currentFocusedId }) {
if currentMappedItems[previousIndex].isPending {
if let updatedId = context.engine.messages.lookUpPendingStoryIdMapping(stableId: currentFocusedId) {
if let updatedId = context.engine.messages.lookUpPendingStoryIdMapping(peerId: peerId, stableId: currentFocusedId) {
if let index = mappedItems.firstIndex(where: { $0.id == updatedId }) {
focusedIndex = index
}

View File

@ -1471,7 +1471,7 @@ private final class StoryContainerScreenComponent: Component {
environment.controller()?.dismiss()
}
let _ = component.context.engine.messages.deleteStories(ids: [slice.item.storyItem.id]).start()
let _ = component.context.engine.messages.deleteStories(peerId: slice.peer.id, ids: [slice.item.storyItem.id]).start()
}
},
markAsSeen: { [weak self] id in

View File

@ -1563,7 +1563,7 @@ public final class StoryItemSetContainerComponent: Component {
view.setProgressMode(itemProgressMode)
}
if component.slice.peer.id == component.context.account.peerId {
if component.slice.peer.id == component.context.account.peerId || component.slice.item.storyItem.isPending {
let contentViewsShadowView: UIImageView
if let current = visibleItem.contentViewsShadowView {
contentViewsShadowView = current
@ -2561,6 +2561,11 @@ public final class StoryItemSetContainerComponent: Component {
let startTime23 = CFAbsoluteTimeGetCurrent()
if component.slice.peer.id != component.context.account.peerId {
var isChannel = false
if case .channel = component.slice.peer {
isChannel = true
}
inputPanelSize = self.inputPanel.update(
transition: inputPanelTransition,
component: AnyComponent(MessageInputPanelComponent(
@ -2765,7 +2770,8 @@ public final class StoryItemSetContainerComponent: Component {
hideKeyboard: self.sendMessageContext.currentInputMode == .media,
forceIsEditing: self.sendMessageContext.currentInputMode == .media,
disabledPlaceholder: disabledPlaceholder,
storyId: component.slice.item.storyItem.id
isChannel: isChannel,
storyItem: component.slice.item.storyItem
)),
environment: {},
containerSize: CGSize(width: inputPanelAvailableWidth, height: 200.0)
@ -3793,7 +3799,7 @@ public final class StoryItemSetContainerComponent: Component {
if let inputPanelSize {
let inputPanelFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - inputPanelSize.width) / 2.0), y: availableSize.height - inputPanelBottomInset - inputPanelSize.height), size: inputPanelSize)
inputPanelFrameValue = inputPanelFrame
var inputPanelAlpha: CGFloat = component.slice.peer.id == component.context.account.peerId || component.hideUI || self.isEditingStory ? 0.0 : 1.0
var inputPanelAlpha: CGFloat = (component.slice.peer.id == component.context.account.peerId || component.hideUI || self.isEditingStory || component.slice.item.storyItem.isPending) ? 0.0 : 1.0
if case .regular = component.metrics.widthClass {
inputPanelAlpha *= component.visibilityFraction
}
@ -4780,6 +4786,7 @@ public final class StoryItemSetContainerComponent: Component {
return
}
let context = component.context
let peerId = component.slice.peer.id
let item = component.slice.item.storyItem
let id = item.id
@ -4827,7 +4834,7 @@ public final class StoryItemSetContainerComponent: Component {
}
}
}
let updateDisposable = MetaDisposable()
var updateProgressImpl: ((Float) -> Void)?
let controller = MediaEditorScreen(
@ -4858,7 +4865,7 @@ public final class StoryItemSetContainerComponent: Component {
updateProgressImpl?(0.0)
if let imageData = compressImageToJPEG(image, quality: 0.7) {
updateDisposable.set((context.engine.messages.editStory(id: id, media: .image(dimensions: dimensions, data: imageData, stickers: stickers), mediaAreas: mediaAreas, text: updatedText, entities: updatedEntities, privacy: nil)
updateDisposable.set((context.engine.messages.editStory(peerId: peerId, id: id, media: .image(dimensions: dimensions, data: imageData, stickers: stickers), mediaAreas: mediaAreas, text: updatedText, entities: updatedEntities, privacy: nil)
|> deliverOnMainQueue).start(next: { [weak self] result in
guard let self else {
return
@ -4908,7 +4915,7 @@ public final class StoryItemSetContainerComponent: Component {
}
}
updateDisposable.set((context.engine.messages.editStory(id: id, media: .video(dimensions: dimensions, duration: duration, resource: resource, firstFrameFile: firstFrameFile, stickers: stickers), mediaAreas: mediaAreas, text: updatedText, entities: updatedEntities, privacy: nil)
updateDisposable.set((context.engine.messages.editStory(peerId: peerId, id: id, media: .video(dimensions: dimensions, duration: duration, resource: resource, firstFrameFile: firstFrameFile, stickers: stickers), mediaAreas: mediaAreas, text: updatedText, entities: updatedEntities, privacy: nil)
|> deliverOnMainQueue).start(next: { [weak self] result in
guard let self else {
return
@ -4932,7 +4939,7 @@ public final class StoryItemSetContainerComponent: Component {
}
}
} else if updatedText != nil {
let _ = (context.engine.messages.editStory(id: id, media: nil, mediaAreas: nil, text: updatedText, entities: updatedEntities, privacy: nil)
let _ = (context.engine.messages.editStory(peerId: peerId, id: id, media: nil, mediaAreas: nil, text: updatedText, entities: updatedEntities, privacy: nil)
|> deliverOnMainQueue).start(next: { [weak self] result in
switch result {
case .completed:
@ -5427,7 +5434,7 @@ public final class StoryItemSetContainerComponent: Component {
return
}
let _ = component.context.engine.messages.updateStoriesArePinned(ids: [component.slice.item.storyItem.id: component.slice.item.storyItem], isPinned: !component.slice.item.storyItem.isPinned).start()
let _ = component.context.engine.messages.updateStoriesArePinned(peerId: component.slice.peer.id, ids: [component.slice.item.storyItem.id: component.slice.item.storyItem], isPinned: !component.slice.item.storyItem.isPinned).start()
let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: component.theme)
if component.slice.item.storyItem.isPinned {

View File

@ -55,7 +55,7 @@ public final class StoryPeerListComponent: Component {
public let storySubscriptions: EngineStorySubscriptions?
public let collapseFraction: CGFloat
public let unlocked: Bool
public let uploadProgress: Float?
public let uploadProgress: [EnginePeer.Id: Float]
public let peerAction: (EnginePeer?) -> Void
public let contextPeerAction: (ContextExtractedContentContainingNode, ContextGesture, EnginePeer) -> Void
public let openStatusSetup: (UIView) -> Void
@ -77,7 +77,7 @@ public final class StoryPeerListComponent: Component {
storySubscriptions: EngineStorySubscriptions?,
collapseFraction: CGFloat,
unlocked: Bool,
uploadProgress: Float?,
uploadProgress: [EnginePeer.Id: Float],
peerAction: @escaping (EnginePeer?) -> Void,
contextPeerAction: @escaping (ContextExtractedContentContainingNode, ContextGesture, EnginePeer) -> Void,
openStatusSetup: @escaping (UIView) -> Void,
@ -980,11 +980,13 @@ public final class StoryPeerListComponent: Component {
} else {
hasItems = false
}
if let uploadProgress = component.uploadProgress {
if let uploadProgress = component.uploadProgress[peer.id] {
itemRingAnimation = .progress(uploadProgress)
}
hasUnseenCloseFriendsItems = false
} else if let uploadProgress = component.uploadProgress[peer.id] {
itemRingAnimation = .progress(uploadProgress)
} else if peer.id == self.loadingItemId {
itemRingAnimation = .loading
}
@ -1131,11 +1133,13 @@ public final class StoryPeerListComponent: Component {
} else {
hasItems = false
}
if let uploadProgress = component.uploadProgress {
if let uploadProgress = component.uploadProgress[peer.id] {
itemRingAnimation = .progress(uploadProgress)
}
hasUnseenCloseFriendsItems = false
} else if let uploadProgress = component.uploadProgress[peer.id] {
itemRingAnimation = .progress(uploadProgress)
}
let collapseIndex = i + effectiveFirstVisibleIndex

View File

@ -266,7 +266,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
}
@discardableResult
public func openStoryCamera(transitionIn: StoryCameraTransitionIn?, transitionedIn: @escaping () -> Void, transitionOut: @escaping (Bool) -> StoryCameraTransitionOut?) -> StoryCameraTransitionInCoordinator? {
public func openStoryCamera(transitionIn: StoryCameraTransitionIn?, transitionedIn: @escaping () -> Void, transitionOut: @escaping (Stories.PendingTarget?) -> StoryCameraTransitionOut?) -> StoryCameraTransitionInCoordinator? {
guard let controller = self.viewControllers.last as? ViewController else {
return nil
}
@ -274,6 +274,8 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
let context = self.context
var storyTarget: Stories.PendingTarget?
var presentImpl: ((ViewController) -> Void)?
var returnToCameraImpl: (() -> Void)?
var dismissCameraImpl: (() -> Void)?
@ -293,7 +295,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
}
},
transitionOut: { finished in
if let transitionOut = transitionOut(finished), let destinationView = transitionOut.destinationView {
if let transitionOut = transitionOut(finished ? storyTarget : nil), let destinationView = transitionOut.destinationView {
return CameraScreen.TransitionOut(
destinationView: destinationView,
destinationRect: transitionOut.destinationRect,
@ -351,7 +353,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
isEditing: false,
transitionIn: transitionIn,
transitionOut: { finished, isNew in
if finished, let transitionOut = transitionOut(finished), let destinationView = transitionOut.destinationView {
if finished, let transitionOut = transitionOut(storyTarget), let destinationView = transitionOut.destinationView {
return MediaEditorScreen.TransitionOut(
destinationView: destinationView,
destinationRect: transitionOut.destinationRect,
@ -403,13 +405,21 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
}
}
let target: Stories.PendingTarget
#if DEBUG
target = .peer(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(2200678799)))
#else
target = .myStories
#endif
storyTarget = target
if let _ = self.chatListController as? ChatListControllerImpl {
switch mediaResult {
case let .image(image, dimensions):
if let imageData = compressImageToJPEG(image, quality: 0.7) {
let entities = generateChatInputTextEntities(caption)
Logger.shared.log("MediaEditor", "Calling uploadStory for image, randomId \(randomId)")
let _ = (context.engine.messages.uploadStory(media: .image(dimensions: dimensions, data: imageData, stickers: stickers), mediaAreas: mediaAreas, text: caption.string, entities: entities, pin: privacy.pin, privacy: privacy.privacy, isForwardingDisabled: privacy.isForwardingDisabled, period: privacy.timeout, randomId: randomId)
let _ = (context.engine.messages.uploadStory(target: target, media: .image(dimensions: dimensions, data: imageData, stickers: stickers), mediaAreas: mediaAreas, text: caption.string, entities: entities, pin: privacy.pin, privacy: privacy.privacy, isForwardingDisabled: privacy.isForwardingDisabled, period: privacy.timeout, randomId: randomId)
|> deliverOnMainQueue).start(next: { stableId in
moveStorySource(engine: context.engine, peerId: context.account.peerId, from: randomId, to: Int64(stableId))
})
@ -443,7 +453,7 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
}
Logger.shared.log("MediaEditor", "Calling uploadStory for video, randomId \(randomId)")
let entities = generateChatInputTextEntities(caption)
let _ = (context.engine.messages.uploadStory(media: .video(dimensions: dimensions, duration: duration, resource: resource, firstFrameFile: firstFrameFile, stickers: stickers), mediaAreas: mediaAreas, text: caption.string, entities: entities, pin: privacy.pin, privacy: privacy.privacy, isForwardingDisabled: privacy.isForwardingDisabled, period: privacy.timeout, randomId: randomId)
let _ = (context.engine.messages.uploadStory(target: target, media: .video(dimensions: dimensions, duration: duration, resource: resource, firstFrameFile: firstFrameFile, stickers: stickers), mediaAreas: mediaAreas, text: caption.string, entities: entities, pin: privacy.pin, privacy: privacy.privacy, isForwardingDisabled: privacy.isForwardingDisabled, period: privacy.timeout, randomId: randomId)
|> deliverOnMainQueue).start(next: { stableId in
moveStorySource(engine: context.engine, peerId: context.account.peerId, from: randomId, to: Int64(stableId))
})