mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-15 18:59:54 +00:00
Update API
This commit is contained in:
parent
3d4d0cc64d
commit
f6120cfead
@ -72,6 +72,26 @@ public struct ProxyServerSettings: PostboxCoding, Equatable, Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
private func dataWithHexString(_ string: String) -> Data {
|
||||
var hex = string
|
||||
if hex.count % 2 != 0 {
|
||||
return Data()
|
||||
}
|
||||
var data = Data()
|
||||
while hex.count > 0 {
|
||||
let subIndex = hex.index(hex.startIndex, offsetBy: 2)
|
||||
let c = String(hex[..<subIndex])
|
||||
hex = String(hex[subIndex...])
|
||||
var ch: UInt32 = 0
|
||||
if !Scanner(string: c).scanHexInt32(&ch) {
|
||||
return Data()
|
||||
}
|
||||
var char = UInt8(ch)
|
||||
data.append(&char, count: 1)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
public struct ProxySettings: PreferencesEntry, Equatable {
|
||||
public var enabled: Bool
|
||||
public var servers: [ProxyServerSettings]
|
||||
|
||||
@ -12,7 +12,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1210199983] = { return Api.InputGeoPoint.parse_inputGeoPoint($0) }
|
||||
dict[-784000893] = { return Api.payments.ValidatedRequestedInfo.parse_validatedRequestedInfo($0) }
|
||||
dict[1509543498] = { return Api.ChatFull.parse_chatFull($0) }
|
||||
dict[-1625164883] = { return Api.ChatFull.parse_channelFull($0) }
|
||||
dict[1517757976] = { return Api.ChatFull.parse_channelFull($0) }
|
||||
dict[-591909213] = { return Api.PollResults.parse_pollResults($0) }
|
||||
dict[-1070776313] = { return Api.ChatParticipant.parse_chatParticipant($0) }
|
||||
dict[-462696732] = { return Api.ChatParticipant.parse_chatParticipantCreator($0) }
|
||||
@ -199,9 +199,9 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1007549728] = { return Api.Update.parse_updateUserName($0) }
|
||||
dict[-232290676] = { return Api.Update.parse_updateUserPhoto($0) }
|
||||
dict[314359194] = { return Api.Update.parse_updateNewEncryptedMessage($0) }
|
||||
dict[1677363374] = { return Api.Update.parse_updateEncryptedChatTyping($0) }
|
||||
dict[386986326] = { return Api.Update.parse_updateEncryptedChatTyping($0) }
|
||||
dict[-1264392051] = { return Api.Update.parse_updateEncryption($0) }
|
||||
dict[122695484] = { return Api.Update.parse_updateEncryptedMessagesRead($0) }
|
||||
dict[956179895] = { return Api.Update.parse_updateEncryptedMessagesRead($0) }
|
||||
dict[1037718609] = { return Api.Update.parse_updateChatParticipantAdd($0) }
|
||||
dict[-483443337] = { return Api.Update.parse_updateChatParticipantDelete($0) }
|
||||
dict[-1906403213] = { return Api.Update.parse_updateDcOptions($0) }
|
||||
@ -933,7 +933,7 @@ public struct Api {
|
||||
return parser(reader)
|
||||
}
|
||||
else {
|
||||
telegramApiLog("Type constructor \(String(signature, radix: 16, uppercase: false)) not found")
|
||||
telegramApiLog("Type constructor \(String(UInt32(bitPattern: signature), radix: 16, uppercase: false)) not found")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ public extension Api {
|
||||
}
|
||||
public enum ChatFull: TypeConstructorDescription {
|
||||
case chatFull(flags: Int32, id: Int64, about: String, participants: Api.ChatParticipants, chatPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo]?, pinnedMsgId: Int32?, folderId: Int32?, call: Api.InputGroupCall?, ttlPeriod: Int32?, groupcallDefaultJoinAs: Api.Peer?)
|
||||
case channelFull(flags: Int32, id: Int64, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, onlineCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo], migratedFromChatId: Int64?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int32?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?, ttlPeriod: Int32?, pendingSuggestions: [String]?, groupcallDefaultJoinAs: Api.Peer?)
|
||||
case channelFull(flags: Int32, id: Int64, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, onlineCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo], migratedFromChatId: Int64?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int64?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?, ttlPeriod: Int32?, pendingSuggestions: [String]?, groupcallDefaultJoinAs: Api.Peer?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -181,7 +181,7 @@ public extension Api {
|
||||
break
|
||||
case .channelFull(let flags, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId, let folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call, let ttlPeriod, let pendingSuggestions, let groupcallDefaultJoinAs):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1625164883)
|
||||
buffer.appendInt32(1517757976)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(id, buffer: buffer, boxed: false)
|
||||
@ -208,7 +208,7 @@ public extension Api {
|
||||
if Int(flags) & Int(1 << 8) != 0 {stickerset!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 9) != 0 {serializeInt32(availableMinId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 11) != 0 {serializeInt32(folderId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 14) != 0 {serializeInt32(linkedChatId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 14) != 0 {serializeInt64(linkedChatId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 15) != 0 {location!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 17) != 0 {serializeInt32(slowmodeSeconds!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 18) != 0 {serializeInt32(slowmodeNextSendDate!, buffer: buffer, boxed: false)}
|
||||
@ -349,8 +349,8 @@ public extension Api {
|
||||
if Int(_1!) & Int(1 << 9) != 0 {_20 = reader.readInt32() }
|
||||
var _21: Int32?
|
||||
if Int(_1!) & Int(1 << 11) != 0 {_21 = reader.readInt32() }
|
||||
var _22: Int32?
|
||||
if Int(_1!) & Int(1 << 14) != 0 {_22 = reader.readInt32() }
|
||||
var _22: Int64?
|
||||
if Int(_1!) & Int(1 << 14) != 0 {_22 = reader.readInt64() }
|
||||
var _23: Api.ChannelLocation?
|
||||
if Int(_1!) & Int(1 << 15) != 0 {if let signature = reader.readInt32() {
|
||||
_23 = Api.parse(reader, signature: signature) as? Api.ChannelLocation
|
||||
@ -4608,9 +4608,9 @@ public extension Api {
|
||||
case updateUserName(userId: Int64, firstName: String, lastName: String, username: String)
|
||||
case updateUserPhoto(userId: Int64, date: Int32, photo: Api.UserProfilePhoto, previous: Api.Bool)
|
||||
case updateNewEncryptedMessage(message: Api.EncryptedMessage, qts: Int32)
|
||||
case updateEncryptedChatTyping(chatId: Int64)
|
||||
case updateEncryptedChatTyping(chatId: Int32)
|
||||
case updateEncryption(chat: Api.EncryptedChat, date: Int32)
|
||||
case updateEncryptedMessagesRead(chatId: Int64, maxDate: Int32, date: Int32)
|
||||
case updateEncryptedMessagesRead(chatId: Int32, maxDate: Int32, date: Int32)
|
||||
case updateChatParticipantAdd(chatId: Int64, userId: Int64, inviterId: Int64, date: Int32, version: Int32)
|
||||
case updateChatParticipantDelete(chatId: Int64, userId: Int64, version: Int32)
|
||||
case updateDcOptions(dcOptions: [Api.DcOption])
|
||||
@ -4776,9 +4776,9 @@ public extension Api {
|
||||
break
|
||||
case .updateEncryptedChatTyping(let chatId):
|
||||
if boxed {
|
||||
buffer.appendInt32(1677363374)
|
||||
buffer.appendInt32(386986326)
|
||||
}
|
||||
serializeInt64(chatId, buffer: buffer, boxed: false)
|
||||
serializeInt32(chatId, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .updateEncryption(let chat, let date):
|
||||
if boxed {
|
||||
@ -4789,9 +4789,9 @@ public extension Api {
|
||||
break
|
||||
case .updateEncryptedMessagesRead(let chatId, let maxDate, let date):
|
||||
if boxed {
|
||||
buffer.appendInt32(122695484)
|
||||
buffer.appendInt32(956179895)
|
||||
}
|
||||
serializeInt64(chatId, buffer: buffer, boxed: false)
|
||||
serializeInt32(chatId, buffer: buffer, boxed: false)
|
||||
serializeInt32(maxDate, buffer: buffer, boxed: false)
|
||||
serializeInt32(date, buffer: buffer, boxed: false)
|
||||
break
|
||||
@ -5877,8 +5877,8 @@ public extension Api {
|
||||
}
|
||||
}
|
||||
public static func parse_updateEncryptedChatTyping(_ reader: BufferReader) -> Update? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.Update.updateEncryptedChatTyping(chatId: _1!)
|
||||
@ -5904,8 +5904,8 @@ public extension Api {
|
||||
}
|
||||
}
|
||||
public static func parse_updateEncryptedMessagesRead(_ reader: BufferReader) -> Update? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: Int32?
|
||||
|
||||
@ -107,7 +107,9 @@ public class UnauthorizedAccount {
|
||||
|
||||
network.context.performBatchUpdates({
|
||||
var datacenterIds: [Int] = [1, 2]
|
||||
if !testingEnvironment {
|
||||
if testingEnvironment {
|
||||
datacenterIds = [3]
|
||||
} else {
|
||||
datacenterIds.append(contentsOf: [4])
|
||||
}
|
||||
for id in datacenterIds {
|
||||
|
||||
@ -506,8 +506,9 @@ func initializedNetwork(accountId: AccountRecordId, arguments: NetworkInitializa
|
||||
|
||||
if testingEnvironment {
|
||||
seedAddressList = [
|
||||
1: ["149.154.175.10"],
|
||||
2: ["149.154.167.40"]
|
||||
1: ["149.154.175.217"],
|
||||
2: ["149.154.167.226"],
|
||||
3: ["149.154.175.118"]
|
||||
]
|
||||
} else {
|
||||
seedAddressList = [
|
||||
|
||||
@ -1252,7 +1252,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
case let .updateNewEncryptedMessage(message, _):
|
||||
updatedState.addSecretMessages([message])
|
||||
case let .updateEncryptedMessagesRead(chatId, maxDate, date):
|
||||
updatedState.readSecretOutbox(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(chatId)), timestamp: maxDate, actionTimestamp: date)
|
||||
updatedState.readSecretOutbox(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))), timestamp: maxDate, actionTimestamp: date)
|
||||
case let .updateUserTyping(userId, type):
|
||||
if let date = updatesDate, date + 60 > serverTime {
|
||||
let activity = PeerInputActivity(apiType: type, timestamp: date)
|
||||
@ -1290,7 +1290,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
|
||||
}
|
||||
case let .updateEncryptedChatTyping(chatId):
|
||||
if let date = updatesDate, date + 60 > serverTime {
|
||||
updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(chatId)), category: .global), peerId: nil, activity: .typingText)
|
||||
updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))), category: .global), peerId: nil, activity: .typingText)
|
||||
}
|
||||
case let .updateDialogPinned(flags, folderId, peer):
|
||||
let groupId: PeerGroupId = folderId.flatMap(PeerGroupId.init(rawValue:)) ?? .root
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user