mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-28 16:42:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
ba65da2930
@ -240,8 +240,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[-1263546448] = { return Api.Update.parse_updatePeerLocated($0) }
|
dict[-1263546448] = { return Api.Update.parse_updatePeerLocated($0) }
|
||||||
dict[967122427] = { return Api.Update.parse_updateNewScheduledMessage($0) }
|
dict[967122427] = { return Api.Update.parse_updateNewScheduledMessage($0) }
|
||||||
dict[-1870238482] = { return Api.Update.parse_updateDeleteScheduledMessages($0) }
|
dict[-1870238482] = { return Api.Update.parse_updateDeleteScheduledMessages($0) }
|
||||||
dict[-2112423005] = { return Api.Update.parse_updateTheme($0) }
|
|
||||||
dict[357013699] = { return Api.Update.parse_updateMessageReactions($0) }
|
dict[357013699] = { return Api.Update.parse_updateMessageReactions($0) }
|
||||||
|
dict[-2112423005] = { return Api.Update.parse_updateTheme($0) }
|
||||||
dict[1558266229] = { return Api.PopularContact.parse_popularContact($0) }
|
dict[1558266229] = { return Api.PopularContact.parse_popularContact($0) }
|
||||||
dict[-373643672] = { return Api.FolderPeer.parse_folderPeer($0) }
|
dict[-373643672] = { return Api.FolderPeer.parse_folderPeer($0) }
|
||||||
dict[367766557] = { return Api.ChannelParticipant.parse_channelParticipant($0) }
|
dict[367766557] = { return Api.ChannelParticipant.parse_channelParticipant($0) }
|
||||||
@ -428,7 +428,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[-2128640689] = { return Api.account.SentEmailCode.parse_sentEmailCode($0) }
|
dict[-2128640689] = { return Api.account.SentEmailCode.parse_sentEmailCode($0) }
|
||||||
dict[-1038136962] = { return Api.EncryptedFile.parse_encryptedFileEmpty($0) }
|
dict[-1038136962] = { return Api.EncryptedFile.parse_encryptedFileEmpty($0) }
|
||||||
dict[1248893260] = { return Api.EncryptedFile.parse_encryptedFile($0) }
|
dict[1248893260] = { return Api.EncryptedFile.parse_encryptedFile($0) }
|
||||||
dict[-557924733] = { return Api.CodeSettings.parse_codeSettings($0) }
|
|
||||||
dict[-391902247] = { return Api.SecureValueError.parse_secureValueErrorData($0) }
|
dict[-391902247] = { return Api.SecureValueError.parse_secureValueErrorData($0) }
|
||||||
dict[12467706] = { return Api.SecureValueError.parse_secureValueErrorFrontSide($0) }
|
dict[12467706] = { return Api.SecureValueError.parse_secureValueErrorFrontSide($0) }
|
||||||
dict[-2037765467] = { return Api.SecureValueError.parse_secureValueErrorReverseSide($0) }
|
dict[-2037765467] = { return Api.SecureValueError.parse_secureValueErrorReverseSide($0) }
|
||||||
@ -726,7 +725,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[-104284986] = { return Api.WebDocument.parse_webDocumentNoProxy($0) }
|
dict[-104284986] = { return Api.WebDocument.parse_webDocumentNoProxy($0) }
|
||||||
dict[475467473] = { return Api.WebDocument.parse_webDocument($0) }
|
dict[475467473] = { return Api.WebDocument.parse_webDocument($0) }
|
||||||
dict[1211967244] = { return Api.Theme.parse_themeDocumentNotModified($0) }
|
dict[1211967244] = { return Api.Theme.parse_themeDocumentNotModified($0) }
|
||||||
dict[1464749545] = { return Api.Theme.parse_theme($0) }
|
dict[975846885] = { return Api.Theme.parse_theme($0) }
|
||||||
dict[-1290580579] = { return Api.contacts.Found.parse_found($0) }
|
dict[-1290580579] = { return Api.contacts.Found.parse_found($0) }
|
||||||
dict[-368018716] = { return Api.ChannelAdminLogEventsFilter.parse_channelAdminLogEventsFilter($0) }
|
dict[-368018716] = { return Api.ChannelAdminLogEventsFilter.parse_channelAdminLogEventsFilter($0) }
|
||||||
dict[1889961234] = { return Api.PeerNotifySettings.parse_peerNotifySettingsEmpty($0) }
|
dict[1889961234] = { return Api.PeerNotifySettings.parse_peerNotifySettingsEmpty($0) }
|
||||||
@ -1088,8 +1087,6 @@ public struct Api {
|
|||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.EncryptedFile:
|
case let _1 as Api.EncryptedFile:
|
||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.CodeSettings:
|
|
||||||
_1.serialize(buffer, boxed)
|
|
||||||
case let _1 as Api.SecureValueError:
|
case let _1 as Api.SecureValueError:
|
||||||
_1.serialize(buffer, boxed)
|
_1.serialize(buffer, boxed)
|
||||||
case let _1 as Api.NotifyPeer:
|
case let _1 as Api.NotifyPeer:
|
||||||
|
@ -4143,8 +4143,8 @@ public extension Api {
|
|||||||
case updatePeerLocated(peers: [Api.PeerLocated])
|
case updatePeerLocated(peers: [Api.PeerLocated])
|
||||||
case updateNewScheduledMessage(message: Api.Message)
|
case updateNewScheduledMessage(message: Api.Message)
|
||||||
case updateDeleteScheduledMessages(peer: Api.Peer, messages: [Int32])
|
case updateDeleteScheduledMessages(peer: Api.Peer, messages: [Int32])
|
||||||
case updateTheme(theme: Api.Theme)
|
|
||||||
case updateMessageReactions(peer: Api.Peer, msgId: Int32, reactions: Api.MessageReactions)
|
case updateMessageReactions(peer: Api.Peer, msgId: Int32, reactions: Api.MessageReactions)
|
||||||
|
case updateTheme(theme: Api.Theme)
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
@ -4763,12 +4763,6 @@ public extension Api {
|
|||||||
serializeInt32(item, buffer: buffer, boxed: false)
|
serializeInt32(item, buffer: buffer, boxed: false)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case .updateTheme(let theme):
|
|
||||||
if boxed {
|
|
||||||
buffer.appendInt32(-2112423005)
|
|
||||||
}
|
|
||||||
theme.serialize(buffer, true)
|
|
||||||
break
|
|
||||||
case .updateMessageReactions(let peer, let msgId, let reactions):
|
case .updateMessageReactions(let peer, let msgId, let reactions):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(357013699)
|
buffer.appendInt32(357013699)
|
||||||
@ -4777,6 +4771,12 @@ public extension Api {
|
|||||||
serializeInt32(msgId, buffer: buffer, boxed: false)
|
serializeInt32(msgId, buffer: buffer, boxed: false)
|
||||||
reactions.serialize(buffer, true)
|
reactions.serialize(buffer, true)
|
||||||
break
|
break
|
||||||
|
case .updateTheme(let theme):
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(-2112423005)
|
||||||
|
}
|
||||||
|
theme.serialize(buffer, true)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4928,10 +4928,10 @@ public extension Api {
|
|||||||
return ("updateNewScheduledMessage", [("message", message)])
|
return ("updateNewScheduledMessage", [("message", message)])
|
||||||
case .updateDeleteScheduledMessages(let peer, let messages):
|
case .updateDeleteScheduledMessages(let peer, let messages):
|
||||||
return ("updateDeleteScheduledMessages", [("peer", peer), ("messages", messages)])
|
return ("updateDeleteScheduledMessages", [("peer", peer), ("messages", messages)])
|
||||||
case .updateTheme(let theme):
|
|
||||||
return ("updateTheme", [("theme", theme)])
|
|
||||||
case .updateMessageReactions(let peer, let msgId, let reactions):
|
case .updateMessageReactions(let peer, let msgId, let reactions):
|
||||||
return ("updateMessageReactions", [("peer", peer), ("msgId", msgId), ("reactions", reactions)])
|
return ("updateMessageReactions", [("peer", peer), ("msgId", msgId), ("reactions", reactions)])
|
||||||
|
case .updateTheme(let theme):
|
||||||
|
return ("updateTheme", [("theme", theme)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6177,19 +6177,6 @@ public extension Api {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static func parse_updateTheme(_ reader: BufferReader) -> Update? {
|
|
||||||
var _1: Api.Theme?
|
|
||||||
if let signature = reader.readInt32() {
|
|
||||||
_1 = Api.parse(reader, signature: signature) as? Api.Theme
|
|
||||||
}
|
|
||||||
let _c1 = _1 != nil
|
|
||||||
if _c1 {
|
|
||||||
return Api.Update.updateTheme(theme: _1!)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static func parse_updateMessageReactions(_ reader: BufferReader) -> Update? {
|
public static func parse_updateMessageReactions(_ reader: BufferReader) -> Update? {
|
||||||
var _1: Api.Peer?
|
var _1: Api.Peer?
|
||||||
if let signature = reader.readInt32() {
|
if let signature = reader.readInt32() {
|
||||||
@ -6211,6 +6198,19 @@ public extension Api {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static func parse_updateTheme(_ reader: BufferReader) -> Update? {
|
||||||
|
var _1: Api.Theme?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
_1 = Api.parse(reader, signature: signature) as? Api.Theme
|
||||||
|
}
|
||||||
|
let _c1 = _1 != nil
|
||||||
|
if _c1 {
|
||||||
|
return Api.Update.updateTheme(theme: _1!)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public enum PopularContact: TypeConstructorDescription {
|
public enum PopularContact: TypeConstructorDescription {
|
||||||
@ -10642,40 +10642,6 @@ public extension Api {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
public enum CodeSettings: TypeConstructorDescription {
|
|
||||||
case codeSettings(flags: Int32)
|
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
|
||||||
switch self {
|
|
||||||
case .codeSettings(let flags):
|
|
||||||
if boxed {
|
|
||||||
buffer.appendInt32(-557924733)
|
|
||||||
}
|
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
|
||||||
switch self {
|
|
||||||
case .codeSettings(let flags):
|
|
||||||
return ("codeSettings", [("flags", flags)])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func parse_codeSettings(_ reader: BufferReader) -> CodeSettings? {
|
|
||||||
var _1: Int32?
|
|
||||||
_1 = reader.readInt32()
|
|
||||||
let _c1 = _1 != nil
|
|
||||||
if _c1 {
|
|
||||||
return Api.CodeSettings.codeSettings(flags: _1!)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public enum SecureValueError: TypeConstructorDescription {
|
public enum SecureValueError: TypeConstructorDescription {
|
||||||
case secureValueErrorData(type: Api.SecureValueType, dataHash: Buffer, field: String, text: String)
|
case secureValueErrorData(type: Api.SecureValueType, dataHash: Buffer, field: String, text: String)
|
||||||
@ -18455,7 +18421,7 @@ public extension Api {
|
|||||||
}
|
}
|
||||||
public enum Theme: TypeConstructorDescription {
|
public enum Theme: TypeConstructorDescription {
|
||||||
case themeDocumentNotModified
|
case themeDocumentNotModified
|
||||||
case theme(flags: Int32, id: Int64, accessHash: Int64, slug: String, title: String, document: Api.Document)
|
case theme(flags: Int32, id: Int64, accessHash: Int64, slug: String, title: String, document: Api.Document?)
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
@ -18467,14 +18433,14 @@ public extension Api {
|
|||||||
break
|
break
|
||||||
case .theme(let flags, let id, let accessHash, let slug, let title, let document):
|
case .theme(let flags, let id, let accessHash, let slug, let title, let document):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(1464749545)
|
buffer.appendInt32(975846885)
|
||||||
}
|
}
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
serializeInt64(id, buffer: buffer, boxed: false)
|
serializeInt64(id, buffer: buffer, boxed: false)
|
||||||
serializeInt64(accessHash, buffer: buffer, boxed: false)
|
serializeInt64(accessHash, buffer: buffer, boxed: false)
|
||||||
serializeString(slug, buffer: buffer, boxed: false)
|
serializeString(slug, buffer: buffer, boxed: false)
|
||||||
serializeString(title, buffer: buffer, boxed: false)
|
serializeString(title, buffer: buffer, boxed: false)
|
||||||
document.serialize(buffer, true)
|
if Int(flags) & Int(1 << 2) != 0 {document!.serialize(buffer, true)}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18503,17 +18469,17 @@ public extension Api {
|
|||||||
var _5: String?
|
var _5: String?
|
||||||
_5 = parseString(reader)
|
_5 = parseString(reader)
|
||||||
var _6: Api.Document?
|
var _6: Api.Document?
|
||||||
if let signature = reader.readInt32() {
|
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
|
||||||
_6 = Api.parse(reader, signature: signature) as? Api.Document
|
_6 = Api.parse(reader, signature: signature) as? Api.Document
|
||||||
}
|
} }
|
||||||
let _c1 = _1 != nil
|
let _c1 = _1 != nil
|
||||||
let _c2 = _2 != nil
|
let _c2 = _2 != nil
|
||||||
let _c3 = _3 != nil
|
let _c3 = _3 != nil
|
||||||
let _c4 = _4 != nil
|
let _c4 = _4 != nil
|
||||||
let _c5 = _5 != nil
|
let _c5 = _5 != nil
|
||||||
let _c6 = _6 != nil
|
let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil
|
||||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||||
return Api.Theme.theme(flags: _1!, id: _2!, accessHash: _3!, slug: _4!, title: _5!, document: _6!)
|
return Api.Theme.theme(flags: _1!, id: _2!, accessHash: _3!, slug: _4!, title: _5!, document: _6)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -2924,6 +2924,33 @@ public extension Api {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static func forwardMessages(flags: Int32, fromPeer: Api.InputPeer, id: [Int32], randomId: [Int64], toPeer: Api.InputPeer, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||||
|
let buffer = Buffer()
|
||||||
|
buffer.appendInt32(-637606386)
|
||||||
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
|
fromPeer.serialize(buffer, true)
|
||||||
|
buffer.appendInt32(481674261)
|
||||||
|
buffer.appendInt32(Int32(id.count))
|
||||||
|
for item in id {
|
||||||
|
serializeInt32(item, buffer: buffer, boxed: false)
|
||||||
|
}
|
||||||
|
buffer.appendInt32(481674261)
|
||||||
|
buffer.appendInt32(Int32(randomId.count))
|
||||||
|
for item in randomId {
|
||||||
|
serializeInt64(item, buffer: buffer, boxed: false)
|
||||||
|
}
|
||||||
|
toPeer.serialize(buffer, true)
|
||||||
|
if Int(flags) & Int(1 << 10) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
|
||||||
|
return (FunctionDescription(name: "messages.forwardMessages", parameters: [("flags", flags), ("fromPeer", fromPeer), ("id", id), ("randomId", randomId), ("toPeer", toPeer), ("scheduleDate", scheduleDate)]), 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 static func sendInlineBotResult(flags: Int32, peer: Api.InputPeer, replyToMsgId: Int32?, randomId: Int64, queryId: Int64, id: String, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
public static func sendInlineBotResult(flags: Int32, peer: Api.InputPeer, replyToMsgId: Int32?, randomId: Int64, queryId: Int64, id: String, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||||
let buffer = Buffer()
|
let buffer = Buffer()
|
||||||
buffer.appendInt32(570955184)
|
buffer.appendInt32(570955184)
|
||||||
@ -2944,6 +2971,31 @@ public extension Api {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static func editMessage(flags: Int32, peer: Api.InputPeer, id: Int32, message: String?, media: Api.InputMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||||
|
let buffer = Buffer()
|
||||||
|
buffer.appendInt32(1224152952)
|
||||||
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
|
peer.serialize(buffer, true)
|
||||||
|
serializeInt32(id, buffer: buffer, boxed: false)
|
||||||
|
if Int(flags) & Int(1 << 11) != 0 {serializeString(message!, buffer: buffer, boxed: false)}
|
||||||
|
if Int(flags) & Int(1 << 14) != 0 {media!.serialize(buffer, true)}
|
||||||
|
if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)}
|
||||||
|
if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261)
|
||||||
|
buffer.appendInt32(Int32(entities!.count))
|
||||||
|
for item in entities! {
|
||||||
|
item.serialize(buffer, true)
|
||||||
|
}}
|
||||||
|
if Int(flags) & Int(1 << 15) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
|
||||||
|
return (FunctionDescription(name: "messages.editMessage", parameters: [("flags", flags), ("peer", peer), ("id", id), ("message", message), ("media", media), ("replyMarkup", replyMarkup), ("entities", entities), ("scheduleDate", scheduleDate)]), 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 static func sendMultiMedia(flags: Int32, peer: Api.InputPeer, replyToMsgId: Int32?, multiMedia: [Api.InputSingleMedia], scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
public static func sendMultiMedia(flags: Int32, peer: Api.InputPeer, replyToMsgId: Int32?, multiMedia: [Api.InputSingleMedia], scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||||
let buffer = Buffer()
|
let buffer = Buffer()
|
||||||
buffer.appendInt32(-872345397)
|
buffer.appendInt32(-872345397)
|
||||||
@ -2966,33 +3018,6 @@ public extension Api {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func forwardMessages(flags: Int32, fromPeer: Api.InputPeer, id: [Int32], randomId: [Int64], toPeer: Api.InputPeer, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
|
||||||
let buffer = Buffer()
|
|
||||||
buffer.appendInt32(-637606386)
|
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
|
||||||
fromPeer.serialize(buffer, true)
|
|
||||||
buffer.appendInt32(481674261)
|
|
||||||
buffer.appendInt32(Int32(id.count))
|
|
||||||
for item in id {
|
|
||||||
serializeInt32(item, buffer: buffer, boxed: false)
|
|
||||||
}
|
|
||||||
buffer.appendInt32(481674261)
|
|
||||||
buffer.appendInt32(Int32(randomId.count))
|
|
||||||
for item in randomId {
|
|
||||||
serializeInt64(item, buffer: buffer, boxed: false)
|
|
||||||
}
|
|
||||||
toPeer.serialize(buffer, true)
|
|
||||||
if Int(flags) & Int(1 << 10) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
|
|
||||||
return (FunctionDescription(name: "messages.forwardMessages", parameters: [("flags", flags), ("fromPeer", fromPeer), ("id", id), ("randomId", randomId), ("toPeer", toPeer), ("scheduleDate", scheduleDate)]), 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 static func getScheduledHistory(peer: Api.InputPeer, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Messages>) {
|
public static func getScheduledHistory(peer: Api.InputPeer, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Messages>) {
|
||||||
let buffer = Buffer()
|
let buffer = Buffer()
|
||||||
buffer.appendInt32(-490575781)
|
buffer.appendInt32(-490575781)
|
||||||
@ -3065,31 +3090,6 @@ public extension Api {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func editMessage(flags: Int32, peer: Api.InputPeer, id: Int32, message: String?, media: Api.InputMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, scheduleDate: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
|
||||||
let buffer = Buffer()
|
|
||||||
buffer.appendInt32(1224152952)
|
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
|
||||||
peer.serialize(buffer, true)
|
|
||||||
serializeInt32(id, buffer: buffer, boxed: false)
|
|
||||||
if Int(flags) & Int(1 << 11) != 0 {serializeString(message!, buffer: buffer, boxed: false)}
|
|
||||||
if Int(flags) & Int(1 << 14) != 0 {media!.serialize(buffer, true)}
|
|
||||||
if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)}
|
|
||||||
if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261)
|
|
||||||
buffer.appendInt32(Int32(entities!.count))
|
|
||||||
for item in entities! {
|
|
||||||
item.serialize(buffer, true)
|
|
||||||
}}
|
|
||||||
if Int(flags) & Int(1 << 15) != 0 {serializeInt32(scheduleDate!, buffer: buffer, boxed: false)}
|
|
||||||
return (FunctionDescription(name: "messages.editMessage", parameters: [("flags", flags), ("peer", peer), ("id", id), ("message", message), ("media", media), ("replyMarkup", replyMarkup), ("entities", entities), ("scheduleDate", scheduleDate)]), 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 static func sendReaction(flags: Int32, peer: Api.InputPeer, msgId: Int32, reaction: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
public static func sendReaction(flags: Int32, peer: Api.InputPeer, msgId: Int32, reaction: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||||
let buffer = Buffer()
|
let buffer = Buffer()
|
||||||
buffer.appendInt32(627641572)
|
buffer.appendInt32(627641572)
|
||||||
|
@ -329,17 +329,6 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
|
|||||||
attributes.append(ConsumableContentMessageAttribute(consumed: false))
|
attributes.append(ConsumableContentMessageAttribute(consumed: false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let peer = peer as? TelegramChannel {
|
|
||||||
switch peer.info {
|
|
||||||
case let .broadcast(info):
|
|
||||||
attributes.append(ViewCountMessageAttribute(count: 1))
|
|
||||||
if info.flags.contains(.messagesShouldHaveSignatures) {
|
|
||||||
attributes.append(AuthorSignatureMessageAttribute(signature: accountPeer.debugDisplayTitle))
|
|
||||||
}
|
|
||||||
case .group:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var entitiesAttribute: TextEntitiesMessageAttribute?
|
var entitiesAttribute: TextEntitiesMessageAttribute?
|
||||||
for attribute in attributes {
|
for attribute in attributes {
|
||||||
@ -398,6 +387,20 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let peer = peer as? TelegramChannel {
|
||||||
|
switch peer.info {
|
||||||
|
case let .broadcast(info):
|
||||||
|
if messageNamespace != Namespaces.Message.ScheduledLocal {
|
||||||
|
attributes.append(ViewCountMessageAttribute(count: 1))
|
||||||
|
}
|
||||||
|
if info.flags.contains(.messagesShouldHaveSignatures) {
|
||||||
|
attributes.append(AuthorSignatureMessageAttribute(signature: accountPeer.debugDisplayTitle))
|
||||||
|
}
|
||||||
|
case .group:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
storeMessages.append(StoreMessage(peerId: peerId, namespace: messageNamespace, globallyUniqueId: randomId, groupingKey: localGroupingKey, timestamp: effectiveTimestamp, flags: flags, tags: tags, globalTags: globalTags, localTags: localTags, forwardInfo: nil, authorId: authorId, text: text, attributes: attributes, media: mediaList))
|
storeMessages.append(StoreMessage(peerId: peerId, namespace: messageNamespace, globallyUniqueId: randomId, groupingKey: localGroupingKey, timestamp: effectiveTimestamp, flags: flags, tags: tags, globalTags: globalTags, localTags: localTags, forwardInfo: nil, authorId: authorId, text: text, attributes: attributes, media: mediaList))
|
||||||
case let .forward(source, grouping, requestedAttributes):
|
case let .forward(source, grouping, requestedAttributes):
|
||||||
let sourceMessage = transaction.getMessage(source)
|
let sourceMessage = transaction.getMessage(source)
|
||||||
|
@ -194,7 +194,7 @@ public extension Message {
|
|||||||
if self.flags.contains(.Failed) {
|
if self.flags.contains(.Failed) {
|
||||||
return true
|
return true
|
||||||
} else if self.id.namespace == Namespaces.Message.ScheduledCloud {
|
} else if self.id.namespace == Namespaces.Message.ScheduledCloud {
|
||||||
return timestamp > self.timestamp
|
return timestamp > self.timestamp + 30
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ public enum PendingMessageFailureReason {
|
|||||||
case publicBan
|
case publicBan
|
||||||
case mediaRestricted
|
case mediaRestricted
|
||||||
case slowmodeActive
|
case slowmodeActive
|
||||||
|
case tooMuchScheduled
|
||||||
}
|
}
|
||||||
|
|
||||||
private func reasonForError(_ error: String) -> PendingMessageFailureReason? {
|
private func reasonForError(_ error: String) -> PendingMessageFailureReason? {
|
||||||
@ -75,6 +76,8 @@ private func reasonForError(_ error: String) -> PendingMessageFailureReason? {
|
|||||||
return .mediaRestricted
|
return .mediaRestricted
|
||||||
} else if error.hasPrefix("SLOWMODE_WAIT") {
|
} else if error.hasPrefix("SLOWMODE_WAIT") {
|
||||||
return .slowmodeActive
|
return .slowmodeActive
|
||||||
|
} else if error.hasPrefix("SCHEDULE_TOO_MUCH") {
|
||||||
|
return .tooMuchScheduled
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -501,7 +501,7 @@ extension StoreMessage {
|
|||||||
attributes.append(ReplyMessageAttribute(messageId: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: replyToMsgId)))
|
attributes.append(ReplyMessageAttribute(messageId: MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: replyToMsgId)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if let views = views {
|
if let views = views, namespace != Namespaces.Message.ScheduledCloud {
|
||||||
attributes.append(ViewCountMessageAttribute(count: Int(views)))
|
attributes.append(ViewCountMessageAttribute(count: Int(views)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,8 +537,6 @@ extension StoreMessage {
|
|||||||
attributes.append(ContentRequiresValidationMessageAttribute())
|
attributes.append(ContentRequiresValidationMessageAttribute())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if let reactions = reactions {
|
if let reactions = reactions {
|
||||||
attributes.append(ReactionsMessageAttribute(apiReactions: reactions))
|
attributes.append(ReactionsMessageAttribute(apiReactions: reactions))
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable {
|
|||||||
public let accessHash: Int64
|
public let accessHash: Int64
|
||||||
public let slug: String
|
public let slug: String
|
||||||
public let title: String
|
public let title: String
|
||||||
public let file: TelegramMediaFile
|
public let file: TelegramMediaFile?
|
||||||
public let isCreator: Bool
|
public let isCreator: Bool
|
||||||
public let isDefault: Bool
|
public let isDefault: Bool
|
||||||
|
|
||||||
public init(id: Int64, accessHash: Int64, slug: String, title: String, file: TelegramMediaFile, isCreator: Bool, isDefault: Bool) {
|
public init(id: Int64, accessHash: Int64, slug: String, title: String, file: TelegramMediaFile?, isCreator: Bool, isDefault: Bool) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.accessHash = accessHash
|
self.accessHash = accessHash
|
||||||
self.slug = slug
|
self.slug = slug
|
||||||
@ -33,7 +33,7 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable {
|
|||||||
self.accessHash = decoder.decodeInt64ForKey("accessHash", orElse: 0)
|
self.accessHash = decoder.decodeInt64ForKey("accessHash", orElse: 0)
|
||||||
self.slug = decoder.decodeStringForKey("slug", orElse: "")
|
self.slug = decoder.decodeStringForKey("slug", orElse: "")
|
||||||
self.title = decoder.decodeStringForKey("title", orElse: "")
|
self.title = decoder.decodeStringForKey("title", orElse: "")
|
||||||
self.file = decoder.decodeObjectForKey("file", decoder: { TelegramMediaFile(decoder: $0) }) as! TelegramMediaFile
|
self.file = decoder.decodeObjectForKey("file", decoder: { TelegramMediaFile(decoder: $0) }) as? TelegramMediaFile
|
||||||
self.isCreator = decoder.decodeInt32ForKey("isCreator", orElse: 0) != 0
|
self.isCreator = decoder.decodeInt32ForKey("isCreator", orElse: 0) != 0
|
||||||
self.isDefault = decoder.decodeInt32ForKey("isDefault", orElse: 0) != 0
|
self.isDefault = decoder.decodeInt32ForKey("isDefault", orElse: 0) != 0
|
||||||
}
|
}
|
||||||
@ -43,7 +43,11 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable {
|
|||||||
encoder.encodeInt64(self.accessHash, forKey: "accessHash")
|
encoder.encodeInt64(self.accessHash, forKey: "accessHash")
|
||||||
encoder.encodeString(self.slug, forKey: "slug")
|
encoder.encodeString(self.slug, forKey: "slug")
|
||||||
encoder.encodeString(self.title, forKey: "title")
|
encoder.encodeString(self.title, forKey: "title")
|
||||||
encoder.encodeObject(self.file, forKey: "file")
|
if let file = self.file {
|
||||||
|
encoder.encodeObject(file, forKey: "file")
|
||||||
|
} else {
|
||||||
|
encoder.encodeNil(forKey: "file")
|
||||||
|
}
|
||||||
encoder.encodeInt32(self.isCreator ? 1 : 0, forKey: "isCreator")
|
encoder.encodeInt32(self.isCreator ? 1 : 0, forKey: "isCreator")
|
||||||
encoder.encodeInt32(self.isDefault ? 1 : 0, forKey: "isDefault")
|
encoder.encodeInt32(self.isDefault ? 1 : 0, forKey: "isDefault")
|
||||||
}
|
}
|
||||||
@ -61,7 +65,7 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable {
|
|||||||
if lhs.title != rhs.title {
|
if lhs.title != rhs.title {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if lhs.file.id != rhs.file.id {
|
if lhs.file?.id != rhs.file?.id {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if lhs.isCreator != rhs.isCreator {
|
if lhs.isCreator != rhs.isCreator {
|
||||||
@ -78,11 +82,7 @@ extension TelegramTheme {
|
|||||||
convenience init?(apiTheme: Api.Theme) {
|
convenience init?(apiTheme: Api.Theme) {
|
||||||
switch apiTheme {
|
switch apiTheme {
|
||||||
case let .theme(flags, id, accessHash, slug, title, document):
|
case let .theme(flags, id, accessHash, slug, title, document):
|
||||||
if let file = telegramMediaFileFromApiDocument(document) {
|
self.init(id: id, accessHash: accessHash, slug: slug, title: title, file: document.flatMap(telegramMediaFileFromApiDocument), isCreator: (flags & 1 << 0) != 0, isDefault: (flags & 1 << 1) != 0)
|
||||||
self.init(id: id, accessHash: accessHash, slug: slug, title: title, file: file, isCreator: (flags & 1 << 0) != 0, isDefault: (flags & 1 << 1) != 0)
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,26 @@ public func getTheme(account: Account, slug: String) -> Signal<TelegramTheme, Ge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum CheckThemeUpdatedResult {
|
||||||
|
case updated(TelegramTheme)
|
||||||
|
case notModified
|
||||||
|
}
|
||||||
|
|
||||||
|
public func checkThemeUpdated(account: Account, theme: TelegramTheme) -> Signal<CheckThemeUpdatedResult, GetThemeError> {
|
||||||
|
guard let file = theme.file, let fileId = file.id?.id else {
|
||||||
|
return .fail(.generic)
|
||||||
|
}
|
||||||
|
return account.network.request(Api.functions.account.getTheme(format: themeFormat, theme: .inputTheme(id: theme.id, accessHash: theme.accessHash), documentId: fileId))
|
||||||
|
|> mapError { _ -> GetThemeError in return .generic }
|
||||||
|
|> map { theme -> CheckThemeUpdatedResult in
|
||||||
|
if let theme = TelegramTheme(apiTheme: theme) {
|
||||||
|
return .updated(theme)
|
||||||
|
} else {
|
||||||
|
return .notModified
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func saveTheme(account: Account, theme: TelegramTheme) -> Signal<Void, NoError> {
|
public func saveTheme(account: Account, theme: TelegramTheme) -> Signal<Void, NoError> {
|
||||||
return saveUnsaveTheme(account: account, theme: theme, unsave: false)
|
return saveUnsaveTheme(account: account, theme: theme, unsave: false)
|
||||||
}
|
}
|
||||||
@ -124,7 +144,7 @@ public func installTheme(account: Account, theme: TelegramTheme) -> Signal<Void,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum UploadThemeStatus {
|
public enum UploadThemeResult {
|
||||||
case progress(Float)
|
case progress(Float)
|
||||||
case complete(TelegramMediaFile)
|
case complete(TelegramMediaFile)
|
||||||
}
|
}
|
||||||
@ -153,13 +173,13 @@ private func uploadedTheme(postbox: Postbox, network: Network, resource: MediaRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func uploadTheme(account: Account, resource: MediaResource) -> Signal<UploadThemeStatus, UploadThemeError> {
|
private func uploadTheme(account: Account, resource: MediaResource) -> Signal<UploadThemeResult, UploadThemeError> {
|
||||||
let fileName = "theme.\(themeFileExtension)"
|
let fileName = "theme.\(themeFileExtension)"
|
||||||
let mimeType = "application/x-tgtheme-\(themeFormat)"
|
let mimeType = "application/x-tgtheme-\(themeFormat)"
|
||||||
|
|
||||||
return uploadedTheme(postbox: account.postbox, network: account.network, resource: resource)
|
return uploadedTheme(postbox: account.postbox, network: account.network, resource: resource)
|
||||||
|> mapError { _ -> UploadThemeError in return .generic }
|
|> mapError { _ -> UploadThemeError in return .generic }
|
||||||
|> mapToSignal { result -> Signal<(UploadThemeStatus, MediaResource?), UploadThemeError> in
|
|> mapToSignal { result -> Signal<(UploadThemeResult, MediaResource?), UploadThemeError> in
|
||||||
switch result.content {
|
switch result.content {
|
||||||
case .error:
|
case .error:
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
@ -170,7 +190,7 @@ private func uploadTheme(account: Account, resource: MediaResource) -> Signal<Up
|
|||||||
case let .inputFile(file):
|
case let .inputFile(file):
|
||||||
return account.network.request(Api.functions.account.uploadTheme(flags: 0, file: file, thumb: nil, fileName: fileName, mimeType: mimeType))
|
return account.network.request(Api.functions.account.uploadTheme(flags: 0, file: file, thumb: nil, fileName: fileName, mimeType: mimeType))
|
||||||
|> mapError { _ in return UploadThemeError.generic }
|
|> mapError { _ in return UploadThemeError.generic }
|
||||||
|> mapToSignal { document -> Signal<(UploadThemeStatus, MediaResource?), UploadThemeError> in
|
|> mapToSignal { document -> Signal<(UploadThemeResult, MediaResource?), UploadThemeError> in
|
||||||
if let file = telegramMediaFileFromApiDocument(document) {
|
if let file = telegramMediaFileFromApiDocument(document) {
|
||||||
return .single((.complete(file), result.resource))
|
return .single((.complete(file), result.resource))
|
||||||
} else {
|
} else {
|
||||||
@ -182,7 +202,7 @@ private func uploadTheme(account: Account, resource: MediaResource) -> Signal<Up
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> map { result, _ -> UploadThemeStatus in
|
|> map { result, _ -> UploadThemeResult in
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,18 +211,23 @@ public enum CreateThemeError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
public func createTheme(account: Account, resource: MediaResource, title: String, slug: String) -> Signal<TelegramTheme, CreateThemeError> {
|
public enum CreateThemeResult {
|
||||||
|
case result(TelegramTheme)
|
||||||
|
case progress(Float)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func createTheme(account: Account, resource: MediaResource, title: String) -> Signal<CreateThemeResult, CreateThemeError> {
|
||||||
return uploadTheme(account: account, resource: resource)
|
return uploadTheme(account: account, resource: resource)
|
||||||
|> mapError { _ in return CreateThemeError.generic }
|
|> mapError { _ in return CreateThemeError.generic }
|
||||||
|> mapToSignal { status -> Signal<TelegramTheme, CreateThemeError> in
|
|> mapToSignal { result -> Signal<CreateThemeResult, CreateThemeError> in
|
||||||
switch status {
|
switch result {
|
||||||
case let .complete(file):
|
case let .complete(file):
|
||||||
if let resource = file.resource as? CloudDocumentMediaResource {
|
if let resource = file.resource as? CloudDocumentMediaResource {
|
||||||
return account.network.request(Api.functions.account.createTheme(slug: slug, title: title, document: .inputDocument(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))))
|
return account.network.request(Api.functions.account.createTheme(slug: "", title: title, document: .inputDocument(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))))
|
||||||
|> mapError { _ in return CreateThemeError.generic }
|
|> mapError { _ in return CreateThemeError.generic }
|
||||||
|> mapToSignal { apiTheme -> Signal<TelegramTheme, CreateThemeError> in
|
|> mapToSignal { apiTheme -> Signal<CreateThemeResult, CreateThemeError> in
|
||||||
if let theme = TelegramTheme(apiTheme: apiTheme) {
|
if let theme = TelegramTheme(apiTheme: apiTheme) {
|
||||||
return .single(theme)
|
return .single(.result(theme))
|
||||||
} else {
|
} else {
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
}
|
||||||
@ -211,17 +236,16 @@ public func createTheme(account: Account, resource: MediaResource, title: String
|
|||||||
else {
|
else {
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
}
|
||||||
default:
|
case let .progress(progress):
|
||||||
return .complete()
|
return .single(.progress(progress))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateTheme(account: Account, theme: TelegramTheme, title: String?, slug: String?, resource: MediaResource?) -> Signal<TelegramTheme, CreateThemeError> {
|
public func updateTheme(account: Account, theme: TelegramTheme, title: String?, slug: String?, resource: MediaResource?) -> Signal<CreateThemeResult, CreateThemeError> {
|
||||||
guard title != nil || slug != nil || resource != nil else {
|
guard title != nil || slug != nil || resource != nil else {
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
|
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
if let _ = title {
|
if let _ = title {
|
||||||
flags |= 1 << 1
|
flags |= 1 << 1
|
||||||
@ -230,6 +254,42 @@ public func updateTheme(account: Account, theme: TelegramTheme, title: String?,
|
|||||||
flags |= 1 << 0
|
flags |= 1 << 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return .never()
|
let uploadSignal: Signal<UploadThemeResult?, UploadThemeError>
|
||||||
//return account.network.request(Api.functions.account.updateTheme(flags: flags, theme: .inputTheme(id: theme.id, accessHash: theme.accessHash), slug: slug, title: title, document: <#T##Api.InputDocument?#>))
|
if let resource = resource {
|
||||||
|
uploadSignal = uploadTheme(account: account, resource: resource)
|
||||||
|
|> map(Optional.init)
|
||||||
|
} else {
|
||||||
|
uploadSignal = .single(nil)
|
||||||
|
}
|
||||||
|
return uploadSignal
|
||||||
|
|> mapError { _ -> CreateThemeError in
|
||||||
|
return .generic
|
||||||
|
}
|
||||||
|
|> mapToSignal { result -> Signal<CreateThemeResult, CreateThemeError> in
|
||||||
|
let inputDocument: Api.InputDocument?
|
||||||
|
if let status = result {
|
||||||
|
switch status {
|
||||||
|
case let .complete(file):
|
||||||
|
if let resource = file.resource as? CloudDocumentMediaResource {
|
||||||
|
inputDocument = .inputDocument(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))
|
||||||
|
} else {
|
||||||
|
return .fail(.generic)
|
||||||
|
}
|
||||||
|
case let .progress(progress):
|
||||||
|
return .single(.progress(progress))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inputDocument = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return account.network.request(Api.functions.account.updateTheme(flags: flags, theme: .inputTheme(id: theme.id, accessHash: theme.accessHash), slug: slug, title: title, document: inputDocument))
|
||||||
|
|> mapError { _ in return CreateThemeError.generic }
|
||||||
|
|> mapToSignal { apiTheme -> Signal<CreateThemeResult, CreateThemeError> in
|
||||||
|
if let theme = TelegramTheme(apiTheme: apiTheme) {
|
||||||
|
return .single(.result(theme))
|
||||||
|
} else {
|
||||||
|
return .fail(.generic)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
|
|||||||
case 3:
|
case 3:
|
||||||
let settings = decoder.decodeObjectForKey("settings", decoder: { WallpaperSettings(decoder: $0) }) as? WallpaperSettings ?? WallpaperSettings()
|
let settings = decoder.decodeObjectForKey("settings", decoder: { WallpaperSettings(decoder: $0) }) as? WallpaperSettings ?? WallpaperSettings()
|
||||||
if let file = decoder.decodeObjectForKey("file", decoder: { TelegramMediaFile(decoder: $0) }) as? TelegramMediaFile {
|
if let file = decoder.decodeObjectForKey("file", decoder: { TelegramMediaFile(decoder: $0) }) as? TelegramMediaFile {
|
||||||
self = .file(id: decoder.decodeInt64ForKey("id", orElse: 0), accessHash: decoder.decodeInt64ForKey("accessHash", orElse: 0), isCreator: decoder.decodeInt32ForKey("isCreator", orElse: 0) != 0, isDefault: decoder.decodeInt32ForKey("isDefault", orElse: 0) != 0, isPattern: decoder.decodeInt32ForKey("isPattern", orElse: 0) != 0, isDark: decoder.decodeInt32ForKey("isDark", orElse: 0) != 0, slug: decoder.decodeStringForKey("slug", orElse: ""), file: decoder.decodeObjectForKey("file", decoder: { TelegramMediaFile(decoder: $0) }) as! TelegramMediaFile, settings: settings)
|
self = .file(id: decoder.decodeInt64ForKey("id", orElse: 0), accessHash: decoder.decodeInt64ForKey("accessHash", orElse: 0), isCreator: decoder.decodeInt32ForKey("isCreator", orElse: 0) != 0, isDefault: decoder.decodeInt32ForKey("isDefault", orElse: 0) != 0, isPattern: decoder.decodeInt32ForKey("isPattern", orElse: 0) != 0, isDark: decoder.decodeInt32ForKey("isDark", orElse: 0) != 0, slug: decoder.decodeStringForKey("slug", orElse: ""), file: file, settings: settings)
|
||||||
} else {
|
} else {
|
||||||
self = .color(0xffffff)
|
self = .color(0xffffff)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user