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
997bcf7edf
commit
8709581d6a
@ -607,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[-940721021] = { return Api.MessageAction.parse_messageActionTodoAppendTasks($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) }
|
||||
@ -938,7 +939,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-651419003] = { return Api.SendMessageAction.parse_speakingInGroupCallAction($0) }
|
||||
dict[-1239335713] = { return Api.ShippingOption.parse_shippingOption($0) }
|
||||
dict[-425595208] = { return Api.SmsJob.parse_smsJob($0) }
|
||||
dict[1301522832] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
||||
dict[2109703795] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
||||
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
|
||||
dict[-963180333] = { return Api.SponsoredPeer.parse_sponsoredPeer($0) }
|
||||
dict[-970274264] = { return Api.StarGift.parse_starGift($0) }
|
||||
@ -1397,7 +1398,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1404185519] = { return Api.messages.SearchResultsPositions.parse_searchResultsPositions($0) }
|
||||
dict[-1802240206] = { return Api.messages.SentEncryptedMessage.parse_sentEncryptedFile($0) }
|
||||
dict[1443858741] = { return Api.messages.SentEncryptedMessage.parse_sentEncryptedMessage($0) }
|
||||
dict[-907141753] = { return Api.messages.SponsoredMessages.parse_sponsoredMessages($0) }
|
||||
dict[-2464403] = { return Api.messages.SponsoredMessages.parse_sponsoredMessages($0) }
|
||||
dict[406407439] = { return Api.messages.SponsoredMessages.parse_sponsoredMessagesEmpty($0) }
|
||||
dict[1846886166] = { return Api.messages.StickerSet.parse_stickerSet($0) }
|
||||
dict[-738646805] = { return Api.messages.StickerSet.parse_stickerSetNotModified($0) }
|
||||
|
||||
@ -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 messageActionTodoAppendTasks(list: [Api.TodoItem])
|
||||
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?)
|
||||
@ -790,6 +791,16 @@ public extension Api {
|
||||
}
|
||||
photo.serialize(buffer, true)
|
||||
break
|
||||
case .messageActionTodoAppendTasks(let list):
|
||||
if boxed {
|
||||
buffer.appendInt32(-940721021)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(list.count))
|
||||
for item in list {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .messageActionTodoCompletions(let completed, let incompleted):
|
||||
if boxed {
|
||||
buffer.appendInt32(-864265079)
|
||||
@ -936,6 +947,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 .messageActionTodoAppendTasks(let list):
|
||||
return ("messageActionTodoAppendTasks", [("list", list 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):
|
||||
@ -1733,6 +1746,19 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageActionTodoAppendTasks(_ reader: BufferReader) -> MessageAction? {
|
||||
var _1: [Api.TodoItem]?
|
||||
if let _ = reader.readInt32() {
|
||||
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.TodoItem.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.MessageAction.messageActionTodoAppendTasks(list: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageActionTodoCompletions(_ reader: BufferReader) -> MessageAction? {
|
||||
var _1: [Int32]?
|
||||
if let _ = reader.readInt32() {
|
||||
|
||||
@ -442,13 +442,13 @@ public extension Api {
|
||||
}
|
||||
public extension Api {
|
||||
indirect enum SponsoredMessage: TypeConstructorDescription {
|
||||
case sponsoredMessage(flags: Int32, randomId: Buffer, url: String, title: String, message: String, entities: [Api.MessageEntity]?, photo: Api.Photo?, media: Api.MessageMedia?, color: Api.PeerColor?, buttonText: String, sponsorInfo: String?, additionalInfo: String?)
|
||||
case sponsoredMessage(flags: Int32, randomId: Buffer, url: String, title: String, message: String, entities: [Api.MessageEntity]?, photo: Api.Photo?, media: Api.MessageMedia?, color: Api.PeerColor?, buttonText: String, sponsorInfo: String?, additionalInfo: String?, minDisplayDuration: Int32?, maxDisplayDuration: Int32?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .sponsoredMessage(let flags, let randomId, let url, let title, let message, let entities, let photo, let media, let color, let buttonText, let sponsorInfo, let additionalInfo):
|
||||
case .sponsoredMessage(let flags, let randomId, let url, let title, let message, let entities, let photo, let media, let color, let buttonText, let sponsorInfo, let additionalInfo, let minDisplayDuration, let maxDisplayDuration):
|
||||
if boxed {
|
||||
buffer.appendInt32(1301522832)
|
||||
buffer.appendInt32(2109703795)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeBytes(randomId, buffer: buffer, boxed: false)
|
||||
@ -466,14 +466,16 @@ public extension Api {
|
||||
serializeString(buttonText, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 7) != 0 {serializeString(sponsorInfo!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 8) != 0 {serializeString(additionalInfo!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 15) != 0 {serializeInt32(minDisplayDuration!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 15) != 0 {serializeInt32(maxDisplayDuration!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .sponsoredMessage(let flags, let randomId, let url, let title, let message, let entities, let photo, let media, let color, let buttonText, let sponsorInfo, let additionalInfo):
|
||||
return ("sponsoredMessage", [("flags", flags as Any), ("randomId", randomId as Any), ("url", url as Any), ("title", title as Any), ("message", message as Any), ("entities", entities as Any), ("photo", photo as Any), ("media", media as Any), ("color", color as Any), ("buttonText", buttonText as Any), ("sponsorInfo", sponsorInfo as Any), ("additionalInfo", additionalInfo as Any)])
|
||||
case .sponsoredMessage(let flags, let randomId, let url, let title, let message, let entities, let photo, let media, let color, let buttonText, let sponsorInfo, let additionalInfo, let minDisplayDuration, let maxDisplayDuration):
|
||||
return ("sponsoredMessage", [("flags", flags as Any), ("randomId", randomId as Any), ("url", url as Any), ("title", title as Any), ("message", message as Any), ("entities", entities as Any), ("photo", photo as Any), ("media", media as Any), ("color", color as Any), ("buttonText", buttonText as Any), ("sponsorInfo", sponsorInfo as Any), ("additionalInfo", additionalInfo as Any), ("minDisplayDuration", minDisplayDuration as Any), ("maxDisplayDuration", maxDisplayDuration as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,6 +512,10 @@ public extension Api {
|
||||
if Int(_1!) & Int(1 << 7) != 0 {_11 = parseString(reader) }
|
||||
var _12: String?
|
||||
if Int(_1!) & Int(1 << 8) != 0 {_12 = parseString(reader) }
|
||||
var _13: Int32?
|
||||
if Int(_1!) & Int(1 << 15) != 0 {_13 = reader.readInt32() }
|
||||
var _14: Int32?
|
||||
if Int(_1!) & Int(1 << 15) != 0 {_14 = reader.readInt32() }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
@ -522,8 +528,10 @@ public extension Api {
|
||||
let _c10 = _10 != nil
|
||||
let _c11 = (Int(_1!) & Int(1 << 7) == 0) || _11 != nil
|
||||
let _c12 = (Int(_1!) & Int(1 << 8) == 0) || _12 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 {
|
||||
return Api.SponsoredMessage.sponsoredMessage(flags: _1!, randomId: _2!, url: _3!, title: _4!, message: _5!, entities: _6, photo: _7, media: _8, color: _9, buttonText: _10!, sponsorInfo: _11, additionalInfo: _12)
|
||||
let _c13 = (Int(_1!) & Int(1 << 15) == 0) || _13 != nil
|
||||
let _c14 = (Int(_1!) & Int(1 << 15) == 0) || _14 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 {
|
||||
return Api.SponsoredMessage.sponsoredMessage(flags: _1!, randomId: _2!, url: _3!, title: _4!, message: _5!, entities: _6, photo: _7, media: _8, color: _9, buttonText: _10!, sponsorInfo: _11, additionalInfo: _12, minDisplayDuration: _13, maxDisplayDuration: _14)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
||||
@ -304,17 +304,19 @@ public extension Api.messages {
|
||||
}
|
||||
public extension Api.messages {
|
||||
enum SponsoredMessages: TypeConstructorDescription {
|
||||
case sponsoredMessages(flags: Int32, postsBetween: Int32?, messages: [Api.SponsoredMessage], chats: [Api.Chat], users: [Api.User])
|
||||
case sponsoredMessages(flags: Int32, postsBetween: Int32?, startDelay: Int32?, betweenDelay: Int32?, messages: [Api.SponsoredMessage], chats: [Api.Chat], users: [Api.User])
|
||||
case sponsoredMessagesEmpty
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .sponsoredMessages(let flags, let postsBetween, let messages, let chats, let users):
|
||||
case .sponsoredMessages(let flags, let postsBetween, let startDelay, let betweenDelay, let messages, let chats, let users):
|
||||
if boxed {
|
||||
buffer.appendInt32(-907141753)
|
||||
buffer.appendInt32(-2464403)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(postsBetween!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(startDelay!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(betweenDelay!, buffer: buffer, boxed: false)}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(messages.count))
|
||||
for item in messages {
|
||||
@ -342,8 +344,8 @@ public extension Api.messages {
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .sponsoredMessages(let flags, let postsBetween, let messages, let chats, let users):
|
||||
return ("sponsoredMessages", [("flags", flags as Any), ("postsBetween", postsBetween as Any), ("messages", messages as Any), ("chats", chats as Any), ("users", users as Any)])
|
||||
case .sponsoredMessages(let flags, let postsBetween, let startDelay, let betweenDelay, let messages, let chats, let users):
|
||||
return ("sponsoredMessages", [("flags", flags as Any), ("postsBetween", postsBetween as Any), ("startDelay", startDelay as Any), ("betweenDelay", betweenDelay as Any), ("messages", messages as Any), ("chats", chats as Any), ("users", users as Any)])
|
||||
case .sponsoredMessagesEmpty:
|
||||
return ("sponsoredMessagesEmpty", [])
|
||||
}
|
||||
@ -354,25 +356,31 @@ public extension Api.messages {
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() }
|
||||
var _3: [Api.SponsoredMessage]?
|
||||
var _3: Int32?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() }
|
||||
var _4: Int32?
|
||||
if Int(_1!) & Int(1 << 2) != 0 {_4 = reader.readInt32() }
|
||||
var _5: [Api.SponsoredMessage]?
|
||||
if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SponsoredMessage.self)
|
||||
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SponsoredMessage.self)
|
||||
}
|
||||
var _4: [Api.Chat]?
|
||||
var _6: [Api.Chat]?
|
||||
if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
|
||||
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
|
||||
}
|
||||
var _5: [Api.User]?
|
||||
var _7: [Api.User]?
|
||||
if let _ = reader.readInt32() {
|
||||
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
|
||||
_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 = _3 != nil
|
||||
let _c4 = _4 != 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
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
||||
return Api.messages.SponsoredMessages.sponsoredMessages(flags: _1!, postsBetween: _2, messages: _3!, chats: _4!, users: _5!)
|
||||
let _c6 = _6 != nil
|
||||
let _c7 = _7 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
|
||||
return Api.messages.SponsoredMessages.sponsoredMessages(flags: _1!, postsBetween: _2, startDelay: _3, betweenDelay: _4, messages: _5!, chats: _6!, users: _7!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
||||
@ -21,22 +21,6 @@ public extension Api.functions.account {
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.account {
|
||||
static func addNoPaidMessagesException(flags: Int32, userId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(1869122215)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
userId.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "account.addNoPaidMessagesException", parameters: [("flags", String(describing: flags)), ("userId", String(describing: userId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.account {
|
||||
static func cancelPasswordEmail() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
@ -666,11 +650,13 @@ public extension Api.functions.account {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.account {
|
||||
static func getPaidMessagesRevenue(userId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.account.PaidMessagesRevenue>) {
|
||||
static func getPaidMessagesRevenue(flags: Int32, parentPeer: Api.InputPeer?, userId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.account.PaidMessagesRevenue>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-249139400)
|
||||
buffer.appendInt32(431639143)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {parentPeer!.serialize(buffer, true)}
|
||||
userId.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "account.getPaidMessagesRevenue", parameters: [("userId", String(describing: userId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.account.PaidMessagesRevenue? in
|
||||
return (FunctionDescription(name: "account.getPaidMessagesRevenue", parameters: [("flags", String(describing: flags)), ("parentPeer", String(describing: parentPeer)), ("userId", String(describing: userId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.account.PaidMessagesRevenue? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.account.PaidMessagesRevenue?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -1437,6 +1423,23 @@ public extension Api.functions.account {
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.account {
|
||||
static func toggleNoPaidMessagesException(flags: Int32, parentPeer: Api.InputPeer?, userId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-30483850)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 1) != 0 {parentPeer!.serialize(buffer, true)}
|
||||
userId.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "account.toggleNoPaidMessagesException", parameters: [("flags", String(describing: flags)), ("parentPeer", String(describing: parentPeer)), ("userId", String(describing: userId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Bool?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Bool
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.account {
|
||||
static func toggleSponsoredMessages(enabled: Api.Bool) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
@ -7086,11 +7089,13 @@ public extension Api.functions.messages {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func getSponsoredMessages(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.SponsoredMessages>) {
|
||||
static func getSponsoredMessages(flags: Int32, peer: Api.InputPeer, msgId: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.SponsoredMessages>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-1680673735)
|
||||
buffer.appendInt32(1030547536)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
peer.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "messages.getSponsoredMessages", parameters: [("peer", String(describing: peer))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.SponsoredMessages? in
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(msgId!, buffer: buffer, boxed: false)}
|
||||
return (FunctionDescription(name: "messages.getSponsoredMessages", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("msgId", String(describing: msgId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.SponsoredMessages? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.messages.SponsoredMessages?
|
||||
if let signature = reader.readInt32() {
|
||||
|
||||
@ -15,8 +15,10 @@ public final class AdMessageAttribute: MessageAttribute {
|
||||
public let additionalInfo: String?
|
||||
public let canReport: Bool
|
||||
public let hasContentMedia: Bool
|
||||
public let minDisplayDuration: Int32?
|
||||
public let maxDisplayDuration: Int32?
|
||||
|
||||
public init(opaqueId: Data, messageType: MessageType, url: String, buttonText: String, sponsorInfo: String?, additionalInfo: String?, canReport: Bool, hasContentMedia: Bool) {
|
||||
public init(opaqueId: Data, messageType: MessageType, url: String, buttonText: String, sponsorInfo: String?, additionalInfo: String?, canReport: Bool, hasContentMedia: Bool, minDisplayDuration: Int32?, maxDisplayDuration: Int32?) {
|
||||
self.opaqueId = opaqueId
|
||||
self.messageType = messageType
|
||||
self.url = url
|
||||
@ -25,6 +27,8 @@ public final class AdMessageAttribute: MessageAttribute {
|
||||
self.additionalInfo = additionalInfo
|
||||
self.canReport = canReport
|
||||
self.hasContentMedia = hasContentMedia
|
||||
self.minDisplayDuration = minDisplayDuration
|
||||
self.maxDisplayDuration = maxDisplayDuration
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
|
||||
@ -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, .messageActionTodoCompletions:
|
||||
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, .messageActionTodoAppendTasks:
|
||||
break
|
||||
case let .messageActionChannelMigrateFrom(_, chatId):
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)))
|
||||
|
||||
@ -226,6 +226,8 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
|
||||
)))
|
||||
case let .messageActionTodoCompletions(completed, incompleted):
|
||||
return TelegramMediaAction(action: .todoCompletions(completed: completed, incompleted: incompleted))
|
||||
case let .messageActionTodoAppendTasks(list):
|
||||
return TelegramMediaAction(action: .todoAppendTasks(list.map { TelegramMediaTodo.Item(apiItem: $0) }))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -438,7 +438,7 @@ public struct NetworkInitializationArguments {
|
||||
public let externalRecaptchaRequestVerification: (String, String) -> Signal<String?, NoError>
|
||||
public let autolockDeadine: Signal<Int32?, NoError>
|
||||
public let encryptionProvider: EncryptionProvider
|
||||
public let deviceModelName:String?
|
||||
public let deviceModelName: String?
|
||||
public let useBetaFeatures: Bool
|
||||
public let isICloudEnabled: Bool
|
||||
|
||||
|
||||
@ -68,7 +68,18 @@ private func requestEditMessageInternal(accountPeerId: PeerId, postbox: Postbox,
|
||||
}
|
||||
return mediaContentToUpload(accountPeerId: accountPeerId, network: network, postbox: postbox, auxiliaryMethods: stateManager.auxiliaryMethods, transformOutgoingMessageMedia: transformOutgoingMessageMedia, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: mediaReferenceRevalidationContext, forceReupload: forceReupload, isGrouped: false, passFetchProgress: false, forceNoBigParts: false, peerId: messageId.peerId, media: augmentedMedia, text: "", autoremoveMessageAttribute: nil, autoclearMessageAttribute: nil, messageId: nil, attributes: attributes, mediaReference: nil)
|
||||
}
|
||||
if let uploadSignal = generateUploadSignal(forceReupload) {
|
||||
if let todo = media.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 }))
|
||||
uploadedMedia = .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputTodo, text), reuploadInfo: nil, cacheReferenceKey: nil)))
|
||||
}
|
||||
else if let uploadSignal = generateUploadSignal(forceReupload) {
|
||||
uploadedMedia = .single(.progress(PendingMessageUploadedContentProgress(progress: 0.027)))
|
||||
|> then(uploadSignal)
|
||||
|> map { result -> PendingMessageUploadedContentResult? in
|
||||
@ -110,7 +121,7 @@ private func requestEditMessageInternal(accountPeerId: PeerId, postbox: Postbox,
|
||||
if text.isEmpty {
|
||||
for media in message.media {
|
||||
switch media {
|
||||
case _ as TelegramMediaImage, _ as TelegramMediaFile:
|
||||
case _ as TelegramMediaImage, _ as TelegramMediaFile, _ as TelegramMediaTodo:
|
||||
break
|
||||
default:
|
||||
if let _ = scheduleTime {
|
||||
|
||||
@ -11,7 +11,7 @@ func _internal_getPaidMessagesRevenue(account: Account, peerId: PeerId) -> Signa
|
||||
guard let inputUser else {
|
||||
return .single(nil)
|
||||
}
|
||||
return account.network.request(Api.functions.account.getPaidMessagesRevenue(userId: inputUser))
|
||||
return account.network.request(Api.functions.account.getPaidMessagesRevenue(flags: 0, parentPeer: nil, userId: inputUser))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.account.PaidMessagesRevenue?, NoError> in
|
||||
return .single(nil)
|
||||
@ -40,7 +40,7 @@ func _internal_addNoPaidMessagesException(account: Account, peerId: PeerId, refu
|
||||
if refundCharged {
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
return account.network.request(Api.functions.account.addNoPaidMessagesException(flags: flags, userId: inputUser))
|
||||
return account.network.request(Api.functions.account.toggleNoPaidMessagesException(flags: flags, parentPeer: nil, userId: inputUser))
|
||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||
return .single(.boolFalse)
|
||||
} |> mapToSignal { _ in
|
||||
|
||||
@ -161,6 +161,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case paidMessagesPriceEdited(stars: Int64, broadcastMessagesAllowed: Bool)
|
||||
case conferenceCall(ConferenceCall)
|
||||
case todoCompletions(completed: [Int32], incompleted: [Int32])
|
||||
case todoAppendTasks([TelegramMediaTodo.Item])
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0)
|
||||
@ -301,6 +302,10 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
completed: decoder.decodeInt32ArrayForKey("completed"),
|
||||
incompleted: decoder.decodeInt32ArrayForKey("incompleted")
|
||||
)
|
||||
case 50:
|
||||
self = .todoAppendTasks(
|
||||
decoder.decodeObjectArrayWithDecoderForKey("tasks")
|
||||
)
|
||||
default:
|
||||
self = .unknown
|
||||
}
|
||||
@ -708,6 +713,9 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
encoder.encodeInt32(49, forKey: "_rawValue")
|
||||
encoder.encodeInt32Array(completed, forKey: "completed")
|
||||
encoder.encodeInt32Array(incompleted, forKey: "incompleted")
|
||||
case let .todoAppendTasks(tasks):
|
||||
encoder.encodeInt32(50, forKey: "_rawValue")
|
||||
encoder.encodeObjectArray(tasks, forKey: "tasks")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ public final class TelegramMediaTodo: Media, Equatable {
|
||||
return nil
|
||||
}
|
||||
public var peerIds: [PeerId] {
|
||||
return []
|
||||
return self.completions.map { $0.completedBy }
|
||||
}
|
||||
|
||||
public let flags: Flags
|
||||
|
||||
@ -20,6 +20,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
case sponsorInfo
|
||||
case additionalInfo
|
||||
case canReport
|
||||
case minDisplayDuration
|
||||
case maxDisplayDuration
|
||||
}
|
||||
|
||||
enum MessageType: Int32, Codable {
|
||||
@ -41,6 +43,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
public let sponsorInfo: String?
|
||||
public let additionalInfo: String?
|
||||
public let canReport: Bool
|
||||
public let minDisplayDuration: Int32?
|
||||
public let maxDisplayDuration: Int32?
|
||||
|
||||
public init(
|
||||
opaqueId: Data,
|
||||
@ -56,7 +60,9 @@ private class AdMessagesHistoryContextImpl {
|
||||
buttonText: String,
|
||||
sponsorInfo: String?,
|
||||
additionalInfo: String?,
|
||||
canReport: Bool
|
||||
canReport: Bool,
|
||||
minDisplayDuration: Int32?,
|
||||
maxDisplayDuration: Int32?
|
||||
) {
|
||||
self.opaqueId = opaqueId
|
||||
self.messageType = messageType
|
||||
@ -72,6 +78,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
self.sponsorInfo = sponsorInfo
|
||||
self.additionalInfo = additionalInfo
|
||||
self.canReport = canReport
|
||||
self.minDisplayDuration = minDisplayDuration
|
||||
self.maxDisplayDuration = maxDisplayDuration
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
@ -109,6 +117,9 @@ private class AdMessagesHistoryContextImpl {
|
||||
self.additionalInfo = try container.decodeIfPresent(String.self, forKey: .additionalInfo)
|
||||
|
||||
self.canReport = try container.decodeIfPresent(Bool.self, forKey: .canReport) ?? false
|
||||
|
||||
self.minDisplayDuration = try container.decodeIfPresent(Int32.self, forKey: .minDisplayDuration)
|
||||
self.maxDisplayDuration = try container.decodeIfPresent(Int32.self, forKey: .maxDisplayDuration)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -144,6 +155,9 @@ private class AdMessagesHistoryContextImpl {
|
||||
try container.encodeIfPresent(self.additionalInfo, forKey: .additionalInfo)
|
||||
|
||||
try container.encode(self.canReport, forKey: .canReport)
|
||||
|
||||
try container.encodeIfPresent(self.minDisplayDuration, forKey: .minDisplayDuration)
|
||||
try container.encodeIfPresent(self.maxDisplayDuration, forKey: .maxDisplayDuration)
|
||||
}
|
||||
|
||||
public static func ==(lhs: CachedMessage, rhs: CachedMessage) -> Bool {
|
||||
@ -193,6 +207,12 @@ private class AdMessagesHistoryContextImpl {
|
||||
if lhs.canReport != rhs.canReport {
|
||||
return false
|
||||
}
|
||||
if lhs.minDisplayDuration != rhs.minDisplayDuration {
|
||||
return false
|
||||
}
|
||||
if lhs.maxDisplayDuration != rhs.maxDisplayDuration {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@ -206,10 +226,22 @@ private class AdMessagesHistoryContextImpl {
|
||||
case .recommended:
|
||||
mappedMessageType = .recommended
|
||||
}
|
||||
attributes.append(AdMessageAttribute(opaqueId: self.opaqueId, messageType: mappedMessageType, url: self.url, buttonText: self.buttonText, sponsorInfo: self.sponsorInfo, additionalInfo: self.additionalInfo, canReport: self.canReport, hasContentMedia: !self.contentMedia.isEmpty))
|
||||
let adAttribute = AdMessageAttribute(
|
||||
opaqueId: self.opaqueId,
|
||||
messageType: mappedMessageType,
|
||||
url: self.url,
|
||||
buttonText: self.buttonText,
|
||||
sponsorInfo: self.sponsorInfo,
|
||||
additionalInfo: self.additionalInfo,
|
||||
canReport: self.canReport,
|
||||
hasContentMedia: !self.contentMedia.isEmpty,
|
||||
minDisplayDuration: self.minDisplayDuration,
|
||||
maxDisplayDuration: self.maxDisplayDuration
|
||||
)
|
||||
attributes.append(adAttribute)
|
||||
if !self.textEntities.isEmpty {
|
||||
let attribute = TextEntitiesMessageAttribute(entities: self.textEntities)
|
||||
attributes.append(attribute)
|
||||
let entitiesAttribute = TextEntitiesMessageAttribute(entities: self.textEntities)
|
||||
attributes.append(entitiesAttribute)
|
||||
}
|
||||
|
||||
var messagePeers = SimpleDictionary<PeerId, Peer>()
|
||||
@ -282,7 +314,8 @@ private class AdMessagesHistoryContextImpl {
|
||||
|
||||
private let queue: Queue
|
||||
private let account: Account
|
||||
private let peerId: PeerId
|
||||
private let peerId: EnginePeer.Id
|
||||
private let messageId: EngineMessage.Id?
|
||||
|
||||
private let maskAsSeenDisposables = DisposableDict<Data>()
|
||||
|
||||
@ -369,12 +402,20 @@ private class AdMessagesHistoryContextImpl {
|
||||
|
||||
struct State: Equatable {
|
||||
var interPostInterval: Int32?
|
||||
var startDelay: Int32?
|
||||
var betweenDelay: Int32?
|
||||
var messages: [Message]
|
||||
|
||||
static func ==(lhs: State, rhs: State) -> Bool {
|
||||
if lhs.interPostInterval != rhs.interPostInterval {
|
||||
return false
|
||||
}
|
||||
if lhs.startDelay != rhs.startDelay {
|
||||
return false
|
||||
}
|
||||
if lhs.betweenDelay != rhs.betweenDelay {
|
||||
return false
|
||||
}
|
||||
if lhs.messages.count != rhs.messages.count {
|
||||
return false
|
||||
}
|
||||
@ -401,15 +442,17 @@ private class AdMessagesHistoryContextImpl {
|
||||
|
||||
private let disposable = MetaDisposable()
|
||||
|
||||
init(queue: Queue, account: Account, peerId: PeerId) {
|
||||
init(queue: Queue, account: Account, peerId: EnginePeer.Id, messageId: EngineMessage.Id?) {
|
||||
self.queue = queue
|
||||
self.account = account
|
||||
self.peerId = peerId
|
||||
self.messageId = messageId
|
||||
|
||||
let accountPeerId = account.peerId
|
||||
|
||||
self.stateValue = State(interPostInterval: nil, messages: [])
|
||||
|
||||
if messageId == nil {
|
||||
self.state.set(CachedState.getCached(postbox: account.postbox, peerId: peerId)
|
||||
|> mapToSignal { cachedState -> Signal<State, NoError> in
|
||||
if let cachedState = cachedState, cachedState.timestamp >= Int32(Date().timeIntervalSince1970) - 5 * 60 {
|
||||
@ -422,27 +465,32 @@ private class AdMessagesHistoryContextImpl {
|
||||
return .single(State(interPostInterval: nil, messages: []))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
let signal: Signal<(interPostInterval: Int32?, messages: [Message]), NoError> = account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||
let signal: Signal<(interPostInterval: Int32?, startDelay: Int32?, betweenDelay: Int32?, messages: [Message]), NoError> = account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||
}
|
||||
|> mapToSignal { inputPeer -> Signal<(interPostInterval: Int32?, messages: [Message]), NoError> in
|
||||
|> mapToSignal { inputPeer -> Signal<(interPostInterval: Int32?, startDelay: Int32?, betweenDelay: Int32?, messages: [Message]), NoError> in
|
||||
guard let inputPeer else {
|
||||
return .single((nil, []))
|
||||
return .single((nil, nil, nil, []))
|
||||
}
|
||||
return account.network.request(Api.functions.messages.getSponsoredMessages(peer: inputPeer))
|
||||
var flags: Int32 = 0
|
||||
if let _ = messageId {
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
return account.network.request(Api.functions.messages.getSponsoredMessages(flags: flags, peer: inputPeer, msgId: messageId?.id))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.messages.SponsoredMessages?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { result -> Signal<(interPostInterval: Int32?, messages: [Message]), NoError> in
|
||||
|> mapToSignal { result -> Signal<(interPostInterval: Int32?, startDelay: Int32?, betweenDelay: Int32?, messages: [Message]), NoError> in
|
||||
guard let result = result else {
|
||||
return .single((nil, []))
|
||||
return .single((nil, nil, nil, []))
|
||||
}
|
||||
|
||||
return account.postbox.transaction { transaction -> (interPostInterval: Int32?, messages: [Message]) in
|
||||
return account.postbox.transaction { transaction -> (interPostInterval: Int32?, startDelay: Int32?, betweenDelay: Int32?, messages: [Message]) in
|
||||
switch result {
|
||||
case let .sponsoredMessages(_, postsBetween, messages, chats, users):
|
||||
case let .sponsoredMessages(_, postsBetween, startDelay, betweenDelay, messages, chats, users):
|
||||
let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
|
||||
@ -450,7 +498,7 @@ private class AdMessagesHistoryContextImpl {
|
||||
|
||||
for message in messages {
|
||||
switch message {
|
||||
case let .sponsoredMessage(flags, randomId, url, title, message, entities, photo, media, color, buttonText, sponsorInfo, additionalInfo):
|
||||
case let .sponsoredMessage(flags, randomId, url, title, message, entities, photo, media, color, buttonText, sponsorInfo, additionalInfo, minDisplayDuration, maxDisplayDuration):
|
||||
var parsedEntities: [MessageTextEntity] = []
|
||||
if let entities = entities {
|
||||
parsedEntities = messageTextEntitiesFromApiEntities(entities)
|
||||
@ -486,29 +534,33 @@ private class AdMessagesHistoryContextImpl {
|
||||
buttonText: buttonText,
|
||||
sponsorInfo: sponsorInfo,
|
||||
additionalInfo: additionalInfo,
|
||||
canReport: canReport
|
||||
canReport: canReport,
|
||||
minDisplayDuration: minDisplayDuration,
|
||||
maxDisplayDuration: maxDisplayDuration
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
if messageId == nil {
|
||||
CachedState.setCached(transaction: transaction, peerId: peerId, state: CachedState(timestamp: Int32(Date().timeIntervalSince1970), interPostInterval: postsBetween, messages: parsedMessages))
|
||||
}
|
||||
|
||||
return (postsBetween, parsedMessages.compactMap { message -> Message? in
|
||||
return (postsBetween, startDelay, betweenDelay, parsedMessages.compactMap { message -> Message? in
|
||||
return message.toMessage(peerId: peerId, transaction: transaction)
|
||||
})
|
||||
case .sponsoredMessagesEmpty:
|
||||
return (nil, [])
|
||||
return (nil, nil, nil, [])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.disposable.set((signal
|
||||
|> deliverOn(self.queue)).start(next: { [weak self] interPostInterval, messages in
|
||||
|> deliverOn(self.queue)).start(next: { [weak self] interPostInterval, startDelay, betweenDelay, messages in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.stateValue = State(interPostInterval: interPostInterval, messages: messages)
|
||||
strongSelf.stateValue = State(interPostInterval: interPostInterval, startDelay: startDelay, betweenDelay: betweenDelay, messages: messages)
|
||||
}))
|
||||
}
|
||||
|
||||
@ -560,6 +612,7 @@ public class AdMessagesHistoryContext {
|
||||
private let queue = Queue()
|
||||
private let impl: QueueLocalObject<AdMessagesHistoryContextImpl>
|
||||
public let peerId: EnginePeer.Id
|
||||
public let messageId: EngineMessage.Id?
|
||||
|
||||
public var state: Signal<(interPostInterval: Int32?, messages: [Message]), NoError> {
|
||||
return Signal { subscriber in
|
||||
@ -576,11 +629,13 @@ public class AdMessagesHistoryContext {
|
||||
}
|
||||
}
|
||||
|
||||
public init(account: Account, peerId: PeerId) {
|
||||
public init(account: Account, peerId: EnginePeer.Id, messageId: EngineMessage.Id? = nil) {
|
||||
self.peerId = peerId
|
||||
self.messageId = messageId
|
||||
|
||||
let queue = self.queue
|
||||
self.impl = QueueLocalObject(queue: queue, generate: {
|
||||
return AdMessagesHistoryContextImpl(queue: queue, account: account, peerId: peerId)
|
||||
return AdMessagesHistoryContextImpl(queue: queue, account: account, peerId: peerId, messageId: messageId)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -415,8 +415,8 @@ public extension TelegramEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public func adMessages(peerId: PeerId) -> AdMessagesHistoryContext {
|
||||
return AdMessagesHistoryContext(account: self.account, peerId: peerId)
|
||||
public func adMessages(peerId: PeerId, messageId: EngineMessage.Id? = nil) -> AdMessagesHistoryContext {
|
||||
return AdMessagesHistoryContext(account: self.account, peerId: peerId, messageId: messageId)
|
||||
}
|
||||
|
||||
public func messageReadStats(id: MessageId) -> Signal<MessageReadStats?, NoError> {
|
||||
|
||||
@ -13,30 +13,23 @@ func _internal_requestUpdateTodoMessageItems(account: Account, messageId: Messag
|
||||
return account.postbox.loadedPeerWithId(messageId.peerId)
|
||||
|> take(1)
|
||||
|> castError(RequestUpdateTodoMessageError.self)
|
||||
|> mapToSignal { peer in
|
||||
|> mapToSignal { peer -> Signal<Never, RequestUpdateTodoMessageError> 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
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Void, RequestUpdateTodoMessageError> in
|
||||
return account.postbox.transaction { transaction in
|
||||
account.stateManager.addUpdates(result)
|
||||
return nil
|
||||
}
|
||||
|> castError(RequestUpdateTodoMessageError.self)
|
||||
}
|
||||
} else {
|
||||
return .single(nil)
|
||||
}
|
||||
}
|
||||
|> ignoreValues
|
||||
} else {
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum AppendTodoMessageError {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user