Update API

This commit is contained in:
Isaac 2023-12-27 01:22:25 +04:00
parent 626e94f72b
commit ee90dd8332
15 changed files with 467 additions and 105 deletions

View File

@ -6,6 +6,7 @@ public enum Api {
public enum channels {}
public enum chatlists {}
public enum contacts {}
public enum feed {}
public enum help {}
public enum messages {}
public enum payments {}
@ -26,6 +27,7 @@ public enum Api {
public enum channels {}
public enum chatlists {}
public enum contacts {}
public enum feed {}
public enum folders {}
public enum help {}
public enum langpack {}
@ -252,6 +254,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1103040667] = { return Api.ExportedContactToken.parse_exportedContactToken($0) }
dict[1571494644] = { return Api.ExportedMessageLink.parse_exportedMessageLink($0) }
dict[1070138683] = { return Api.ExportedStoryLink.parse_exportedStoryLink($0) }
dict[1348066419] = { return Api.FeedPosition.parse_feedPosition($0) }
dict[-207944868] = { return Api.FileHash.parse_fileHash($0) }
dict[-11252123] = { return Api.Folder.parse_folder($0) }
dict[-373643672] = { return Api.FolderPeer.parse_folderPeer($0) }
@ -539,7 +542,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1859134776] = { return Api.MessageEntity.parse_messageEntityUrl($0) }
dict[-297296796] = { return Api.MessageExtendedMedia.parse_messageExtendedMedia($0) }
dict[-1386050360] = { return Api.MessageExtendedMedia.parse_messageExtendedMediaPreview($0) }
dict[1601666510] = { return Api.MessageFwdHeader.parse_messageFwdHeader($0) }
dict[1313731771] = { return Api.MessageFwdHeader.parse_messageFwdHeader($0) }
dict[1882335561] = { return Api.MessageMedia.parse_messageMediaContact($0) }
dict[1065280907] = { return Api.MessageMedia.parse_messageMediaDice($0) }
dict[1291114285] = { return Api.MessageMedia.parse_messageMediaDocument($0) }
@ -949,6 +952,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1218471511] = { return Api.Update.parse_updateReadChannelOutbox($0) }
dict[-78886548] = { return Api.Update.parse_updateReadFeaturedEmojiStickers($0) }
dict[1461528386] = { return Api.Update.parse_updateReadFeaturedStickers($0) }
dict[1951948721] = { return Api.Update.parse_updateReadFeed($0) }
dict[-1667805217] = { return Api.Update.parse_updateReadHistoryInbox($0) }
dict[791617983] = { return Api.Update.parse_updateReadHistoryOutbox($0) }
dict[-131960447] = { return Api.Update.parse_updateReadMessagesContents($0) }
@ -1088,6 +1092,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1891070632] = { return Api.contacts.TopPeers.parse_topPeers($0) }
dict[-1255369827] = { return Api.contacts.TopPeers.parse_topPeersDisabled($0) }
dict[-567906571] = { return Api.contacts.TopPeers.parse_topPeersNotModified($0) }
dict[-587770695] = { return Api.feed.FeedMessages.parse_feedMessages($0) }
dict[-619039485] = { return Api.feed.FeedMessages.parse_feedMessagesNotModified($0) }
dict[-585598930] = { return Api.help.AppConfig.parse_appConfig($0) }
dict[2094949405] = { return Api.help.AppConfig.parse_appConfigNotModified($0) }
dict[-860107216] = { return Api.help.AppUpdate.parse_appUpdate($0) }
@ -1463,6 +1469,8 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.ExportedStoryLink:
_1.serialize(buffer, boxed)
case let _1 as Api.FeedPosition:
_1.serialize(buffer, boxed)
case let _1 as Api.FileHash:
_1.serialize(buffer, boxed)
case let _1 as Api.Folder:
@ -1959,6 +1967,8 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.contacts.TopPeers:
_1.serialize(buffer, boxed)
case let _1 as Api.feed.FeedMessages:
_1.serialize(buffer, boxed)
case let _1 as Api.help.AppConfig:
_1.serialize(buffer, boxed)
case let _1 as Api.help.AppUpdate:

View File

