Update API

This commit is contained in:
Ali 2022-08-25 20:37:09 +03:00
parent baad5e1eb8
commit 1d2ad0f5de
13 changed files with 157 additions and 64 deletions

View File

@ -89,7 +89,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-914167110] = { return Api.CdnPublicKey.parse_cdnPublicKey($0) } dict[-914167110] = { return Api.CdnPublicKey.parse_cdnPublicKey($0) }
dict[531458253] = { return Api.ChannelAdminLogEvent.parse_channelAdminLogEvent($0) } dict[531458253] = { return Api.ChannelAdminLogEvent.parse_channelAdminLogEvent($0) }
dict[1427671598] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeAbout($0) } dict[1427671598] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeAbout($0) }
dict[-1661470870] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeAvailableReactions($0) } dict[-1102180616] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeAvailableReactions($0) }
dict[1855199800] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeHistoryTTL($0) } dict[1855199800] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeHistoryTTL($0) }
dict[84703944] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeLinkedChat($0) } dict[84703944] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeLinkedChat($0) }
dict[241923758] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeLocation($0) } dict[241923758] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeLocation($0) }
@ -595,6 +595,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1558266229] = { return Api.PopularContact.parse_popularContact($0) } dict[1558266229] = { return Api.PopularContact.parse_popularContact($0) }
dict[512535275] = { return Api.PostAddress.parse_postAddress($0) } dict[512535275] = { return Api.PostAddress.parse_postAddress($0) }
dict[1958953753] = { return Api.PremiumGiftOption.parse_premiumGiftOption($0) } dict[1958953753] = { return Api.PremiumGiftOption.parse_premiumGiftOption($0) }
dict[-1225711938] = { return Api.PremiumSubscriptionOption.parse_premiumSubscriptionOption($0) }
dict[1124062251] = { return Api.PrivacyKey.parse_privacyKeyAddedByPhone($0) } dict[1124062251] = { return Api.PrivacyKey.parse_privacyKeyAddedByPhone($0) }
dict[1343122938] = { return Api.PrivacyKey.parse_privacyKeyChatInvite($0) } dict[1343122938] = { return Api.PrivacyKey.parse_privacyKeyChatInvite($0) }
dict[1777096355] = { return Api.PrivacyKey.parse_privacyKeyForwards($0) } dict[1777096355] = { return Api.PrivacyKey.parse_privacyKeyForwards($0) }
@ -953,7 +954,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[415997816] = { return Api.help.InviteText.parse_inviteText($0) } dict[415997816] = { return Api.help.InviteText.parse_inviteText($0) }
dict[-1600596305] = { return Api.help.PassportConfig.parse_passportConfig($0) } dict[-1600596305] = { return Api.help.PassportConfig.parse_passportConfig($0) }
dict[-1078332329] = { return Api.help.PassportConfig.parse_passportConfigNotModified($0) } dict[-1078332329] = { return Api.help.PassportConfig.parse_passportConfigNotModified($0) }
dict[-1974518743] = { return Api.help.PremiumPromo.parse_premiumPromo($0) } dict[1395946908] = { return Api.help.PremiumPromo.parse_premiumPromo($0) }
dict[-1942390465] = { return Api.help.PromoData.parse_promoData($0) } dict[-1942390465] = { return Api.help.PromoData.parse_promoData($0) }
dict[-1728664459] = { return Api.help.PromoData.parse_promoDataEmpty($0) } dict[-1728664459] = { return Api.help.PromoData.parse_promoDataEmpty($0) }
dict[235081943] = { return Api.help.RecentMeUrls.parse_recentMeUrls($0) } dict[235081943] = { return Api.help.RecentMeUrls.parse_recentMeUrls($0) }
@ -1497,6 +1498,8 @@ public extension Api {
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.PremiumGiftOption: case let _1 as Api.PremiumGiftOption:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.PremiumSubscriptionOption:
_1.serialize(buffer, boxed)
case let _1 as Api.PrivacyKey: case let _1 as Api.PrivacyKey:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.PrivacyRule: case let _1 as Api.PrivacyRule:

View File

@ -652,6 +652,62 @@ public extension Api {
} }
} }
public extension Api {
enum PremiumSubscriptionOption: TypeConstructorDescription {
case premiumSubscriptionOption(flags: Int32, months: Int32, currency: String, amount: Int64, botUrl: String, storeProduct: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .premiumSubscriptionOption(let flags, let months, let currency, let amount, let botUrl, let storeProduct):
if boxed {
buffer.appendInt32(-1225711938)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(months, buffer: buffer, boxed: false)
serializeString(currency, buffer: buffer, boxed: false)
serializeInt64(amount, buffer: buffer, boxed: false)
serializeString(botUrl, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeString(storeProduct!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .premiumSubscriptionOption(let flags, let months, let currency, let amount, let botUrl, let storeProduct):
return ("premiumSubscriptionOption", [("flags", String(describing: flags)), ("months", String(describing: months)), ("currency", String(describing: currency)), ("amount", String(describing: amount)), ("botUrl", String(describing: botUrl)), ("storeProduct", String(describing: storeProduct))])
}
}
public static func parse_premiumSubscriptionOption(_ reader: BufferReader) -> PremiumSubscriptionOption? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: String?
_3 = parseString(reader)
var _4: Int64?
_4 = reader.readInt64()
var _5: String?
_5 = parseString(reader)
var _6: String?
if Int(_1!) & Int(1 << 0) != 0 {_6 = parseString(reader) }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
return Api.PremiumSubscriptionOption.premiumSubscriptionOption(flags: _1!, months: _2!, currency: _3!, amount: _4!, botUrl: _5!, storeProduct: _6)
}
else {
return nil
}
}
}
}
public extension Api { public extension Api {
enum PrivacyKey: TypeConstructorDescription { enum PrivacyKey: TypeConstructorDescription {
case privacyKeyAddedByPhone case privacyKeyAddedByPhone

View File

@ -607,7 +607,7 @@ public extension Api {
public extension Api { public extension Api {
enum ChannelAdminLogEventAction: TypeConstructorDescription { enum ChannelAdminLogEventAction: TypeConstructorDescription {
case channelAdminLogEventActionChangeAbout(prevValue: String, newValue: String) case channelAdminLogEventActionChangeAbout(prevValue: String, newValue: String)
case channelAdminLogEventActionChangeAvailableReactions(prevValue: [String], newValue: [String]) case channelAdminLogEventActionChangeAvailableReactions(prevValue: Api.ChatReactions, newValue: Api.ChatReactions)
case channelAdminLogEventActionChangeHistoryTTL(prevValue: Int32, newValue: Int32) case channelAdminLogEventActionChangeHistoryTTL(prevValue: Int32, newValue: Int32)
case channelAdminLogEventActionChangeLinkedChat(prevValue: Int64, newValue: Int64) case channelAdminLogEventActionChangeLinkedChat(prevValue: Int64, newValue: Int64)
case channelAdminLogEventActionChangeLocation(prevValue: Api.ChannelLocation, newValue: Api.ChannelLocation) case channelAdminLogEventActionChangeLocation(prevValue: Api.ChannelLocation, newValue: Api.ChannelLocation)
@ -654,18 +654,10 @@ public extension Api {
break break
case .channelAdminLogEventActionChangeAvailableReactions(let prevValue, let newValue): case .channelAdminLogEventActionChangeAvailableReactions(let prevValue, let newValue):
if boxed { if boxed {
buffer.appendInt32(-1661470870) buffer.appendInt32(-1102180616)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(prevValue.count))
for item in prevValue {
serializeString(item, buffer: buffer, boxed: false)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(newValue.count))
for item in newValue {
serializeString(item, buffer: buffer, boxed: false)
} }
prevValue.serialize(buffer, true)
newValue.serialize(buffer, true)
break break
case .channelAdminLogEventActionChangeHistoryTTL(let prevValue, let newValue): case .channelAdminLogEventActionChangeHistoryTTL(let prevValue, let newValue):
if boxed { if boxed {
@ -980,13 +972,13 @@ public extension Api {
} }
} }
public static func parse_channelAdminLogEventActionChangeAvailableReactions(_ reader: BufferReader) -> ChannelAdminLogEventAction? { public static func parse_channelAdminLogEventActionChangeAvailableReactions(_ reader: BufferReader) -> ChannelAdminLogEventAction? {
var _1: [String]? var _1: Api.ChatReactions?
if let _ = reader.readInt32() { if let signature = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self) _1 = Api.parse(reader, signature: signature) as? Api.ChatReactions
} }
var _2: [String]? var _2: Api.ChatReactions?
if let _ = reader.readInt32() { if let signature = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self) _2 = Api.parse(reader, signature: signature) as? Api.ChatReactions
} }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil

View File

@ -414,13 +414,13 @@ public extension Api.help {
} }
public extension Api.help { public extension Api.help {
enum PremiumPromo: TypeConstructorDescription { enum PremiumPromo: TypeConstructorDescription {
case premiumPromo(statusText: String, statusEntities: [Api.MessageEntity], videoSections: [String], videos: [Api.Document], currency: String, monthlyAmount: Int64, users: [Api.User]) case premiumPromo(statusText: String, statusEntities: [Api.MessageEntity], videoSections: [String], videos: [Api.Document], periodOptions: [Api.PremiumSubscriptionOption], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .premiumPromo(let statusText, let statusEntities, let videoSections, let videos, let currency, let monthlyAmount, let users): case .premiumPromo(let statusText, let statusEntities, let videoSections, let videos, let periodOptions, let users):
if boxed { if boxed {
buffer.appendInt32(-1974518743) buffer.appendInt32(1395946908)
} }
serializeString(statusText, buffer: buffer, boxed: false) serializeString(statusText, buffer: buffer, boxed: false)
buffer.appendInt32(481674261) buffer.appendInt32(481674261)
@ -438,8 +438,11 @@ public extension Api.help {
for item in videos { for item in videos {
item.serialize(buffer, true) item.serialize(buffer, true)
} }
serializeString(currency, buffer: buffer, boxed: false) buffer.appendInt32(481674261)
serializeInt64(monthlyAmount, buffer: buffer, boxed: false) buffer.appendInt32(Int32(periodOptions.count))
for item in periodOptions {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261) buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count)) buffer.appendInt32(Int32(users.count))
for item in users { for item in users {
@ -451,8 +454,8 @@ public extension Api.help {
public func descriptionFields() -> (String, [(String, Any)]) { public func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .premiumPromo(let statusText, let statusEntities, let videoSections, let videos, let currency, let monthlyAmount, let users): case .premiumPromo(let statusText, let statusEntities, let videoSections, let videos, let periodOptions, let users):
return ("premiumPromo", [("statusText", String(describing: statusText)), ("statusEntities", String(describing: statusEntities)), ("videoSections", String(describing: videoSections)), ("videos", String(describing: videos)), ("currency", String(describing: currency)), ("monthlyAmount", String(describing: monthlyAmount)), ("users", String(describing: users))]) return ("premiumPromo", [("statusText", String(describing: statusText)), ("statusEntities", String(describing: statusEntities)), ("videoSections", String(describing: videoSections)), ("videos", String(describing: videos)), ("periodOptions", String(describing: periodOptions)), ("users", String(describing: users))])
} }
} }
@ -471,13 +474,13 @@ public extension Api.help {
if let _ = reader.readInt32() { if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self) _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
} }
var _5: String? var _5: [Api.PremiumSubscriptionOption]?
_5 = parseString(reader)
var _6: Int64?
_6 = reader.readInt64()
var _7: [Api.User]?
if let _ = reader.readInt32() { if let _ = reader.readInt32() {
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PremiumSubscriptionOption.self)
}
var _6: [Api.User]?
if let _ = reader.readInt32() {
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
} }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
@ -485,9 +488,8 @@ public extension Api.help {
let _c4 = _4 != nil let _c4 = _4 != nil
let _c5 = _5 != nil let _c5 = _5 != nil
let _c6 = _6 != nil let _c6 = _6 != nil
let _c7 = _7 != nil if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { return Api.help.PremiumPromo.premiumPromo(statusText: _1!, statusEntities: _2!, videoSections: _3!, videos: _4!, periodOptions: _5!, users: _6!)
return Api.help.PremiumPromo.premiumPromo(statusText: _1!, statusEntities: _2!, videoSections: _3!, videos: _4!, currency: _5!, monthlyAmount: _6!, users: _7!)
} }
else { else {
return nil return nil

View File

@ -5383,13 +5383,13 @@ public extension Api.functions.messages {
} }
} }
public extension Api.functions.messages { public extension Api.functions.messages {
static func reportReaction(peer: Api.InputPeer, id: Int32, userId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) { static func reportReaction(peer: Api.InputPeer, id: Int32, reactionPeer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(1631726152) buffer.appendInt32(1063567478)
peer.serialize(buffer, true) peer.serialize(buffer, true)
serializeInt32(id, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false)
userId.serialize(buffer, true) reactionPeer.serialize(buffer, true)
return (FunctionDescription(name: "messages.reportReaction", parameters: [("peer", String(describing: peer)), ("id", String(describing: id)), ("userId", String(describing: userId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in return (FunctionDescription(name: "messages.reportReaction", parameters: [("peer", String(describing: peer)), ("id", String(describing: id)), ("reactionPeer", String(describing: reactionPeer))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.Bool? var result: Api.Bool?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {
@ -5432,14 +5432,15 @@ public extension Api.functions.messages {
} }
} }
public extension Api.functions.messages { public extension Api.functions.messages {
static func requestSimpleWebView(flags: Int32, bot: Api.InputUser, url: String, themeParams: Api.DataJSON?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.SimpleWebViewResult>) { static func requestSimpleWebView(flags: Int32, bot: Api.InputUser, url: String, themeParams: Api.DataJSON?, platform: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.SimpleWebViewResult>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(1790652275) buffer.appendInt32(698084494)
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
bot.serialize(buffer, true) bot.serialize(buffer, true)
serializeString(url, buffer: buffer, boxed: false) serializeString(url, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {themeParams!.serialize(buffer, true)} if Int(flags) & Int(1 << 0) != 0 {themeParams!.serialize(buffer, true)}
return (FunctionDescription(name: "messages.requestSimpleWebView", parameters: [("flags", String(describing: flags)), ("bot", String(describing: bot)), ("url", String(describing: url)), ("themeParams", String(describing: themeParams))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.SimpleWebViewResult? in serializeString(platform, buffer: buffer, boxed: false)
return (FunctionDescription(name: "messages.requestSimpleWebView", parameters: [("flags", String(describing: flags)), ("bot", String(describing: bot)), ("url", String(describing: url)), ("themeParams", String(describing: themeParams)), ("platform", String(describing: platform))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.SimpleWebViewResult? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.SimpleWebViewResult? var result: Api.SimpleWebViewResult?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {
@ -5469,18 +5470,19 @@ public extension Api.functions.messages {
} }
} }
public extension Api.functions.messages { public extension Api.functions.messages {
static func requestWebView(flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, url: String?, startParam: String?, themeParams: Api.DataJSON?, replyToMsgId: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.WebViewResult>) { static func requestWebView(flags: Int32, peer: Api.InputPeer, bot: Api.InputUser, url: String?, startParam: String?, themeParams: Api.DataJSON?, platform: String, replyToMsgId: Int32?, sendAs: Api.InputPeer?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.WebViewResult>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(-1850648527) buffer.appendInt32(-58219204)
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true) peer.serialize(buffer, true)
bot.serialize(buffer, true) bot.serialize(buffer, true)
if Int(flags) & Int(1 << 1) != 0 {serializeString(url!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {serializeString(url!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 3) != 0 {serializeString(startParam!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 3) != 0 {serializeString(startParam!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {themeParams!.serialize(buffer, true)} if Int(flags) & Int(1 << 2) != 0 {themeParams!.serialize(buffer, true)}
serializeString(platform, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(replyToMsgId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)} if Int(flags) & Int(1 << 13) != 0 {sendAs!.serialize(buffer, true)}
return (FunctionDescription(name: "messages.requestWebView", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("bot", String(describing: bot)), ("url", String(describing: url)), ("startParam", String(describing: startParam)), ("themeParams", String(describing: themeParams)), ("replyToMsgId", String(describing: replyToMsgId)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.WebViewResult? in return (FunctionDescription(name: "messages.requestWebView", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("bot", String(describing: bot)), ("url", String(describing: url)), ("startParam", String(describing: startParam)), ("themeParams", String(describing: themeParams)), ("platform", String(describing: platform)), ("replyToMsgId", String(describing: replyToMsgId)), ("sendAs", String(describing: sendAs))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.WebViewResult? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.WebViewResult? var result: Api.WebViewResult?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {

View File

@ -19,7 +19,7 @@ func updatePremiumPromoConfigurationOnce(postbox: Postbox, network: Network) ->
return .complete() return .complete()
} }
return postbox.transaction { transaction -> Void in return postbox.transaction { transaction -> Void in
if case let .premiumPromo(_, _, _, _, _, _, apiUsers) = result { if case let .premiumPromo(_, _, _, _, _, apiUsers) = result {
let users = apiUsers.map { TelegramUser(user: $0) } let users = apiUsers.map { TelegramUser(user: $0) }
updatePeers(transaction: transaction, peers: users, update: { current, updated -> Peer in updatePeers(transaction: transaction, peers: users, update: { current, updated -> Peer in
if let updated = updated as? TelegramUser { if let updated = updated as? TelegramUser {
@ -65,7 +65,7 @@ private func updatePremiumPromoConfiguration(transaction: Transaction, _ f: (Pre
private extension PremiumPromoConfiguration { private extension PremiumPromoConfiguration {
init(apiPremiumPromo: Api.help.PremiumPromo) { init(apiPremiumPromo: Api.help.PremiumPromo) {
switch apiPremiumPromo { switch apiPremiumPromo {
case let .premiumPromo(statusText, statusEntities, videoSections, videoFiles, currency, monthlyAmount, _): case let .premiumPromo(statusText, statusEntities, videoSections, videoFiles, periodOptions, _):
self.status = statusText self.status = statusText
self.statusEntities = messageTextEntitiesFromApiEntities(statusEntities) self.statusEntities = messageTextEntitiesFromApiEntities(statusEntities)
self.currency = currency self.currency = currency

View File

@ -5,7 +5,7 @@ public struct CacheStorageSettings: Codable, Equatable {
public let defaultCacheStorageLimitGigabytes: Int32 public let defaultCacheStorageLimitGigabytes: Int32
public static var defaultSettings: CacheStorageSettings { public static var defaultSettings: CacheStorageSettings {
return CacheStorageSettings(defaultCacheStorageTimeout: Int32.max, defaultCacheStorageLimitGigabytes: Int32.max) return CacheStorageSettings(defaultCacheStorageTimeout: Int32.max, defaultCacheStorageLimitGigabytes: 8 * 1024 * 1024)
} }
public init(defaultCacheStorageTimeout: Int32, defaultCacheStorageLimitGigabytes: Int32) { public init(defaultCacheStorageTimeout: Int32, defaultCacheStorageLimitGigabytes: Int32) {
@ -17,7 +17,14 @@ public struct CacheStorageSettings: Codable, Equatable {
let container = try decoder.container(keyedBy: StringCodingKey.self) let container = try decoder.container(keyedBy: StringCodingKey.self)
self.defaultCacheStorageTimeout = (try? container.decode(Int32.self, forKey: "dt")) ?? Int32.max self.defaultCacheStorageTimeout = (try? container.decode(Int32.self, forKey: "dt")) ?? Int32.max
self.defaultCacheStorageLimitGigabytes = (try? container.decode(Int32.self, forKey: "dl")) ?? Int32.max
if let legacyValue = try container.decodeIfPresent(Int32.self, forKey: "dl") {
self.defaultCacheStorageLimitGigabytes = legacyValue
} else if let value = try container.decodeIfPresent(Int32.self, forKey: "sizeLimit") {
self.defaultCacheStorageLimitGigabytes = value
} else {
self.defaultCacheStorageLimitGigabytes = 8 * 1024 * 1024
}
} }
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {

View File

@ -1,5 +1,6 @@
import Foundation import Foundation
import Postbox import Postbox
import TelegramApi
public final class CachedPeerBotInfo: PostboxCoding, Equatable { public final class CachedPeerBotInfo: PostboxCoding, Equatable {
public let peerId: PeerId public let peerId: PeerId
@ -82,6 +83,19 @@ public enum PeerAllowedReactions: Equatable, Codable {
} }
} }
extension PeerAllowedReactions {
init(apiReactions: Api.ChatReactions) {
switch apiReactions {
case .chatReactionsAll:
self = .all
case let .chatReactionsSome(reactions):
self = .limited(reactions.compactMap(MessageReaction.Reaction.init(apiReaction:)))
case .chatReactionsNone:
self = .empty
}
}
}
public final class CachedGroupData: CachedPeerData { public final class CachedGroupData: CachedPeerData {
public let participants: CachedGroupParticipants? public let participants: CachedGroupParticipants?
public let exportedInvitation: ExportedInvitation? public let exportedInvitation: ExportedInvitation?

View File

@ -22,7 +22,7 @@ func _internal_requestSimpleWebView(postbox: Postbox, network: Network, botId: P
if let _ = serializedThemeParams { if let _ = serializedThemeParams {
flags |= (1 << 0) flags |= (1 << 0)
} }
return network.request(Api.functions.messages.requestSimpleWebView(flags: flags, bot: inputUser, url: url, themeParams: serializedThemeParams)) return network.request(Api.functions.messages.requestSimpleWebView(flags: flags, bot: inputUser, url: url, themeParams: serializedThemeParams, platform: ""))
|> mapError { _ -> RequestSimpleWebViewError in |> mapError { _ -> RequestSimpleWebViewError in
return .generic return .generic
} }
@ -125,7 +125,7 @@ func _internal_requestWebView(postbox: Postbox, network: Network, stateManager:
// if _ { // if _ {
// flags |= (1 << 13) // flags |= (1 << 13)
// } // }
return network.request(Api.functions.messages.requestWebView(flags: flags, peer: inputPeer, bot: inputBot, url: url, startParam: payload, themeParams: serializedThemeParams, replyToMsgId: replyToMsgId, sendAs: nil)) return network.request(Api.functions.messages.requestWebView(flags: flags, peer: inputPeer, bot: inputBot, url: url, startParam: payload, themeParams: serializedThemeParams, platform: "", replyToMsgId: replyToMsgId, sendAs: nil))
|> mapError { _ -> RequestWebViewError in |> mapError { _ -> RequestWebViewError in
return .generic return .generic
} }

View File

@ -3,9 +3,11 @@ import SwiftSignalKit
import TelegramApi import TelegramApi
public final class MessageReadStats { public final class MessageReadStats {
public let reactionCount: Int
public let peers: [EnginePeer] public let peers: [EnginePeer]
public init(peers: [EnginePeer]) { public init(reactionCount: Int, peers: [EnginePeer]) {
self.reactionCount = reactionCount
self.peers = peers self.peers = peers
} }
} }
@ -22,12 +24,25 @@ func _internal_messageReadStats(account: Account, id: MessageId) -> Signal<Messa
return .single(nil) return .single(nil)
} }
return account.network.request(Api.functions.messages.getMessageReadParticipants(peer: inputPeer, msgId: id.id)) let readPeers: Signal<[Int64]?, NoError> = account.network.request(Api.functions.messages.getMessageReadParticipants(peer: inputPeer, msgId: id.id))
|> map(Optional.init) |> map(Optional.init)
|> `catch` { _ -> Signal<[Int64]?, NoError> in |> `catch` { _ -> Signal<[Int64]?, NoError> in
return .single(nil) return .single(nil)
} }
|> mapToSignal { result -> Signal<MessageReadStats?, NoError> in
let reactionCount: Signal<Int, NoError> = account.network.request(Api.functions.messages.getMessageReactionsList(flags: 0, peer: inputPeer, id: id.id, reaction: nil, offset: nil, limit: 1))
|> map { result -> Int in
switch result {
case let .messageReactionsList(_, count, _, _, _, _):
return Int(count)
}
}
|> `catch` { _ -> Signal<Int, NoError> in
return .single(0)
}
return combineLatest(readPeers, reactionCount)
|> mapToSignal { result, reactionCount -> Signal<MessageReadStats?, NoError> in
guard let result = result else { guard let result = result else {
return .single(nil) return .single(nil)
} }
@ -56,7 +71,7 @@ func _internal_messageReadStats(account: Account, id: MessageId) -> Signal<Messa
|> mapToSignal { peerIds, missingPeerIds -> Signal<MessageReadStats?, NoError> in |> mapToSignal { peerIds, missingPeerIds -> Signal<MessageReadStats?, NoError> in
if missingPeerIds.isEmpty || id.peerId.namespace != Namespaces.Peer.CloudChannel { if missingPeerIds.isEmpty || id.peerId.namespace != Namespaces.Peer.CloudChannel {
return account.postbox.transaction { transaction -> MessageReadStats? in return account.postbox.transaction { transaction -> MessageReadStats? in
return MessageReadStats(peers: peerIds.compactMap { peerId -> EnginePeer? in return MessageReadStats(reactionCount: reactionCount, peers: peerIds.compactMap { peerId -> EnginePeer? in
return transaction.getPeer(peerId).flatMap(EnginePeer.init) return transaction.getPeer(peerId).flatMap(EnginePeer.init)
}) })
} }
@ -64,7 +79,7 @@ func _internal_messageReadStats(account: Account, id: MessageId) -> Signal<Messa
return _internal_channelMembers(postbox: account.postbox, network: account.network, accountPeerId: account.peerId, peerId: id.peerId, category: .recent(.all), offset: 0, limit: 50, hash: 0) return _internal_channelMembers(postbox: account.postbox, network: account.network, accountPeerId: account.peerId, peerId: id.peerId, category: .recent(.all), offset: 0, limit: 50, hash: 0)
|> mapToSignal { _ -> Signal<MessageReadStats?, NoError> in |> mapToSignal { _ -> Signal<MessageReadStats?, NoError> in
return account.postbox.transaction { transaction -> MessageReadStats? in return account.postbox.transaction { transaction -> MessageReadStats? in
return MessageReadStats(peers: peerIds.compactMap { peerId -> EnginePeer? in return MessageReadStats(reactionCount: reactionCount, peers: peerIds.compactMap { peerId -> EnginePeer? in
return transaction.getPeer(peerId).flatMap(EnginePeer.init) return transaction.getPeer(peerId).flatMap(EnginePeer.init)
}) })
} }

View File

@ -67,7 +67,7 @@ public enum AdminLogEventAction {
case participantJoinByRequest(invitation: ExportedInvitation, approvedBy: PeerId) case participantJoinByRequest(invitation: ExportedInvitation, approvedBy: PeerId)
case toggleCopyProtection(Bool) case toggleCopyProtection(Bool)
case sendMessage(Message) case sendMessage(Message)
case changeAvailableReactions(previousValue: [String], updatedValue: [String]) case changeAvailableReactions(previousValue: PeerAllowedReactions, updatedValue: PeerAllowedReactions)
} }
public enum ChannelAdminLogEventError { public enum ChannelAdminLogEventError {
@ -264,7 +264,7 @@ func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: PeerId, m
action = .sendMessage(rendered) action = .sendMessage(rendered)
} }
case let .channelAdminLogEventActionChangeAvailableReactions(prevValue, newValue): case let .channelAdminLogEventActionChangeAvailableReactions(prevValue, newValue):
action = .changeAvailableReactions(previousValue: prevValue, updatedValue: newValue) action = .changeAvailableReactions(previousValue: PeerAllowedReactions(apiReactions: prevValue), updatedValue: PeerAllowedReactions(apiReactions: newValue))
} }
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
if let action = action { if let action = action {

View File

@ -171,20 +171,20 @@ func _internal_reportPeerMessages(account: Account, messageIds: [MessageId], rea
} }
func _internal_reportPeerReaction(account: Account, authorId: PeerId, messageId: MessageId) -> Signal<Never, NoError> { func _internal_reportPeerReaction(account: Account, authorId: PeerId, messageId: MessageId) -> Signal<Never, NoError> {
return account.postbox.transaction { transaction -> (Api.InputPeer, Api.InputUser)? in return account.postbox.transaction { transaction -> (Api.InputPeer, Api.InputPeer)? in
guard let peer = transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) else { guard let peer = transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) else {
return nil return nil
} }
guard let author = transaction.getPeer(authorId).flatMap(apiInputUser) else { guard let author = transaction.getPeer(authorId).flatMap(apiInputPeer) else {
return nil return nil
} }
return (peer, author) return (peer, author)
} }
|> mapToSignal { inputData -> Signal<Never, NoError> in |> mapToSignal { inputData -> Signal<Never, NoError> in
guard let (inputPeer, inputUser) = inputData else { guard let (inputPeer, authorPeer) = inputData else {
return .complete() return .complete()
} }
return account.network.request(Api.functions.messages.reportReaction(peer: inputPeer, id: messageId.id, userId: inputUser)) return account.network.request(Api.functions.messages.reportReaction(peer: inputPeer, id: messageId.id, reactionPeer: authorPeer))
|> `catch` { _ -> Signal<Api.Bool, NoError> in |> `catch` { _ -> Signal<Api.Bool, NoError> in
return .single(.boolFalse) return .single(.boolFalse)
} }

View File

@ -1573,9 +1573,11 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
var readStats = readStats var readStats = readStats
if !canViewStats { if !canViewStats {
readStats = MessageReadStats(peers: []) readStats = MessageReadStats(reactionCount: 0, peers: [])
} }
let reactionCount = readStats?.reactionCount ?? 0
if hasReadReports || reactionCount != 0 { if hasReadReports || reactionCount != 0 {
if !actions.isEmpty { if !actions.isEmpty {
actions.insert(.separator, at: 0) actions.insert(.separator, at: 0)