mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-23 03:31:09 +00:00
Update API
This commit is contained in:
parent
3a47dab24e
commit
f7db73db40
@ -1124,7 +1124,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1667805217] = { return Api.Update.parse_updateReadHistoryInbox($0) }
|
||||
dict[791617983] = { return Api.Update.parse_updateReadHistoryOutbox($0) }
|
||||
dict[-131960447] = { return Api.Update.parse_updateReadMessagesContents($0) }
|
||||
dict[-1124907246] = { return Api.Update.parse_updateReadMonoForumInbox($0) }
|
||||
dict[2008081266] = { return Api.Update.parse_updateReadMonoForumInbox($0) }
|
||||
dict[-1532521610] = { return Api.Update.parse_updateReadMonoForumOutbox($0) }
|
||||
dict[-145845461] = { return Api.Update.parse_updateReadStories($0) }
|
||||
dict[821314523] = { return Api.Update.parse_updateRecentEmojiStatuses($0) }
|
||||
|
@ -1096,7 +1096,7 @@ 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(flags: Int32, messages: [Int32], pts: Int32, ptsCount: Int32, date: Int32?)
|
||||
case updateReadMonoForumInbox(flags: Int32, channelId: Int64, savedPeerId: Api.Peer, readMaxId: Int32)
|
||||
case updateReadMonoForumInbox(channelId: Int64, savedPeerId: Api.Peer, readMaxId: Int32)
|
||||
case updateReadMonoForumOutbox(channelId: Int64, savedPeerId: Api.Peer, readMaxId: Int32)
|
||||
case updateReadStories(peer: Api.Peer, maxId: Int32)
|
||||
case updateRecentEmojiStatuses
|
||||
@ -2168,11 +2168,10 @@ public extension Api {
|
||||
serializeInt32(ptsCount, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(date!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .updateReadMonoForumInbox(let flags, let channelId, let savedPeerId, let readMaxId):
|
||||
case .updateReadMonoForumInbox(let channelId, let savedPeerId, let readMaxId):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1124907246)
|
||||
buffer.appendInt32(2008081266)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(channelId, buffer: buffer, boxed: false)
|
||||
savedPeerId.serialize(buffer, true)
|
||||
serializeInt32(readMaxId, buffer: buffer, boxed: false)
|
||||
@ -2630,8 +2629,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 flags, let messages, let pts, let ptsCount, let date):
|
||||
return ("updateReadMessagesContents", [("flags", flags as Any), ("messages", messages as Any), ("pts", pts as Any), ("ptsCount", ptsCount as Any), ("date", date as Any)])
|
||||
case .updateReadMonoForumInbox(let flags, let channelId, let savedPeerId, let readMaxId):
|
||||
return ("updateReadMonoForumInbox", [("flags", flags as Any), ("channelId", channelId as Any), ("savedPeerId", savedPeerId as Any), ("readMaxId", readMaxId as Any)])
|
||||
case .updateReadMonoForumInbox(let channelId, let savedPeerId, let readMaxId):
|
||||
return ("updateReadMonoForumInbox", [("channelId", channelId as Any), ("savedPeerId", savedPeerId as Any), ("readMaxId", readMaxId as Any)])
|
||||
case .updateReadMonoForumOutbox(let channelId, let savedPeerId, let readMaxId):
|
||||
return ("updateReadMonoForumOutbox", [("channelId", channelId as Any), ("savedPeerId", savedPeerId as Any), ("readMaxId", readMaxId as Any)])
|
||||
case .updateReadStories(let peer, let maxId):
|
||||
@ -4838,22 +4837,19 @@ public extension Api {
|
||||
}
|
||||
}
|
||||
public static func parse_updateReadMonoForumInbox(_ reader: BufferReader) -> Update? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: Api.Peer?
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _2: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_3 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
var _4: Int32?
|
||||
_4 = reader.readInt32()
|
||||
var _3: Int32?
|
||||
_3 = 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.Update.updateReadMonoForumInbox(flags: _1!, channelId: _2!, savedPeerId: _3!, readMaxId: _4!)
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.Update.updateReadMonoForumInbox(channelId: _1!, savedPeerId: _2!, readMaxId: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -6856,6 +6856,27 @@ public extension Api.functions.messages {
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func getSavedDialogsByID(flags: Int32, parentPeer: Api.InputPeer?, ids: [Api.InputPeer]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.SavedDialogs>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1869585558)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 1) != 0 {parentPeer!.serialize(buffer, true)}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(ids.count))
|
||||
for item in ids {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
return (FunctionDescription(name: "messages.getSavedDialogsByID", parameters: [("flags", String(describing: flags)), ("parentPeer", String(describing: parentPeer)), ("ids", String(describing: ids))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.SavedDialogs? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.messages.SavedDialogs?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.messages.SavedDialogs
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func getSavedGifs(hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.SavedGifs>) {
|
||||
let buffer = Buffer()
|
||||
|
@ -1216,7 +1216,7 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
|
||||
updatedState.readThread(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: Int64(topMsgId), readMaxId: readMaxId, isIncoming: true, mainChannelMessage: mainChannelMessage)
|
||||
case let .updateReadChannelDiscussionOutbox(channelId, topMsgId, readMaxId):
|
||||
updatedState.readThread(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: Int64(topMsgId), readMaxId: readMaxId, isIncoming: false, mainChannelMessage: nil)
|
||||
case let .updateReadMonoForumInbox(_, channelId, savedPeerId, readMaxId):
|
||||
case let .updateReadMonoForumInbox(channelId, savedPeerId, readMaxId):
|
||||
updatedState.readThread(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: savedPeerId.peerId.toInt64(), readMaxId: readMaxId, isIncoming: true, mainChannelMessage: nil)
|
||||
case let .updateReadMonoForumOutbox(channelId, savedPeerId, readMaxId):
|
||||
updatedState.readThread(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: savedPeerId.peerId.toInt64(), readMaxId: readMaxId, isIncoming: false, mainChannelMessage: nil)
|
||||
@ -2019,31 +2019,10 @@ func resolveForumThreads(accountPeerId: PeerId, postbox: Postbox, source: FetchM
|
||||
}
|
||||
|
||||
if peer.flags.contains(.isMonoforum) {
|
||||
//TODO:release
|
||||
let signal = source.request(Api.functions.messages.getSavedDialogs(flags: 1 << 1, parentPeer: inputPeer, offsetDate: 0, offsetId: 0, offsetPeer: .inputPeerEmpty, limit: 100, hash: 0))
|
||||
let signal = source.request(Api.functions.messages.getSavedDialogsByID(flags: 1 << 1, parentPeer: inputPeer, ids: threadIds.compactMap { transaction.getPeer(PeerId($0)).flatMap(apiInputPeer(_:)) }))
|
||||
|> map { result -> (Peer, FetchedForumThreads)? in
|
||||
let result = FetchedForumThreads(savedDialogs: result)
|
||||
return (peer, FetchedForumThreads(
|
||||
items: result.items.filter({ item -> Bool in
|
||||
switch item {
|
||||
case let .savedDialog(savedDialog):
|
||||
switch savedDialog {
|
||||
case let .monoForumDialog(_, peer, _, _, _, _, _):
|
||||
return threadIds.contains(peer.peerId.toInt64())
|
||||
case .savedDialog:
|
||||
return false
|
||||
}
|
||||
case .forum:
|
||||
return false
|
||||
}
|
||||
}),
|
||||
totalCount: result.totalCount,
|
||||
orderByDate: result.orderByDate,
|
||||
pts: result.pts,
|
||||
messages: result.messages,
|
||||
users: result.users,
|
||||
chats: result.chats
|
||||
))
|
||||
return (peer, result)
|
||||
}
|
||||
|> `catch` { _ -> Signal<(Peer, FetchedForumThreads)?, NoError> in
|
||||
return .single(nil)
|
||||
@ -2191,30 +2170,10 @@ func resolveForumThreads(accountPeerId: PeerId, postbox: Postbox, source: FetchM
|
||||
}
|
||||
|
||||
if peer.flags.contains(.isMonoforum) {
|
||||
let signal = source.request(Api.functions.messages.getSavedDialogs(flags: 1 << 1, parentPeer: inputPeer, offsetDate: 0, offsetId: 0, offsetPeer: .inputPeerEmpty, limit: 100, hash: 0))
|
||||
let signal = source.request(Api.functions.messages.getSavedDialogsByID(flags: 1 << 1, parentPeer: inputPeer, ids: threadIds.compactMap { transaction.getPeer(PeerId($0)).flatMap(apiInputPeer(_:)) }))
|
||||
|> map { result -> (Peer, FetchedForumThreads)? in
|
||||
let result = FetchedForumThreads(savedDialogs: result)
|
||||
return (peer, FetchedForumThreads(
|
||||
items: result.items.filter({ item -> Bool in
|
||||
switch item {
|
||||
case let .savedDialog(savedDialog):
|
||||
switch savedDialog {
|
||||
case let .monoForumDialog(_, peer, _, _, _, _, _):
|
||||
return threadIds.contains(peer.peerId.toInt64())
|
||||
case .savedDialog:
|
||||
return false
|
||||
}
|
||||
case .forum:
|
||||
return false
|
||||
}
|
||||
}),
|
||||
totalCount: result.totalCount,
|
||||
orderByDate: result.orderByDate,
|
||||
pts: result.pts,
|
||||
messages: result.messages,
|
||||
users: result.users,
|
||||
chats: result.chats
|
||||
))
|
||||
return (peer, result)
|
||||
}
|
||||
|> `catch` { _ -> Signal<(Peer, FetchedForumThreads)?, NoError> in
|
||||
return .single(nil)
|
||||
@ -2366,31 +2325,10 @@ func resolveForumThreads(accountPeerId: PeerId, postbox: Postbox, source: FetchM
|
||||
}
|
||||
|
||||
if peer.flags.contains(.isMonoforum) {
|
||||
//TODO:release
|
||||
let signal = source.request(Api.functions.messages.getSavedDialogs(flags: 1 << 1, parentPeer: inputPeer, offsetDate: 0, offsetId: 0, offsetPeer: .inputPeerEmpty, limit: 100, hash: 0))
|
||||
let signal = source.request(Api.functions.messages.getSavedDialogsByID(flags: 1 << 1, parentPeer: inputPeer, ids: threadIds.compactMap { transaction.getPeer(PeerId($0)).flatMap(apiInputPeer(_:)) }))
|
||||
|> map { result -> (Peer, FetchedForumThreads)? in
|
||||
let result = FetchedForumThreads(savedDialogs: result)
|
||||
return (peer, FetchedForumThreads(
|
||||
items: result.items.filter({ item -> Bool in
|
||||
switch item {
|
||||
case let .savedDialog(savedDialog):
|
||||
switch savedDialog {
|
||||
case let .monoForumDialog(_, peer, _, _, _, _, _):
|
||||
return threadIds.contains(peer.peerId.toInt64())
|
||||
case .savedDialog:
|
||||
return false
|
||||
}
|
||||
case .forum:
|
||||
return false
|
||||
}
|
||||
}),
|
||||
totalCount: result.totalCount,
|
||||
orderByDate: result.orderByDate,
|
||||
pts: result.pts,
|
||||
messages: result.messages,
|
||||
users: result.users,
|
||||
chats: result.chats
|
||||
))
|
||||
return (peer, result)
|
||||
}
|
||||
|> `catch` { _ -> Signal<(Peer, FetchedForumThreads)?, NoError> in
|
||||
return .single(nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user