@ -618,13 +618,13 @@ public extension Api {
}
public extension Api {
enum MessageFwdHeader: TypeConstructorDescription {
case messageFwdHeader(flags: Int32, fromId: Api.Peer?, fromName: String?, date: Int32, channelPost: Int32?, postAuthor: String?, savedFromPeer: Api.Peer?, savedFromMsgId: Int32?, psaType: String?)
case messageFwdHeader(flags: Int32, fromId: Api.Peer?, fromName: String?, date: Int32, channelPost: Int32?, postAuthor: String?, savedFromPeer: Api.Peer?, savedFromMsgId: Int32?, savedFromId: Api.Peer?, savedFromName: String?, savedDate: Int32?, psaType: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .messageFwdHeader(let flags, let fromId, let fromName, let date, let channelPost, let postAuthor, let savedFromPeer, let savedFromMsgId, let psaType):
case .messageFwdHeader(let flags, let fromId, let fromName, let date, let channelPost, let postAuthor, let savedFromPeer, let savedFromMsgId, let savedFromId, let savedFromName, let savedDate, let psaType):
if boxed {
buffer.appendInt32(1601666510)
buffer.appendInt32(1313731771)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {fromId!.serialize(buffer, true)}
@ -634,6 +634,9 @@ public extension Api {
if Int(flags) & Int(1 << 3) != 0 {serializeString(postAuthor!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 4) != 0 {savedFromPeer!.serialize(buffer, true)}
if Int(flags) & Int(1 << 4) != 0 {serializeInt32(savedFromMsgId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 8) != 0 {savedFromId!.serialize(buffer, true)}
if Int(flags) & Int(1 << 9) != 0 {serializeString(savedFromName!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 10) != 0 {serializeInt32(savedDate!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 6) != 0 {serializeString(psaType!, buffer: buffer, boxed: false)}
break
}
@ -641,8 +644,8 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .messageFwdHeader(let flags, let fromId, let fromName, let date, let channelPost, let postAuthor, let savedFromPeer, let savedFromMsgId, let psaType):
return ("messageFwdHeader", [("flags", flags as Any), ("fromId", fromId as Any), ("fromName", fromName as Any), ("date", date as Any), ("channelPost", channelPost as Any), ("postAuthor", postAuthor as Any), ("savedFromPeer", savedFromPeer as Any), ("savedFromMsgId", savedFromMsgId as Any), ("psaType", psaType as Any)])
case .messageFwdHeader(let flags, let fromId, let fromName, let date, let channelPost, let postAuthor, let savedFromPeer, let savedFromMsgId, let savedFromId, let savedFromName, let savedDate, let psaType):
return ("messageFwdHeader", [("flags", flags as Any), ("fromId", fromId as Any), ("fromName", fromName as Any), ("date", date as Any), ("channelPost", channelPost as Any), ("postAuthor", postAuthor as Any), ("savedFromPeer", savedFromPeer as Any), ("savedFromMsgId", savedFromMsgId as Any), ("savedFromId", savedFromId as Any), ("savedFromName", savedFromName as Any), ("savedDate", savedDate as Any), ("psaType", psaType as Any)])
}
}
@ -667,8 +670,16 @@ public extension Api {
} }
var _8: Int32?
if Int(_1!) & Int(1 << 4) != 0 {_8 = reader.readInt32() }
var _9: String?
if Int(_1!) & Int(1 << 6) != 0 {_9 = parseString(reader) }
var _9: Api.Peer?
if Int(_1!) & Int(1 << 8) != 0 {if let signature = reader.readInt32() {
_9 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _10: String?
if Int(_1!) & Int(1 << 9) != 0 {_10 = parseString(reader) }
var _11: Int32?
if Int(_1!) & Int(1 << 10) != 0 {_11 = reader.readInt32() }
var _12: String?
if Int(_1!) & Int(1 << 6) != 0 {_12 = parseString(reader) }
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 5) == 0) || _3 != nil
@ -677,9 +688,12 @@ public extension Api {
let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 4) == 0) || _8 != nil
let _c9 = (Int(_1!) & Int(1 << 6) == 0) || _9 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
return Api.MessageFwdHeader.messageFwdHeader(flags: _1!, fromId: _2, fromName: _3, date: _4!, channelPost: _5, postAuthor: _6, savedFromPeer: _7, savedFromMsgId: _8, psaType: _9)
let _c9 = (Int(_1!) & Int(1 << 8) == 0) || _9 != nil
let _c10 = (Int(_1!) & Int(1 << 9) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 10) == 0) || _11 != nil
let _c12 = (Int(_1!) & Int(1 << 6) == 0) || _12 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 {
return Api.MessageFwdHeader.messageFwdHeader(flags: _1!, fromId: _2, fromName: _3, date: _4!, channelPost: _5, postAuthor: _6, savedFromPeer: _7, savedFromMsgId: _8, savedFromId: _9, savedFromName: _10, savedDate: _11, psaType: _12)
}
else {
return nil

View File

@ -559,6 +559,7 @@ public extension Api {
case updateReadChannelOutbox(channelId: Int64, maxId: Int32)
case updateReadFeaturedEmojiStickers
case updateReadFeaturedStickers
case updateReadFeed(flags: Int32, filterId: Int32, maxPosition: Api.FeedPosition, unreadCount: Int32?, unreadMutedCount: Int32?)
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(flags: Int32, messages: [Int32], pts: Int32, ptsCount: Int32, date: Int32?)
@ -1450,6 +1451,16 @@ public extension Api {
buffer.appendInt32(1461528386)
}
break
case .updateReadFeed(let flags, let filterId, let maxPosition, let unreadCount, let unreadMutedCount):
if boxed {
buffer.appendInt32(1951948721)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(filterId, buffer: buffer, boxed: false)
maxPosition.serialize(buffer, true)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(unreadCount!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(unreadMutedCount!, buffer: buffer, boxed: false)}
break
case .updateReadHistoryInbox(let flags, let folderId, let peer, let maxId, let stillUnreadCount, let pts, let ptsCount):
if boxed {
@ -1866,6 +1877,8 @@ public extension Api {
return ("updateReadFeaturedEmojiStickers", [])
case .updateReadFeaturedStickers:
return ("updateReadFeaturedStickers", [])
case .updateReadFeed(let flags, let filterId, let maxPosition, let unreadCount, let unreadMutedCount):
return ("updateReadFeed", [("flags", flags as Any), ("filterId", filterId as Any), ("maxPosition", maxPosition as Any), ("unreadCount", unreadCount as Any), ("unreadMutedCount", unreadMutedCount as Any)])
case .updateReadHistoryInbox(let flags, let folderId, let peer, let maxId, let stillUnreadCount, let pts, let ptsCount):
return ("updateReadHistoryInbox", [("flags", flags as Any), ("folderId", folderId as Any), ("peer", peer as Any), ("maxId", maxId as Any), ("stillUnreadCount", stillUnreadCount as Any), ("pts", pts as Any), ("ptsCount", ptsCount as Any)])
case .updateReadHistoryOutbox(let peer, let maxId, let pts, let ptsCount):
@ -3688,6 +3701,31 @@ public extension Api {
public static func parse_updateReadFeaturedStickers(_ reader: BufferReader) -> Update? {
return Api.Update.updateReadFeaturedStickers
}
public static func parse_updateReadFeed(_ reader: BufferReader) -> Update? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Api.FeedPosition?
if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.FeedPosition
}
var _4: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_4 = reader.readInt32() }
var _5: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.Update.updateReadFeed(flags: _1!, filterId: _2!, maxPosition: _3!, unreadCount: _4, unreadMutedCount: _5)
}
else {
return nil
}
}
public static func parse_updateReadHistoryInbox(_ reader: BufferReader) -> Update? {
var _1: Int32?
_1 = reader.readInt32()

View File

@ -634,6 +634,102 @@ public extension Api.contacts {
}
}
public extension Api.feed {
enum FeedMessages: TypeConstructorDescription {
case feedMessages(flags: Int32, maxPosition: Api.FeedPosition?, minPosition: Api.FeedPosition?, readMaxPosition: Api.FeedPosition?, messages: [Api.Message], chats: [Api.Chat], users: [Api.User])
case feedMessagesNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .feedMessages(let flags, let maxPosition, let minPosition, let readMaxPosition, let messages, let chats, let users):
if boxed {
buffer.appendInt32(-587770695)
}
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {maxPosition!.serialize(buffer, true)}
if Int(flags) & Int(1 << 1) != 0 {minPosition!.serialize(buffer, true)}
if Int(flags) & Int(1 << 2) != 0 {readMaxPosition!.serialize(buffer, true)}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(messages.count))
for item in messages {
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 .feedMessagesNotModified:
if boxed {
buffer.appendInt32(-619039485)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .feedMessages(let flags, let maxPosition, let minPosition, let readMaxPosition, let messages, let chats, let users):
return ("feedMessages", [("flags", flags as Any), ("maxPosition", maxPosition as Any), ("minPosition", minPosition as Any), ("readMaxPosition", readMaxPosition as Any), ("messages", messages as Any), ("chats", chats as Any), ("users", users as Any)])
case .feedMessagesNotModified:
return ("feedMessagesNotModified", [])
}
}
public static func parse_feedMessages(_ reader: BufferReader) -> FeedMessages? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Api.FeedPosition?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_2 = Api.parse(reader, signature: signature) as? Api.FeedPosition
} }
var _3: Api.FeedPosition?
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.FeedPosition
} }
var _4: Api.FeedPosition?
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.FeedPosition
} }
var _5: [Api.Message]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self)
}
var _6: [Api.Chat]?
if let _ = reader.readInt32() {
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _7: [Api.User]?
if let _ = reader.readInt32() {
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.feed.FeedMessages.feedMessages(flags: _1!, maxPosition: _2, minPosition: _3, readMaxPosition: _4, messages: _5!, chats: _6!, users: _7!)
}
else {
return nil
}
}
public static func parse_feedMessagesNotModified(_ reader: BufferReader) -> FeedMessages? {
return Api.feed.FeedMessages.feedMessagesNotModified
}
}
}
public extension Api.help {
enum AppConfig: TypeConstructorDescription {
case appConfig(hash: Int32, config: Api.JSONValue)
@ -1304,89 +1400,3 @@ public extension Api.help {
}
}
public extension Api.help {
enum PremiumPromo: TypeConstructorDescription {
case premiumPromo(statusText: String, statusEntities: [Api.MessageEntity], videoSections: [String], videos: [Api.Document], periodOptions: [Api.PremiumSubscriptionOption], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .premiumPromo(let statusText, let statusEntities, let videoSections, let videos, let periodOptions, let users):
if boxed {
buffer.appendInt32(1395946908)
}
serializeString(statusText, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(statusEntities.count))
for item in statusEntities {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(videoSections.count))
for item in videoSections {
serializeString(item, buffer: buffer, boxed: false)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(videos.count))
for item in videos {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(periodOptions.count))
for item in periodOptions {
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 .premiumPromo(let statusText, let statusEntities, let videoSections, let videos, let periodOptions, let users):
return ("premiumPromo", [("statusText", statusText as Any), ("statusEntities", statusEntities as Any), ("videoSections", videoSections as Any), ("videos", videos as Any), ("periodOptions", periodOptions as Any), ("users", users as Any)])
}
}
public static func parse_premiumPromo(_ reader: BufferReader) -> PremiumPromo? {
var _1: String?
_1 = parseString(reader)
var _2: [Api.MessageEntity]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
}
var _3: [String]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self)
}
var _4: [Api.Document]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
}
var _5: [Api.PremiumSubscriptionOption]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PremiumSubscriptionOption.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 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.help.PremiumPromo.premiumPromo(statusText: _1!, statusEntities: _2!, videoSections: _3!, videos: _4!, periodOptions: _5!, users: _6!)
}
else {
return nil
}
}
}
}

