Update API [skip ci]

This commit is contained in:
Ali 2023-05-16 15:28:17 +04:00
parent 8477cf454c
commit 0d39380cdf
8 changed files with 43 additions and 61 deletions

View File

@ -209,7 +209,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1744710921] = { return Api.DocumentAttribute.parse_documentAttributeHasStickers($0) }
dict[1815593308] = { return Api.DocumentAttribute.parse_documentAttributeImageSize($0) }
dict[1662637586] = { return Api.DocumentAttribute.parse_documentAttributeSticker($0) }
dict[250621158] = { return Api.DocumentAttribute.parse_documentAttributeVideo($0) }
dict[-381651053] = { return Api.DocumentAttribute.parse_documentAttributeVideo($0) }
dict[-40996577] = { return Api.DraftMessage.parse_draftMessage($0) }
dict[453805082] = { return Api.DraftMessage.parse_draftMessageEmpty($0) }
dict[-1764723459] = { return Api.EmailVerification.parse_emailVerificationApple($0) }
@ -937,8 +937,7 @@ 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[333268946] = { return Api.UserStories.parse_userStories($0) }
dict[827991632] = { return Api.UserStories.parse_userStoriesSlice($0) }
dict[-144780892] = { 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) }

View File

@ -888,76 +888,54 @@ public extension Api {
}
public extension Api {
enum UserStories: TypeConstructorDescription {
case userStories(userId: Int64, stories: [Api.StoryItem])
case userStoriesSlice(count: Int32, userId: Int64, stories: [Api.StoryItem])
case userStories(flags: Int32, userId: Int64, maxReadId: Int32?, stories: [Api.StoryItem], missingCount: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .userStories(let userId, let stories):
case .userStories(let flags, let userId, let maxReadId, let stories, let missingCount):
if boxed {
buffer.appendInt32(333268946)
buffer.appendInt32(-144780892)
}
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
case .userStoriesSlice(let count, let userId, let stories):
if boxed {
buffer.appendInt32(827991632)
}
serializeInt32(count, buffer: buffer, boxed: false)
serializeInt64(userId, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(stories.count))
for item in stories {
item.serialize(buffer, true)
}
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(missingCount!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .userStories(let userId, let stories):
return ("userStories", [("userId", userId as Any), ("stories", stories as Any)])
case .userStoriesSlice(let count, let userId, let stories):
return ("userStoriesSlice", [("count", count as Any), ("userId", userId as Any), ("stories", stories as Any)])
case .userStories(let flags, let userId, let maxReadId, let stories, let missingCount):
return ("userStories", [("flags", flags as Any), ("userId", userId as Any), ("maxReadId", maxReadId as Any), ("stories", stories as Any), ("missingCount", missingCount as Any)])
}
}
public static func parse_userStories(_ reader: BufferReader) -> UserStories? {
var _1: Int64?
_1 = reader.readInt64()
var _2: [Api.StoryItem]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StoryItem.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.UserStories.userStories(userId: _1!, stories: _2!)
}
else {
return nil
}
}
public static func parse_userStoriesSlice(_ reader: BufferReader) -> UserStories? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
var _3: [Api.StoryItem]?
var _3: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() }
var _4: [Api.StoryItem]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StoryItem.self)
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StoryItem.self)
}
var _5: Int32?
if Int(_1!) & Int(1 << 1) != 0 {_5 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.UserStories.userStoriesSlice(count: _1!, userId: _2!, stories: _3!)
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.UserStories.userStories(flags: _1!, userId: _2!, maxReadId: _3, stories: _4!, missingCount: _5)
}
else {
return nil

View File

@ -1377,7 +1377,7 @@ public extension Api {
case documentAttributeHasStickers
case documentAttributeImageSize(w: Int32, h: Int32)
case documentAttributeSticker(flags: Int32, alt: String, stickerset: Api.InputStickerSet, maskCoords: Api.MaskCoords?)
case documentAttributeVideo(flags: Int32, duration: Int32, w: Int32, h: Int32)
case documentAttributeVideo(flags: Int32, duration: Int32, w: Int32, h: Int32, preloadPrefixSize: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -1433,14 +1433,15 @@ public extension Api {
stickerset.serialize(buffer, true)
if Int(flags) & Int(1 << 0) != 0 {maskCoords!.serialize(buffer, true)}
break
case .documentAttributeVideo(let flags, let duration, let w, let h):
case .documentAttributeVideo(let flags, let duration, let w, let h, let preloadPrefixSize):
if boxed {
buffer.appendInt32(250621158)
buffer.appendInt32(-381651053)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(duration, buffer: buffer, boxed: false)
serializeInt32(w, buffer: buffer, boxed: false)
serializeInt32(h, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(preloadPrefixSize!, buffer: buffer, boxed: false)}
break
}
}
@ -1461,8 +1462,8 @@ public extension Api {
return ("documentAttributeImageSize", [("w", w as Any), ("h", h as Any)])
case .documentAttributeSticker(let flags, let alt, let stickerset, let maskCoords):
return ("documentAttributeSticker", [("flags", flags as Any), ("alt", alt as Any), ("stickerset", stickerset as Any), ("maskCoords", maskCoords as Any)])
case .documentAttributeVideo(let flags, let duration, let w, let h):
return ("documentAttributeVideo", [("flags", flags as Any), ("duration", duration as Any), ("w", w as Any), ("h", h as Any)])
case .documentAttributeVideo(let flags, let duration, let w, let h, let preloadPrefixSize):
return ("documentAttributeVideo", [("flags", flags as Any), ("duration", duration as Any), ("w", w as Any), ("h", h as Any), ("preloadPrefixSize", preloadPrefixSize as Any)])
}
}
@ -1572,12 +1573,15 @@ public extension Api {
_3 = reader.readInt32()
var _4: Int32?
_4 = reader.readInt32()
var _5: Int32?
if Int(_1!) & Int(1 << 2) != 0 {_5 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.DocumentAttribute.documentAttributeVideo(flags: _1!, duration: _2!, w: _3!, h: _4!)
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.DocumentAttribute.documentAttributeVideo(flags: _1!, duration: _2!, w: _3!, h: _4!, preloadPrefixSize: _5)
}
else {
return nil

View File

@ -97,7 +97,7 @@ func telegramMediaFileAttributesFromApiAttributes(_ attributes: [Api.DocumentAtt
result.append(.ImageSize(size: PixelDimensions(width: w, height: h)))
case .documentAttributeAnimated:
result.append(.Animated)
case let .documentAttributeVideo(flags, duration, w, h):
case let .documentAttributeVideo(flags, duration, w, h, _):
var videoFlags = TelegramMediaVideoFlags()
if (flags & (1 << 0)) != 0 {
videoFlags.insert(.instantRoundVideo)

View File

@ -558,7 +558,7 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF
flags |= (1 << 1)
}
attributes.append(.documentAttributeVideo(flags: flags, duration: Int32(duration), w: Int32(size.width), h: Int32(size.height)))
attributes.append(.documentAttributeVideo(flags: flags, duration: Int32(duration), w: Int32(size.width), h: Int32(size.height), preloadPrefixSize: nil))
case let .Audio(isVoice, duration, title, performer, waveform):
var flags: Int32 = 0
if isVoice {

View File

@ -4330,7 +4330,9 @@ func replayFinalState(
}
case let .UpdateStories(updateStories):
switch updateStories {
case .userStories(let userId, let stories), .userStoriesSlice(_, let userId, let stories):
case let .userStories(_, userId, maxReadId, stories, missingCount):
let _ = maxReadId
let _ = missingCount
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
for storyItem in stories {
if let parsedItem = _internal_parseApiStoryItem(transaction: transaction, peerId: peerId, apiStory: storyItem) {

View File

@ -180,7 +180,7 @@ func _internal_uploadStory(account: Account, media: EngineStoryInputMedia, text:
for update in updates.allUpdates {
if case let .updateStories(stories) = update {
switch stories {
case .userStories(let userId, let apiStories), .userStoriesSlice(_, let userId, let apiStories):
case let .userStories(_, userId, _, apiStories, _):
if PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) == account.peerId, apiStories.count == 1 {
switch apiStories[0] {
case let .storyItem(_, _, _, _, _, media, _, _):

View File

@ -469,14 +469,13 @@ public final class StoryListContext {
let apiUserId: Int64
let apiStories: [Api.StoryItem]
var apiTotalCount: Int32?
var apiMaxReadId: Int32 = 0
switch userStories {
case let .userStories(userId, stories):
case let .userStories(_, userId, maxReadId, stories, missingCount):
apiUserId = userId
apiStories = stories
case let .userStoriesSlice(totalCount, userId, stories):
apiUserId = userId
apiStories = stories
apiTotalCount = totalCount
apiTotalCount = (missingCount ?? 0) + Int32(stories.count)
apiMaxReadId = maxReadId ?? 0
}
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(apiUserId))
@ -488,7 +487,7 @@ public final class StoryListContext {
parsedItemSets.append(StoryListContext.PeerItemSet(
peerId: peerId,
peer: transaction.getPeer(peerId).flatMap(EnginePeer.init),
maxReadId: 0,
maxReadId: apiMaxReadId,
items: [item],
totalCount: apiTotalCount.flatMap(Int.init)
))