mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-06 17:00:13 +00:00
Update API
This commit is contained in:
parent
0a1be88185
commit
997bcf7edf
@ -410,6 +410,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-440664550] = { return Api.InputMedia.parse_inputMediaPhotoExternal($0) }
|
||||
dict[261416433] = { return Api.InputMedia.parse_inputMediaPoll($0) }
|
||||
dict[-1979852936] = { return Api.InputMedia.parse_inputMediaStory($0) }
|
||||
dict[-1614454818] = { return Api.InputMedia.parse_inputMediaTodo($0) }
|
||||
dict[58495792] = { return Api.InputMedia.parse_inputMediaUploadedDocument($0) }
|
||||
dict[505969924] = { return Api.InputMedia.parse_inputMediaUploadedPhoto($0) }
|
||||
dict[-1052959727] = { return Api.InputMedia.parse_inputMediaVenue($0) }
|
||||
@ -606,6 +607,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1192749220] = { return Api.MessageAction.parse_messageActionStarGift($0) }
|
||||
dict[775611918] = { return Api.MessageAction.parse_messageActionStarGiftUnique($0) }
|
||||
dict[1474192222] = { return Api.MessageAction.parse_messageActionSuggestProfilePhoto($0) }
|
||||
dict[-864265079] = { return Api.MessageAction.parse_messageActionTodoCompletions($0) }
|
||||
dict[228168278] = { return Api.MessageAction.parse_messageActionTopicCreate($0) }
|
||||
dict[-1064024032] = { return Api.MessageAction.parse_messageActionTopicEdit($0) }
|
||||
dict[-1262252875] = { return Api.MessageAction.parse_messageActionWebViewDataSent($0) }
|
||||
@ -648,6 +650,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) }
|
||||
dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) }
|
||||
dict[1758159491] = { return Api.MessageMedia.parse_messageMediaStory($0) }
|
||||
dict[-1974226924] = { return Api.MessageMedia.parse_messageMediaToDo($0) }
|
||||
dict[-1618676578] = { return Api.MessageMedia.parse_messageMediaUnsupported($0) }
|
||||
dict[784356159] = { return Api.MessageMedia.parse_messageMediaVenue($0) }
|
||||
dict[-571405253] = { return Api.MessageMedia.parse_messageMediaWebPage($0) }
|
||||
@ -999,6 +1002,9 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1609668650] = { return Api.Theme.parse_theme($0) }
|
||||
dict[-94849324] = { return Api.ThemeSettings.parse_themeSettings($0) }
|
||||
dict[-7173643] = { return Api.Timezone.parse_timezone($0) }
|
||||
dict[1287725239] = { return Api.TodoCompletion.parse_todoCompletion($0) }
|
||||
dict[-878074577] = { return Api.TodoItem.parse_todoItem($0) }
|
||||
dict[1236871718] = { return Api.TodoList.parse_todoList($0) }
|
||||
dict[-305282981] = { return Api.TopPeer.parse_topPeer($0) }
|
||||
dict[-39945236] = { return Api.TopPeerCategory.parse_topPeerCategoryBotsApp($0) }
|
||||
dict[344356834] = { return Api.TopPeerCategory.parse_topPeerCategoryBotsInline($0) }
|
||||
@ -2203,6 +2209,12 @@ public extension Api {
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.Timezone:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.TodoCompletion:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.TodoItem:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.TodoList:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.TopPeer:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.TopPeerCategory:
|
||||
|
||||
@ -572,6 +572,7 @@ public extension Api {
|
||||
case inputMediaPhotoExternal(flags: Int32, url: String, ttlSeconds: Int32?)
|
||||
case inputMediaPoll(flags: Int32, poll: Api.Poll, correctAnswers: [Buffer]?, solution: String?, solutionEntities: [Api.MessageEntity]?)
|
||||
case inputMediaStory(peer: Api.InputPeer, id: Int32)
|
||||
case inputMediaTodo(todo: Api.TodoList)
|
||||
case inputMediaUploadedDocument(flags: Int32, file: Api.InputFile, thumb: Api.InputFile?, mimeType: String, attributes: [Api.DocumentAttribute], stickers: [Api.InputDocument]?, videoCover: Api.InputPhoto?, videoTimestamp: Int32?, 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)
|
||||
@ -712,6 +713,12 @@ public extension Api {
|
||||
peer.serialize(buffer, true)
|
||||
serializeInt32(id, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .inputMediaTodo(let todo):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1614454818)
|
||||
}
|
||||
todo.serialize(buffer, true)
|
||||
break
|
||||
case .inputMediaUploadedDocument(let flags, let file, let thumb, let mimeType, let attributes, let stickers, let videoCover, let videoTimestamp, let ttlSeconds):
|
||||
if boxed {
|
||||
buffer.appendInt32(58495792)
|
||||
@ -798,6 +805,8 @@ public extension Api {
|
||||
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 peer, let id):
|
||||
return ("inputMediaStory", [("peer", peer as Any), ("id", id as Any)])
|
||||
case .inputMediaTodo(let todo):
|
||||
return ("inputMediaTodo", [("todo", todo as Any)])
|
||||
case .inputMediaUploadedDocument(let flags, let file, let thumb, let mimeType, let attributes, let stickers, let videoCover, let videoTimestamp, 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), ("videoCover", videoCover as Any), ("videoTimestamp", videoTimestamp as Any), ("ttlSeconds", ttlSeconds as Any)])
|
||||
case .inputMediaUploadedPhoto(let flags, let file, let stickers, let ttlSeconds):
|
||||
@ -1098,6 +1107,19 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputMediaTodo(_ reader: BufferReader) -> InputMedia? {
|
||||
var _1: Api.TodoList?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.TodoList
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.InputMedia.inputMediaTodo(todo: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputMediaUploadedDocument(_ reader: BufferReader) -> InputMedia? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
|
||||
@ -383,6 +383,7 @@ public extension Api {
|
||||
case messageActionStarGift(flags: Int32, gift: Api.StarGift, message: Api.TextWithEntities?, convertStars: Int64?, upgradeMsgId: Int32?, upgradeStars: Int64?, fromId: Api.Peer?, peer: Api.Peer?, savedId: Int64?)
|
||||
case messageActionStarGiftUnique(flags: Int32, gift: Api.StarGift, canExportAt: Int32?, transferStars: Int64?, fromId: Api.Peer?, peer: Api.Peer?, savedId: Int64?, resaleStars: Int64?, canTransferAt: Int32?, canResellAt: Int32?)
|
||||
case messageActionSuggestProfilePhoto(photo: Api.Photo)
|
||||
case messageActionTodoCompletions(completed: [Int32], incompleted: [Int32])
|
||||
case messageActionTopicCreate(flags: Int32, title: String, iconColor: Int32, iconEmojiId: Int64?)
|
||||
case messageActionTopicEdit(flags: Int32, title: String?, iconEmojiId: Int64?, closed: Api.Bool?, hidden: Api.Bool?)
|
||||
case messageActionWebViewDataSent(text: String)
|
||||
@ -789,6 +790,21 @@ public extension Api {
|
||||
}
|
||||
photo.serialize(buffer, true)
|
||||
break
|
||||
case .messageActionTodoCompletions(let completed, let incompleted):
|
||||
if boxed {
|
||||
buffer.appendInt32(-864265079)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(completed.count))
|
||||
for item in completed {
|
||||
serializeInt32(item, buffer: buffer, boxed: false)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(incompleted.count))
|
||||
for item in incompleted {
|
||||
serializeInt32(item, buffer: buffer, boxed: false)
|
||||
}
|
||||
break
|
||||
case .messageActionTopicCreate(let flags, let title, let iconColor, let iconEmojiId):
|
||||
if boxed {
|
||||
buffer.appendInt32(228168278)
|
||||
@ -920,6 +936,8 @@ public extension Api {
|
||||
return ("messageActionStarGiftUnique", [("flags", flags as Any), ("gift", gift as Any), ("canExportAt", canExportAt as Any), ("transferStars", transferStars as Any), ("fromId", fromId as Any), ("peer", peer as Any), ("savedId", savedId as Any), ("resaleStars", resaleStars as Any), ("canTransferAt", canTransferAt as Any), ("canResellAt", canResellAt as Any)])
|
||||
case .messageActionSuggestProfilePhoto(let photo):
|
||||
return ("messageActionSuggestProfilePhoto", [("photo", photo as Any)])
|
||||
case .messageActionTodoCompletions(let completed, let incompleted):
|
||||
return ("messageActionTodoCompletions", [("completed", completed as Any), ("incompleted", incompleted as Any)])
|
||||
case .messageActionTopicCreate(let flags, let title, let iconColor, let iconEmojiId):
|
||||
return ("messageActionTopicCreate", [("flags", flags as Any), ("title", title as Any), ("iconColor", iconColor as Any), ("iconEmojiId", iconEmojiId as Any)])
|
||||
case .messageActionTopicEdit(let flags, let title, let iconEmojiId, let closed, let hidden):
|
||||
@ -1715,6 +1733,24 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageActionTodoCompletions(_ reader: BufferReader) -> MessageAction? {
|
||||
var _1: [Int32]?
|
||||
if let _ = reader.readInt32() {
|
||||
_1 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
|
||||
}
|
||||
var _2: [Int32]?
|
||||
if let _ = reader.readInt32() {
|
||||
_2 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.MessageAction.messageActionTodoCompletions(completed: _1!, incompleted: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageActionTopicCreate(_ reader: BufferReader) -> MessageAction? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
|
||||
@ -722,6 +722,7 @@ public extension Api {
|
||||
case messageMediaPhoto(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?)
|
||||
case messageMediaPoll(poll: Api.Poll, results: Api.PollResults)
|
||||
case messageMediaStory(flags: Int32, peer: Api.Peer, id: Int32, story: Api.StoryItem?)
|
||||
case messageMediaToDo(flags: Int32, todo: Api.TodoList, completions: [Api.TodoCompletion]?)
|
||||
case messageMediaUnsupported
|
||||
case messageMediaVenue(geo: Api.GeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String)
|
||||
case messageMediaWebPage(flags: Int32, webpage: Api.WebPage)
|
||||
@ -878,6 +879,18 @@ public extension Api {
|
||||
serializeInt32(id, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {story!.serialize(buffer, true)}
|
||||
break
|
||||
case .messageMediaToDo(let flags, let todo, let completions):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1974226924)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
todo.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 0) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(completions!.count))
|
||||
for item in completions! {
|
||||
item.serialize(buffer, true)
|
||||
}}
|
||||
break
|
||||
case .messageMediaUnsupported:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1618676578)
|
||||
@ -935,6 +948,8 @@ public extension Api {
|
||||
return ("messageMediaPoll", [("poll", poll as Any), ("results", results 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 .messageMediaToDo(let flags, let todo, let completions):
|
||||
return ("messageMediaToDo", [("flags", flags as Any), ("todo", todo as Any), ("completions", completions as Any)])
|
||||
case .messageMediaUnsupported:
|
||||
return ("messageMediaUnsupported", [])
|
||||
case .messageMediaVenue(let geo, let title, let address, let provider, let venueId, let venueType):
|
||||
@ -1262,6 +1277,27 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageMediaToDo(_ reader: BufferReader) -> MessageMedia? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.TodoList?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.TodoList
|
||||
}
|
||||
var _3: [Api.TodoCompletion]?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.TodoCompletion.self)
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.MessageMedia.messageMediaToDo(flags: _1!, todo: _2!, completions: _3)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageMediaUnsupported(_ reader: BufferReader) -> MessageMedia? {
|
||||
return Api.MessageMedia.messageMediaUnsupported
|
||||
}
|
||||
|
||||
@ -762,6 +762,144 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum TodoCompletion: TypeConstructorDescription {
|
||||
case todoCompletion(id: Int32, completedBy: Int64, date: Int32)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .todoCompletion(let id, let completedBy, let date):
|
||||
if boxed {
|
||||
buffer.appendInt32(1287725239)
|
||||
}
|
||||
serializeInt32(id, buffer: buffer, boxed: false)
|
||||
serializeInt64(completedBy, buffer: buffer, boxed: false)
|
||||
serializeInt32(date, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .todoCompletion(let id, let completedBy, let date):
|
||||
return ("todoCompletion", [("id", id as Any), ("completedBy", completedBy as Any), ("date", date as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_todoCompletion(_ reader: BufferReader) -> TodoCompletion? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.TodoCompletion.todoCompletion(id: _1!, completedBy: _2!, date: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum TodoItem: TypeConstructorDescription {
|
||||
case todoItem(id: Int32, title: Api.TextWithEntities)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .todoItem(let id, let title):
|
||||
if boxed {
|
||||
buffer.appendInt32(-878074577)
|
||||
}
|
||||
serializeInt32(id, buffer: buffer, boxed: false)
|
||||
title.serialize(buffer, true)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .todoItem(let id, let title):
|
||||
return ("todoItem", [("id", id as Any), ("title", title as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_todoItem(_ reader: BufferReader) -> TodoItem? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.TextWithEntities?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.TextWithEntities
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.TodoItem.todoItem(id: _1!, title: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum TodoList: TypeConstructorDescription {
|
||||
case todoList(flags: Int32, title: Api.TextWithEntities, list: [Api.TodoItem])
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .todoList(let flags, let title, let list):
|
||||
if boxed {
|
||||
buffer.appendInt32(1236871718)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
title.serialize(buffer, true)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(list.count))
|
||||
for item in list {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .todoList(let flags, let title, let list):
|
||||
return ("todoList", [("flags", flags as Any), ("title", title as Any), ("list", list as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_todoList(_ reader: BufferReader) -> TodoList? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.TextWithEntities?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.TextWithEntities
|
||||
}
|
||||
var _3: [Api.TodoItem]?
|
||||
if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.TodoItem.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.TodoList.todoList(flags: _1!, title: _2!, list: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum TopPeer: TypeConstructorDescription {
|
||||
case topPeer(peer: Api.Peer, rating: Double)
|
||||
|
||||
@ -5067,6 +5067,27 @@ public extension Api.functions.messages {
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func appendTodoList(peer: Api.InputPeer, msgId: Int32, list: [Api.TodoItem]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(564531287)
|
||||
peer.serialize(buffer, true)
|
||||
serializeInt32(msgId, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(list.count))
|
||||
for item in list {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
return (FunctionDescription(name: "messages.appendTodoList", parameters: [("peer", String(describing: peer)), ("msgId", String(describing: msgId)), ("list", String(describing: list))]), 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.messages {
|
||||
static func checkChatInvite(hash: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.ChatInvite>) {
|
||||
let buffer = Buffer()
|
||||
@ -8880,6 +8901,32 @@ public extension Api.functions.messages {
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func toggleTodoCompleted(peer: Api.InputPeer, msgId: Int32, completed: [Int32], incompleted: [Int32]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-740282076)
|
||||
peer.serialize(buffer, true)
|
||||
serializeInt32(msgId, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(completed.count))
|
||||
for item in completed {
|
||||
serializeInt32(item, buffer: buffer, boxed: false)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(incompleted.count))
|
||||
for item in incompleted {
|
||||
serializeInt32(item, buffer: buffer, boxed: false)
|
||||
}
|
||||
return (FunctionDescription(name: "messages.toggleTodoCompleted", parameters: [("peer", String(describing: peer)), ("msgId", String(describing: msgId)), ("completed", String(describing: completed)), ("incompleted", String(describing: incompleted))]), 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.messages {
|
||||
static func transcribeAudio(peer: Api.InputPeer, msgId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.TranscribedAudio>) {
|
||||
let buffer = Buffer()
|
||||
|
||||
@ -233,6 +233,9 @@ private var declaredEncodables: Void = {
|
||||
declareEncodable(TelegramMediaPaidContent.self, f: { TelegramMediaPaidContent(decoder: $0) })
|
||||
declareEncodable(ReportDeliveryMessageAttribute.self, f: { ReportDeliveryMessageAttribute(decoder: $0) })
|
||||
declareEncodable(PaidStarsMessageAttribute.self, f: { PaidStarsMessageAttribute(decoder: $0) })
|
||||
declareEncodable(TelegramMediaTodo.self, f: { TelegramMediaTodo(decoder: $0) })
|
||||
declareEncodable(TelegramMediaTodo.Item.self, f: { TelegramMediaTodo.Item(decoder: $0) })
|
||||
declareEncodable(TelegramMediaTodo.Completion.self, f: { TelegramMediaTodo.Completion(decoder: $0) })
|
||||
return
|
||||
}()
|
||||
|
||||
|
||||
@ -229,7 +229,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
||||
}
|
||||
|
||||
switch action {
|
||||
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionGiftStars, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe, .messageActionStarGift, .messageActionStarGiftUnique, .messageActionPaidMessagesRefunded, .messageActionPaidMessagesPrice:
|
||||
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionGiftStars, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe, .messageActionStarGift, .messageActionStarGiftUnique, .messageActionPaidMessagesRefunded, .messageActionPaidMessagesPrice, .messageActionTodoCompletions:
|
||||
break
|
||||
case let .messageActionChannelMigrateFrom(_, chatId):
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)))
|
||||
@ -428,6 +428,30 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI
|
||||
|
||||
return (TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.CloudPoll, id: id), publicity: publicity, kind: kind, text: questionText, textEntities: questionEntities, options: answers.map(TelegramMediaPollOption.init(apiOption:)), correctAnswers: nil, results: TelegramMediaPollResults(apiResults: results), isClosed: (flags & (1 << 0)) != 0, deadlineTimeout: closePeriod), nil, nil, nil, nil, nil)
|
||||
}
|
||||
case let .messageMediaToDo(_, todo, completions):
|
||||
switch todo {
|
||||
case let .todoList(apiFlags, title, list):
|
||||
var flags: TelegramMediaTodo.Flags = []
|
||||
if (apiFlags & (1 << 0)) != 0 {
|
||||
flags.insert(.othersCanAppend)
|
||||
}
|
||||
if (apiFlags & (1 << 1)) != 0 {
|
||||
flags.insert(.othersCanComplete)
|
||||
}
|
||||
|
||||
let todoText: String
|
||||
let todoEntities: [MessageTextEntity]
|
||||
switch title {
|
||||
case let .textWithEntities(text, entities):
|
||||
todoText = text
|
||||
todoEntities = messageTextEntitiesFromApiEntities(entities)
|
||||
}
|
||||
var todoCompletions: [TelegramMediaTodo.Completion] = []
|
||||
if let completions {
|
||||
todoCompletions = completions.map(TelegramMediaTodo.Completion.init(apiCompletion:))
|
||||
}
|
||||
return (TelegramMediaTodo(flags: flags, text: todoText, textEntities: todoEntities, items: list.map(TelegramMediaTodo.Item.init(apiItem:)), completions: todoCompletions), nil, nil, nil, nil, nil)
|
||||
}
|
||||
case let .messageMediaDice(value, emoticon):
|
||||
return (TelegramMediaDice(emoji: emoticon, value: value), nil, nil, nil, nil, nil)
|
||||
case let .messageMediaStory(flags, peerId, id, _):
|
||||
|
||||
@ -224,6 +224,8 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
|
||||
flags: mappedFlags,
|
||||
otherParticipants: otherParticipants.flatMap({ return $0.map(\.peerId) }) ?? []
|
||||
)))
|
||||
case let .messageActionTodoCompletions(completed, incompleted):
|
||||
return TelegramMediaAction(action: .todoCompletions(completed: completed, incompleted: incompleted))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
|
||||
|
||||
extension TelegramMediaTodo.Item {
|
||||
init(apiItem: Api.TodoItem) {
|
||||
switch apiItem {
|
||||
case let .todoItem(id, title):
|
||||
let itemText: String
|
||||
let itemEntities: [MessageTextEntity]
|
||||
switch title {
|
||||
case let .textWithEntities(text, entities):
|
||||
itemText = text
|
||||
itemEntities = messageTextEntitiesFromApiEntities(entities)
|
||||
}
|
||||
self.init(text: itemText, entities: itemEntities, id: id)
|
||||
}
|
||||
}
|
||||
|
||||
var apiItem: Api.TodoItem {
|
||||
return .todoItem(id: self.id, title: .textWithEntities(text: self.text, entities: apiEntitiesFromMessageTextEntities(self.entities, associatedPeers: SimpleDictionary())))
|
||||
}
|
||||
}
|
||||
|
||||
extension TelegramMediaTodo.Completion {
|
||||
init(apiCompletion: Api.TodoCompletion) {
|
||||
switch apiCompletion {
|
||||
case let .todoCompletion(id, completedBy, date):
|
||||
self.init(id: id, date: date, completedBy: EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(completedBy)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -319,6 +319,7 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post
|
||||
if poll.deadlineTimeout != nil {
|
||||
pollFlags |= 1 << 4
|
||||
}
|
||||
|
||||
var mappedSolution: String?
|
||||
var mappedSolutionEntities: [Api.MessageEntity]?
|
||||
if let solution = poll.results.solution {
|
||||
@ -328,10 +329,20 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post
|
||||
}
|
||||
let inputPoll = Api.InputMedia.inputMediaPoll(flags: pollMediaFlags, poll: Api.Poll.poll(id: 0, flags: pollFlags, question: .textWithEntities(text: poll.text, entities: apiEntitiesFromMessageTextEntities(poll.textEntities, associatedPeers: SimpleDictionary())), answers: poll.options.map({ $0.apiOption }), closePeriod: poll.deadlineTimeout, closeDate: nil), correctAnswers: correctAnswers, solution: mappedSolution, solutionEntities: mappedSolutionEntities)
|
||||
return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputPoll, text), reuploadInfo: nil, cacheReferenceKey: nil)))
|
||||
} else if let media = media as? TelegramMediaDice {
|
||||
let inputDice = Api.InputMedia.inputMediaDice(emoticon: media.emoji)
|
||||
} else if let todo = media as? TelegramMediaTodo {
|
||||
var flags: Int32 = 0
|
||||
if todo.flags.contains(.othersCanAppend) {
|
||||
flags |= 1 << 0
|
||||
}
|
||||
if todo.flags.contains(.othersCanComplete) {
|
||||
flags |= 1 << 1
|
||||
}
|
||||
let inputTodo = Api.InputMedia.inputMediaTodo(todo: .todoList(flags: flags, title: .textWithEntities(text: todo.text, entities: apiEntitiesFromMessageTextEntities(todo.textEntities, associatedPeers: SimpleDictionary())), list: todo.items.map { $0.apiItem }))
|
||||
return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputTodo, text), reuploadInfo: nil, cacheReferenceKey: nil)))
|
||||
} else if let dice = media as? TelegramMediaDice {
|
||||
let inputDice = Api.InputMedia.inputMediaDice(emoticon: dice.emoji)
|
||||
return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputDice, text), reuploadInfo: nil, cacheReferenceKey: nil)))
|
||||
} else if let media = media as? TelegramMediaWebpage, case let .Loaded(content) = media.content {
|
||||
} else if let webPage = media as? TelegramMediaWebpage, case let .Loaded(content) = webPage.content {
|
||||
var flags: Int32 = 0
|
||||
flags |= 1 << 2
|
||||
if let attribute = attributes.first(where: { $0 is WebpagePreviewMessageAttribute }) as? WebpagePreviewMessageAttribute {
|
||||
|
||||
@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
|
||||
|
||||
public class Serialization: NSObject, MTSerialization {
|
||||
public func currentLayer() -> UInt {
|
||||
return 204
|
||||
return 205
|
||||
}
|
||||
|
||||
public func parseMessage(_ data: Data!) -> Any! {
|
||||
|
||||
@ -160,6 +160,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case paidMessagesRefunded(count: Int32, stars: Int64)
|
||||
case paidMessagesPriceEdited(stars: Int64, broadcastMessagesAllowed: Bool)
|
||||
case conferenceCall(ConferenceCall)
|
||||
case todoCompletions(completed: [Int32], incompleted: [Int32])
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0)
|
||||
@ -295,6 +296,11 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
flags: ConferenceCall.Flags(rawValue: decoder.decodeInt32ForKey("flags", orElse: 0)),
|
||||
otherParticipants: decoder.decodeInt64ArrayForKey("part").map(PeerId.init)
|
||||
))
|
||||
case 49:
|
||||
self = .todoCompletions(
|
||||
completed: decoder.decodeInt32ArrayForKey("completed"),
|
||||
incompleted: decoder.decodeInt32ArrayForKey("incompleted")
|
||||
)
|
||||
default:
|
||||
self = .unknown
|
||||
}
|
||||
@ -698,6 +704,10 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
}
|
||||
encoder.encodeInt32(conferenceCall.flags.rawValue, forKey: "flags")
|
||||
encoder.encodeInt64Array(conferenceCall.otherParticipants.map({ $0.toInt64() }), forKey: "part")
|
||||
case let .todoCompletions(completed, incompleted):
|
||||
encoder.encodeInt32(49, forKey: "_rawValue")
|
||||
encoder.encodeInt32Array(completed, forKey: "completed")
|
||||
encoder.encodeInt32Array(incompleted, forKey: "incompleted")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,134 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
|
||||
public final class TelegramMediaTodo: Media, Equatable {
|
||||
public struct Flags: OptionSet {
|
||||
public var rawValue: Int32
|
||||
|
||||
public init() {
|
||||
self.rawValue = 0
|
||||
}
|
||||
|
||||
public init(rawValue: Int32) {
|
||||
self.rawValue = rawValue
|
||||
}
|
||||
|
||||
public static let othersCanAppend = Flags(rawValue: 1 << 0)
|
||||
public static let othersCanComplete = Flags(rawValue: 1 << 1)
|
||||
}
|
||||
|
||||
public struct Item: Equatable, PostboxCoding {
|
||||
public let text: String
|
||||
public let entities: [MessageTextEntity]
|
||||
public let id: Int32
|
||||
|
||||
public init(text: String, entities: [MessageTextEntity], id: Int32) {
|
||||
self.text = text
|
||||
self.entities = entities
|
||||
self.id = id
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.text = decoder.decodeStringForKey("t", orElse: "")
|
||||
self.entities = decoder.decodeObjectArrayWithDecoderForKey("et")
|
||||
self.id = decoder.decodeInt32ForKey("i", orElse: 0)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.text, forKey: "t")
|
||||
encoder.encodeObjectArray(self.entities, forKey: "et")
|
||||
encoder.encodeInt32(self.id, forKey: "i")
|
||||
}
|
||||
}
|
||||
|
||||
public struct Completion: Equatable, PostboxCoding {
|
||||
public let id: Int32
|
||||
public let date: Int32
|
||||
public let completedBy: EnginePeer.Id
|
||||
|
||||
public init(id: Int32, date: Int32, completedBy: EnginePeer.Id) {
|
||||
self.id = id
|
||||
self.date = date
|
||||
self.completedBy = completedBy
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.id = decoder.decodeInt32ForKey("i", orElse: 0)
|
||||
self.date = decoder.decodeInt32ForKey("d", orElse: 0)
|
||||
self.completedBy = PeerId(decoder.decodeInt64ForKey("p", orElse: 0))
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt32(self.id, forKey: "i")
|
||||
encoder.encodeInt32(self.date, forKey: "d")
|
||||
encoder.encodeInt64(self.completedBy.toInt64(), forKey: "p")
|
||||
}
|
||||
}
|
||||
|
||||
public var id: MediaId? {
|
||||
return nil
|
||||
}
|
||||
public var peerIds: [PeerId] {
|
||||
return []
|
||||
}
|
||||
|
||||
public let flags: Flags
|
||||
public let text: String
|
||||
public let textEntities: [MessageTextEntity]
|
||||
public let items: [Item]
|
||||
public let completions: [Completion]
|
||||
|
||||
public init(flags: Flags, text: String, textEntities: [MessageTextEntity], items: [Item], completions: [Completion] = []) {
|
||||
self.flags = flags
|
||||
self.text = text
|
||||
self.textEntities = textEntities
|
||||
self.items = items
|
||||
self.completions = completions
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.flags = Flags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0))
|
||||
self.text = decoder.decodeStringForKey("t", orElse: "")
|
||||
self.textEntities = decoder.decodeObjectArrayWithDecoderForKey("te")
|
||||
self.items = decoder.decodeObjectArrayWithDecoderForKey("is")
|
||||
self.completions = decoder.decodeObjectArrayWithDecoderForKey("cs")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt32(self.flags.rawValue, forKey: "f")
|
||||
encoder.encodeString(self.text, forKey: "t")
|
||||
encoder.encodeObjectArray(self.textEntities, forKey: "te")
|
||||
encoder.encodeObjectArray(self.items, forKey: "is")
|
||||
encoder.encodeObjectArray(self.completions, forKey: "cs")
|
||||
}
|
||||
|
||||
public func isEqual(to other: Media) -> Bool {
|
||||
guard let other = other as? TelegramMediaTodo else {
|
||||
return false
|
||||
}
|
||||
return self == other
|
||||
}
|
||||
|
||||
public func isSemanticallyEqual(to other: Media) -> Bool {
|
||||
return self.isEqual(to: other)
|
||||
}
|
||||
|
||||
public static func ==(lhs: TelegramMediaTodo, rhs: TelegramMediaTodo) -> Bool {
|
||||
if lhs.flags != rhs.flags {
|
||||
return false
|
||||
}
|
||||
if lhs.text != rhs.text {
|
||||
return false
|
||||
}
|
||||
if lhs.textEntities != rhs.textEntities {
|
||||
return false
|
||||
}
|
||||
if lhs.items != rhs.items {
|
||||
return false
|
||||
}
|
||||
if lhs.completions != rhs.completions {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -20,6 +20,7 @@ public enum EngineMedia: Equatable {
|
||||
case giveaway(TelegramMediaGiveaway)
|
||||
case giveawayResults(TelegramMediaGiveawayResults)
|
||||
case paidContent(TelegramMediaPaidContent)
|
||||
case todo(TelegramMediaTodo)
|
||||
}
|
||||
|
||||
public extension EngineMedia {
|
||||
@ -59,6 +60,8 @@ public extension EngineMedia {
|
||||
return giveawayResults.id
|
||||
case let .paidContent(paidContent):
|
||||
return paidContent.id
|
||||
case .todo:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -100,6 +103,8 @@ public extension EngineMedia {
|
||||
self = .giveawayResults(giveawayResults)
|
||||
case let paidContent as TelegramMediaPaidContent:
|
||||
self = .paidContent(paidContent)
|
||||
case let todo as TelegramMediaTodo:
|
||||
self = .todo(todo)
|
||||
default:
|
||||
preconditionFailure()
|
||||
}
|
||||
@ -141,6 +146,8 @@ public extension EngineMedia {
|
||||
return giveawayResults
|
||||
case let .paidContent(paidContent):
|
||||
return paidContent
|
||||
case let .todo(todo):
|
||||
return todo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,6 +204,14 @@ public extension TelegramEngine {
|
||||
return PollResultsContext(account: self.account, messageId: messageId, poll: poll)
|
||||
}
|
||||
|
||||
public func requestUpdateTodoMessageItems(messageId: MessageId, completedIds: [Int32], incompletedIds: [Int32]) -> Signal<Never, RequestUpdateTodoMessageError> {
|
||||
return _internal_requestUpdateTodoMessageItems(account: self.account, messageId: messageId, completedIds: completedIds, incompletedIds: incompletedIds)
|
||||
}
|
||||
|
||||
public func appendTodoMessageItems(messageId: MessageId, items: [TelegramMediaTodo.Item]) -> Signal<Never, AppendTodoMessageError> {
|
||||
return _internal_appendTodoMessageItems(account: self.account, messageId: messageId, items: items)
|
||||
}
|
||||
|
||||
public func earliestUnseenPersonalMentionMessage(peerId: PeerId, threadId: Int64?) -> Signal<EarliestUnseenPersonalMentionMessageResult, NoError> {
|
||||
let account = self.account
|
||||
return _internal_earliestUnseenPersonalMentionMessage(account: self.account, peerId: peerId, threadId: threadId)
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
import Foundation
|
||||
import TelegramApi
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import MtProtoKit
|
||||
|
||||
|
||||
public enum RequestUpdateTodoMessageError {
|
||||
case generic
|
||||
}
|
||||
|
||||
func _internal_requestUpdateTodoMessageItems(account: Account, messageId: MessageId, completedIds: [Int32], incompletedIds: [Int32]) -> Signal<Never, RequestUpdateTodoMessageError> {
|
||||
return account.postbox.loadedPeerWithId(messageId.peerId)
|
||||
|> take(1)
|
||||
|> castError(RequestUpdateTodoMessageError.self)
|
||||
|> mapToSignal { peer in
|
||||
if let inputPeer = apiInputPeer(peer) {
|
||||
return account.network.request(Api.functions.messages.toggleTodoCompleted(peer: inputPeer, msgId: messageId.id, completed: completedIds, incompleted: incompletedIds))
|
||||
|> mapError { _ -> RequestUpdateTodoMessageError in
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { result -> Signal<TelegramMediaTodo?, RequestUpdateTodoMessageError> in
|
||||
return account.postbox.transaction { transaction -> TelegramMediaTodo? in
|
||||
switch result {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
let _ = updates
|
||||
default:
|
||||
break
|
||||
}
|
||||
account.stateManager.addUpdates(result)
|
||||
return nil
|
||||
}
|
||||
|> castError(RequestUpdateTodoMessageError.self)
|
||||
}
|
||||
} else {
|
||||
return .single(nil)
|
||||
}
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
|
||||
public enum AppendTodoMessageError {
|
||||
case generic
|
||||
}
|
||||
|
||||
func _internal_appendTodoMessageItems(account: Account, messageId: MessageId, items: [TelegramMediaTodo.Item]) -> Signal<Never, AppendTodoMessageError> {
|
||||
return account.postbox.loadedPeerWithId(messageId.peerId)
|
||||
|> take(1)
|
||||
|> castError(AppendTodoMessageError.self)
|
||||
|> mapToSignal { peer -> Signal<TelegramMediaTodo?, AppendTodoMessageError> in
|
||||
guard let inputPeer = apiInputPeer(peer) else {
|
||||
return .single(nil)
|
||||
}
|
||||
return account.network.request(Api.functions.messages.appendTodoList(peer: inputPeer, msgId: messageId.id, list: items.map { $0.apiItem }))
|
||||
|> mapError { _ -> AppendTodoMessageError in
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { result -> Signal<TelegramMediaTodo?, AppendTodoMessageError> in
|
||||
return account.postbox.transaction { transaction -> TelegramMediaTodo? in
|
||||
switch result {
|
||||
case let .updates(updates, _, _, _, _):
|
||||
let _ = updates
|
||||
default:
|
||||
break
|
||||
}
|
||||
account.stateManager.addUpdates(result)
|
||||
return nil
|
||||
}
|
||||
|> castError(AppendTodoMessageError.self)
|
||||
}
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user