View File

@ -1,3 +1,89 @@
public extension Api.help {
enum PremiumPromo: TypeConstructorDescription {
case premiumPromo(statusText: String, statusEntities: [Api.MessageEntity], videoSections: [String], videos: [Api.Document], periodOptions: [Api.PremiumSubscriptionOption], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .premiumPromo(let statusText, let statusEntities, let videoSections, let videos, let periodOptions, let users):
if boxed {
buffer.appendInt32(1395946908)
}
serializeString(statusText, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(statusEntities.count))
for item in statusEntities {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(videoSections.count))
for item in videoSections {
serializeString(item, buffer: buffer, boxed: false)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(videos.count))
for item in videos {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(periodOptions.count))
for item in periodOptions {
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 .premiumPromo(let statusText, let statusEntities, let videoSections, let videos, let periodOptions, let users):
return ("premiumPromo", [("statusText", statusText as Any), ("statusEntities", statusEntities as Any), ("videoSections", videoSections as Any), ("videos", videos as Any), ("periodOptions", periodOptions as Any), ("users", users as Any)])
}
}
public static func parse_premiumPromo(_ reader: BufferReader) -> PremiumPromo? {
var _1: String?
_1 = parseString(reader)
var _2: [Api.MessageEntity]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
}
var _3: [String]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self)
}
var _4: [Api.Document]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
}
var _5: [Api.PremiumSubscriptionOption]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PremiumSubscriptionOption.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 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.help.PremiumPromo.premiumPromo(statusText: _1!, statusEntities: _2!, videoSections: _3!, videos: _4!, periodOptions: _5!, users: _6!)
}
else {
return nil
}
}
}
}
public extension Api.help {
enum PromoData: TypeConstructorDescription {
case promoData(flags: Int32, expires: Int32, peer: Api.Peer, chats: [Api.Chat], users: [Api.User], psaType: String?, psaMessage: String?)

View File

@ -3770,6 +3770,44 @@ public extension Api.functions.contacts {
})
}
}
public extension Api.functions.feed {
static func getFeed(flags: Int32, filterId: Int32, offsetPosition: Api.FeedPosition?, addOffset: Int32, limit: Int32, maxPosition: Api.FeedPosition?, minPosition: Api.FeedPosition?, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.feed.FeedMessages>) {
let buffer = Buffer()
buffer.appendInt32(2121717715)
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(filterId, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {offsetPosition!.serialize(buffer, true)}
serializeInt32(addOffset, buffer: buffer, boxed: false)
serializeInt32(limit, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {maxPosition!.serialize(buffer, true)}
if Int(flags) & Int(1 << 2) != 0 {minPosition!.serialize(buffer, true)}
serializeInt64(hash, buffer: buffer, boxed: false)
return (FunctionDescription(name: "feed.getFeed", parameters: [("flags", String(describing: flags)), ("filterId", String(describing: filterId)), ("offsetPosition", String(describing: offsetPosition)), ("addOffset", String(describing: addOffset)), ("limit", String(describing: limit)), ("maxPosition", String(describing: maxPosition)), ("minPosition", String(describing: minPosition)), ("hash", String(describing: hash))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.feed.FeedMessages? in
let reader = BufferReader(buffer)
var result: Api.feed.FeedMessages?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.feed.FeedMessages
}
return result
})
}
}
public extension Api.functions.feed {
static func readFeed(filterId: Int32, maxPosition: Api.FeedPosition) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(-1271479809)
serializeInt32(filterId, buffer: buffer, boxed: false)
maxPosition.serialize(buffer, true)
return (FunctionDescription(name: "feed.readFeed", parameters: [("filterId", String(describing: filterId)), ("maxPosition", String(describing: maxPosition))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Updates
}
return result
})
}
}
public extension Api.functions.folders {
static func editPeerFolders(folderPeers: [Api.InputFolderPeer]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()

View File

@ -74,6 +74,52 @@ public extension Api {
}
}
public extension Api {
enum FeedPosition: TypeConstructorDescription {
case feedPosition(date: Int32, peer: Api.Peer, id: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .feedPosition(let date, let peer, let id):
if boxed {
buffer.appendInt32(1348066419)
}
serializeInt32(date, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
serializeInt32(id, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .feedPosition(let date, let peer, let id):
return ("feedPosition", [("date", date as Any), ("peer", peer as Any), ("id", id as Any)])
}
}
public static func parse_feedPosition(_ reader: BufferReader) -> FeedPosition? {
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?
_3 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.FeedPosition.feedPosition(date: _1!, peer: _2!, id: _3!)
}
else {
return nil
}
}
}
}
public extension Api {
enum FileHash: TypeConstructorDescription {
case fileHash(offset: Int64, limit: Int32, hash: Buffer)

View File

@ -116,6 +116,7 @@ private var declaredEncodables: Void = {
declareEncodable(OutgoingMessageInfoAttribute.self, f: { OutgoingMessageInfoAttribute(decoder: $0) })
declareEncodable(ForwardSourceInfoAttribute.self, f: { ForwardSourceInfoAttribute(decoder: $0) })
declareEncodable(SourceReferenceMessageAttribute.self, f: { SourceReferenceMessageAttribute(decoder: $0) })
declareEncodable(SourceAuthorInfoMessageAttribute.self, f: { SourceAuthorInfoMessageAttribute(decoder: $0) })
declareEncodable(EditedMessageAttribute.self, f: { EditedMessageAttribute(decoder: $0) })
declareEncodable(ReplyMarkupMessageAttribute.self, f: { ReplyMarkupMessageAttribute(decoder: $0) })
declareEncodable(OutgoingChatContextResultMessageAttribute.self, f: { OutgoingChatContextResultMessageAttribute(decoder: $0) })

View File

@ -155,13 +155,16 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
if let fwdHeader = fwdHeader {
switch fwdHeader {
case let .messageFwdHeader(_, fromId, _, _, _, _, savedFromPeer, _, _):
case let .messageFwdHeader(_, fromId, _, _, _, _, savedFromPeer, _, savedFromId, _, _, _):
if let fromId = fromId {
result.append(fromId.peerId)
}
if let savedFromPeer = savedFromPeer {
result.append(savedFromPeer.peerId)
}
if let savedFromId = savedFromId {
result.append(savedFromId.peerId)
}
}
}
@ -669,7 +672,7 @@ extension StoreMessage {
var forwardInfo: StoreMessageForwardInfo?
if let fwdFrom = fwdFrom {
switch fwdFrom {
case let .messageFwdHeader(flags, fromId, fromName, date, channelPost, postAuthor, savedFromPeer, savedFromMsgId, psaType):
case let .messageFwdHeader(flags, fromId, fromName, date, channelPost, postAuthor, savedFromPeer, savedFromMsgId, savedFromId, savedFromName, savedDate, psaType):
var forwardInfoFlags: MessageForwardInfo.Flags = []
let isImported = (flags & (1 << 7)) != 0
if isImported {
@ -693,15 +696,20 @@ extension StoreMessage {
authorId = fromId.peerId
}
}
let originalOutgoing = (flags & (1 << 11)) != 0
if let savedFromPeer = savedFromPeer, let savedFromMsgId = savedFromMsgId {
let peerId: PeerId = savedFromPeer.peerId
let messageId: MessageId = MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: savedFromMsgId)
attributes.append(SourceReferenceMessageAttribute(messageId: messageId))
}
if savedFromId != nil || savedFromName != nil || savedDate != nil || originalOutgoing {
attributes.append(SourceAuthorInfoMessageAttribute(originalAuthor: savedFromId?.peerId, originalAuthorName: savedFromName, orignalDate: savedDate, originalOutgoing: originalOutgoing))
}
if let authorId = authorId {
forwardInfo = StoreMessageForwardInfo(authorId: authorId, sourceId: sourceId, sourceMessageId: sourceMessageId, date: date, authorSignature: postAuthor, psaType: psaType, flags: forwardInfoFlags)
forwardInfo = StoreMessageForwardInfo(authorId: authorId, sourceId: sourceId, sourceMessageId: sourceMessageId, date: date, authorSignature: postAuthor, psaType: psaType, flags: forwardInfoFlags)
} else if let sourceId = sourceId {
forwardInfo = StoreMessageForwardInfo(authorId: sourceId, sourceId: sourceId, sourceMessageId: sourceMessageId, date: date, authorSignature: postAuthor, psaType: psaType, flags: forwardInfoFlags)
} else if let postAuthor = postAuthor ?? fromName {

View File

@ -109,7 +109,7 @@ public class QuotedReplyMessageAttribute: MessageAttribute {
extension QuotedReplyMessageAttribute {
convenience init(apiHeader: Api.MessageFwdHeader, quote: EngineMessageReplyQuote?, isQuote: Bool) {
switch apiHeader {
case let .messageFwdHeader(_, fromId, fromName, _, _, _, _, _, _):
case let .messageFwdHeader(_, fromId, fromName, _, _, _, _, _, _, _, _, _):
self.init(peerId: fromId?.peerId, authorName: fromName, quote: quote, isQuote: isQuote)
}
}

View File

@ -3,17 +3,20 @@ import Postbox
public class SourceReferenceMessageAttribute: MessageAttribute {
public let messageId: MessageId
public let associatedMessageIds: [MessageId] = []
public let associatedPeerIds: [PeerId]
public init(messageId: MessageId) {
self.messageId = messageId
self.associatedPeerIds = [messageId.peerId]
}
required public init(decoder: PostboxDecoder) {
let namespaceAndId: Int64 = decoder.decodeInt64ForKey("i", orElse: 0)
self.messageId = MessageId(peerId: PeerId(decoder.decodeInt64ForKey("p", orElse: 0)), namespace: Int32(namespaceAndId & 0xffffffff), id: Int32((namespaceAndId >> 32) & 0xffffffff))
self.associatedPeerIds = [self.messageId.peerId]
}
@ -24,4 +27,57 @@ public class SourceReferenceMessageAttribute: MessageAttribute {
}
}
public class SourceAuthorInfoMessageAttribute: MessageAttribute {
public let originalAuthor: PeerId?
public let originalAuthorName: String?
public let orignalDate: Int32?
public let originalOutgoing: Bool
public let associatedMessageIds: [MessageId] = []
public let associatedPeerIds: [PeerId]
public init(originalAuthor: PeerId?, originalAuthorName: String?, orignalDate: Int32?, originalOutgoing: Bool) {
self.originalAuthor = originalAuthor
self.originalAuthorName = originalAuthorName
self.orignalDate = orignalDate
self.originalOutgoing = originalOutgoing
if let originalAuthor = self.originalAuthor {
self.associatedPeerIds = [originalAuthor]
} else {
self.associatedPeerIds = []
}
}
required public init(decoder: PostboxDecoder) {
self.originalAuthor = decoder.decodeOptionalInt64ForKey("oa").flatMap(PeerId.init)
self.originalAuthorName = decoder.decodeOptionalStringForKey("oan")
self.orignalDate = decoder.decodeOptionalInt32ForKey("od")
self.originalOutgoing = decoder.decodeBoolForKey("oout", orElse: false)
if let originalAuthor = self.originalAuthor {
self.associatedPeerIds = [originalAuthor]
} else {
self.associatedPeerIds = []
}
}
public func encode(_ encoder: PostboxEncoder) {
if let originalAuthor = self.originalAuthor {
encoder.encodeInt64(originalAuthor.toInt64(), forKey: "oa")
} else {
encoder.encodeNil(forKey: "oa")
}
if let originalAuthorName = self.originalAuthorName {
encoder.encodeString(originalAuthorName, forKey: "oan")
} else {
encoder.encodeNil(forKey: "oan")
}
if let orignalDate = self.orignalDate {
encoder.encodeInt32(orignalDate, forKey: "od")
} else {
encoder.encodeNil(forKey: "od")
}
encoder.encodeBool(self.originalOutgoing, forKey: "oout")
}
}

View File

@ -114,7 +114,21 @@ public extension Message {
return nil
}
var sourceAuthorInfo: SourceAuthorInfoMessageAttribute? {
for attribute in self.attributes {
if let attribute = attribute as? SourceAuthorInfoMessageAttribute {
return attribute
}
}
return nil
}
var effectiveAuthor: Peer? {
if let sourceAuthorInfo = self.sourceAuthorInfo {
if let sourceAuthorId = sourceAuthorInfo.originalAuthor, let peer = self.peers[sourceAuthorId] {
return peer
}
}
if let forwardInfo = self.forwardInfo, let sourceReference = self.sourceReference, forwardInfo.author?.id == sourceReference.messageId.peerId {
if let peer = self.peers[sourceReference.messageId.peerId] {
return peer

View File

@ -1331,6 +1331,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
break
}
}
let sourceAuthorInfo = item.content.firstMessage.sourceAuthorInfo
var isCrosspostFromChannel = false
if let _ = sourceReference {
@ -1357,10 +1358,17 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
displayAuthorInfo = false
} else if item.message.id.peerId.isRepliesOrSavedMessages(accountPeerId: item.context.account.peerId) {
if let forwardInfo = item.content.firstMessage.forwardInfo {
ignoreForward = true
effectiveAuthor = forwardInfo.author
if effectiveAuthor == nil, let authorSignature = forwardInfo.authorSignature {
effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil)
if let sourceAuthorInfo, let originalAuthorId = sourceAuthorInfo.originalAuthor, let peer = item.message.peers[originalAuthorId] {
effectiveAuthor = peer
} else if let sourceAuthorInfo, let originalAuthorName = sourceAuthorInfo.originalAuthorName {
effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(originalAuthorName.persistentHashValue % 32))), accessHash: nil, firstName: originalAuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil)
} else {
ignoreForward = true
if effectiveAuthor == nil, let authorSignature = forwardInfo.authorSignature {
effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil)
}
}
}
displayAuthorInfo = !mergedTop.merged && incoming && effectiveAuthor != nil

View File

@ -86,6 +86,10 @@ public func stringForMessageTimestampStatus(accountPeerId: PeerId, message: Mess
timestamp = forwardInfo.date
}
if let sourceAuthorInfo = message.sourceAuthorInfo, let orignalDate = sourceAuthorInfo.orignalDate {
timestamp = orignalDate
}
var dateText = stringForMessageTimestamp(timestamp: timestamp, dateTimeFormat: dateTimeFormat)
if timestamp == scheduleWhenOnlineTimestamp {
dateText = " "

View File

@ -56,12 +56,24 @@ private func messagesShouldBeMerged(accountPeerId: PeerId, _ lhs: Message, _ rhs
break
}
}
let lhsSourceAuthorInfo = lhs.sourceAuthorInfo
if let sourceAuthorInfo = lhsSourceAuthorInfo {
if let originalAuthor = sourceAuthorInfo.originalAuthor {
lhsEffectiveAuthor = lhs.peers[originalAuthor]
}
}
for attribute in rhs.attributes {
if let attribute = attribute as? SourceReferenceMessageAttribute {
rhsEffectiveAuthor = rhs.peers[attribute.messageId.peerId]
break
}
}
let rhsSourceAuthorInfo = rhs.sourceAuthorInfo
if let sourceAuthorInfo = rhsSourceAuthorInfo {
if let originalAuthor = sourceAuthorInfo.originalAuthor {
rhsEffectiveAuthor = rhs.peers[originalAuthor]
}
}
var sameThread = true
if let lhsPeer = lhs.peers[lhs.id.peerId], let rhsPeer = rhs.peers[rhs.id.peerId], arePeersEqual(lhsPeer, rhsPeer), let channel = lhsPeer as? TelegramChannel, channel.flags.contains(.isForum), lhs.threadId != rhs.threadId {
@ -73,6 +85,16 @@ private func messagesShouldBeMerged(accountPeerId: PeerId, _ lhs: Message, _ rhs
sameAuthor = true
}
if let lhsSourceAuthorInfo, let rhsSourceAuthorInfo {
if lhsSourceAuthorInfo.originalAuthor != rhsSourceAuthorInfo.originalAuthor {
sameAuthor = false
} else if lhsSourceAuthorInfo.originalAuthorName != rhsSourceAuthorInfo.originalAuthorName {
sameAuthor = false
}
} else if (lhsSourceAuthorInfo == nil) != (rhsSourceAuthorInfo == nil) {
sameAuthor = false
}
var lhsEffectiveTimestamp = lhs.timestamp
var rhsEffectiveTimestamp = rhs.timestamp
@ -257,6 +279,13 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible
effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil)
}
}
if let sourceAuthorInfo = content.firstMessage.sourceAuthorInfo {
if let originalAuthor = sourceAuthorInfo.originalAuthor, let peer = content.firstMessage.peers[originalAuthor] {
effectiveAuthor = peer
} else if let authorSignature = sourceAuthorInfo.originalAuthorName {
effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil)
}
}
displayAuthorInfo = incoming && effectiveAuthor != nil
} else {
effectiveAuthor = content.firstMessage.author