mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Refactor Api types 90-99 to use struct-wrapped constructors
Types refactored (file-grouped parallel approach): - encrypted* (Chat, ChatDiscarded, ChatEmpty, ChatRequested, ChatWaiting, File, Message, MessageService) - chatInviteExported - exported* (ChatlistInvite, ContactToken, MessageLink, StoryLink) - factCheck Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a78b2c0db2
commit
ac019b15c5
13 changed files with 252 additions and 41 deletions
|
|
@ -1,6 +1,12 @@
|
|||
public extension Api {
|
||||
enum EmojiURL: TypeConstructorDescription {
|
||||
case emojiURL(url: String)
|
||||
public class Cons_emojiURL {
|
||||
public var url: String
|
||||
public init(url: String) {
|
||||
self.url = url
|
||||
}
|
||||
}
|
||||
case emojiURL(Cons_emojiURL)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -29,11 +35,77 @@ public extension Api {
|
|||
}
|
||||
public extension Api {
|
||||
enum EncryptedChat: TypeConstructorDescription {
|
||||
case encryptedChat(id: Int32, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, gAOrB: Buffer, keyFingerprint: Int64)
|
||||
case encryptedChatDiscarded(flags: Int32, id: Int32)
|
||||
case encryptedChatEmpty(id: Int32)
|
||||
case encryptedChatRequested(flags: Int32, folderId: Int32?, id: Int32, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, gA: Buffer)
|
||||
case encryptedChatWaiting(id: Int32, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64)
|
||||
public class Cons_encryptedChat {
|
||||
public var id: Int32
|
||||
public var accessHash: Int64
|
||||
public var date: Int32
|
||||
public var adminId: Int64
|
||||
public var participantId: Int64
|
||||
public var gAOrB: Buffer
|
||||
public var keyFingerprint: Int64
|
||||
public init(id: Int32, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, gAOrB: Buffer, keyFingerprint: Int64) {
|
||||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
self.date = date
|
||||
self.adminId = adminId
|
||||
self.participantId = participantId
|
||||
self.gAOrB = gAOrB
|
||||
self.keyFingerprint = keyFingerprint
|
||||
}
|
||||
}
|
||||
public class Cons_encryptedChatDiscarded {
|
||||
public var flags: Int32
|
||||
public var id: Int32
|
||||
public init(flags: Int32, id: Int32) {
|
||||
self.flags = flags
|
||||
self.id = id
|
||||
}
|
||||
}
|
||||
public class Cons_encryptedChatEmpty {
|
||||
public var id: Int32
|
||||
public init(id: Int32) {
|
||||
self.id = id
|
||||
}
|
||||
}
|
||||
public class Cons_encryptedChatRequested {
|
||||
public var flags: Int32
|
||||
public var folderId: Int32?
|
||||
public var id: Int32
|
||||
public var accessHash: Int64
|
||||
public var date: Int32
|
||||
public var adminId: Int64
|
||||
public var participantId: Int64
|
||||
public var gA: Buffer
|
||||
public init(flags: Int32, folderId: Int32?, id: Int32, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, gA: Buffer) {
|
||||
self.flags = flags
|
||||
self.folderId = folderId
|
||||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
self.date = date
|
||||
self.adminId = adminId
|
||||
self.participantId = participantId
|
||||
self.gA = gA
|
||||
}
|
||||
}
|
||||
public class Cons_encryptedChatWaiting {
|
||||
public var id: Int32
|
||||
public var accessHash: Int64
|
||||
public var date: Int32
|
||||
public var adminId: Int64
|
||||
public var participantId: Int64
|
||||
public init(id: Int32, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64) {
|
||||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
self.date = date
|
||||
self.adminId = adminId
|
||||
self.participantId = participantId
|
||||
}
|
||||
}
|
||||
case encryptedChat(Cons_encryptedChat)
|
||||
case encryptedChatDiscarded(Cons_encryptedChatDiscarded)
|
||||
case encryptedChatEmpty(Cons_encryptedChatEmpty)
|
||||
case encryptedChatRequested(Cons_encryptedChatRequested)
|
||||
case encryptedChatWaiting(Cons_encryptedChatWaiting)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -90,7 +162,21 @@ public extension Api {
|
|||
}
|
||||
public extension Api {
|
||||
enum EncryptedFile: TypeConstructorDescription {
|
||||
case encryptedFile(id: Int64, accessHash: Int64, size: Int64, dcId: Int32, keyFingerprint: Int32)
|
||||
public class Cons_encryptedFile {
|
||||
public var id: Int64
|
||||
public var accessHash: Int64
|
||||
public var size: Int64
|
||||
public var dcId: Int32
|
||||
public var keyFingerprint: Int32
|
||||
public init(id: Int64, accessHash: Int64, size: Int64, dcId: Int32, keyFingerprint: Int32) {
|
||||
self.id = id
|
||||
self.accessHash = accessHash
|
||||
self.size = size
|
||||
self.dcId = dcId
|
||||
self.keyFingerprint = keyFingerprint
|
||||
}
|
||||
}
|
||||
case encryptedFile(Cons_encryptedFile)
|
||||
case encryptedFileEmpty
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
|
|
@ -127,8 +213,34 @@ public extension Api {
|
|||
}
|
||||
public extension Api {
|
||||
enum EncryptedMessage: TypeConstructorDescription {
|
||||
case encryptedMessage(randomId: Int64, chatId: Int32, date: Int32, bytes: Buffer, file: Api.EncryptedFile)
|
||||
case encryptedMessageService(randomId: Int64, chatId: Int32, date: Int32, bytes: Buffer)
|
||||
public class Cons_encryptedMessage {
|
||||
public var randomId: Int64
|
||||
public var chatId: Int32
|
||||
public var date: Int32
|
||||
public var bytes: Buffer
|
||||
public var file: Api.EncryptedFile
|
||||
public init(randomId: Int64, chatId: Int32, date: Int32, bytes: Buffer, file: Api.EncryptedFile) {
|
||||
self.randomId = randomId
|
||||
self.chatId = chatId
|
||||
self.date = date
|
||||
self.bytes = bytes
|
||||
self.file = file
|
||||
}
|
||||
}
|
||||
public class Cons_encryptedMessageService {
|
||||
public var randomId: Int64
|
||||
public var chatId: Int32
|
||||
public var date: Int32
|
||||
public var bytes: Buffer
|
||||
public init(randomId: Int64, chatId: Int32, date: Int32, bytes: Buffer) {
|
||||
self.randomId = randomId
|
||||
self.chatId = chatId
|
||||
self.date = date
|
||||
self.bytes = bytes
|
||||
}
|
||||
}
|
||||
case encryptedMessage(Cons_encryptedMessage)
|
||||
case encryptedMessageService(Cons_encryptedMessageService)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -164,7 +276,35 @@ public extension Api {
|
|||
}
|
||||
public extension Api {
|
||||
enum ExportedChatInvite: TypeConstructorDescription {
|
||||
case chatInviteExported(flags: Int32, link: String, adminId: Int64, date: Int32, startDate: Int32?, expireDate: Int32?, usageLimit: Int32?, usage: Int32?, requested: Int32?, subscriptionExpired: Int32?, title: String?, subscriptionPricing: Api.StarsSubscriptionPricing?)
|
||||
public class Cons_chatInviteExported {
|
||||
public var flags: Int32
|
||||
public var link: String
|
||||
public var adminId: Int64
|
||||
public var date: Int32
|
||||
public var startDate: Int32?
|
||||
public var expireDate: Int32?
|
||||
public var usageLimit: Int32?
|
||||
public var usage: Int32?
|
||||
public var requested: Int32?
|
||||
public var subscriptionExpired: Int32?
|
||||
public var title: String?
|
||||
public var subscriptionPricing: Api.StarsSubscriptionPricing?
|
||||
public init(flags: Int32, link: String, adminId: Int64, date: Int32, startDate: Int32?, expireDate: Int32?, usageLimit: Int32?, usage: Int32?, requested: Int32?, subscriptionExpired: Int32?, title: String?, subscriptionPricing: Api.StarsSubscriptionPricing?) {
|
||||
self.flags = flags
|
||||
self.link = link
|
||||
self.adminId = adminId
|
||||
self.date = date
|
||||
self.startDate = startDate
|
||||
self.expireDate = expireDate
|
||||
self.usageLimit = usageLimit
|
||||
self.usage = usage
|
||||
self.requested = requested
|
||||
self.subscriptionExpired = subscriptionExpired
|
||||
self.title = title
|
||||
self.subscriptionPricing = subscriptionPricing
|
||||
}
|
||||
}
|
||||
case chatInviteExported(Cons_chatInviteExported)
|
||||
case chatInvitePublicJoinRequests
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
|
|
@ -201,7 +341,19 @@ public extension Api {
|
|||
}
|
||||
public extension Api {
|
||||
enum ExportedChatlistInvite: TypeConstructorDescription {
|
||||
case exportedChatlistInvite(flags: Int32, title: String, url: String, peers: [Api.Peer])
|
||||
public class Cons_exportedChatlistInvite {
|
||||
public var flags: Int32
|
||||
public var title: String
|
||||
public var url: String
|
||||
public var peers: [Api.Peer]
|
||||
public init(flags: Int32, title: String, url: String, peers: [Api.Peer]) {
|
||||
self.flags = flags
|
||||
self.title = title
|
||||
self.url = url
|
||||
self.peers = peers
|
||||
}
|
||||
}
|
||||
case exportedChatlistInvite(Cons_exportedChatlistInvite)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -230,7 +382,15 @@ public extension Api {
|
|||
}
|
||||
public extension Api {
|
||||
enum ExportedContactToken: TypeConstructorDescription {
|
||||
case exportedContactToken(url: String, expires: Int32)
|
||||
public class Cons_exportedContactToken {
|
||||
public var url: String
|
||||
public var expires: Int32
|
||||
public init(url: String, expires: Int32) {
|
||||
self.url = url
|
||||
self.expires = expires
|
||||
}
|
||||
}
|
||||
case exportedContactToken(Cons_exportedContactToken)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -259,7 +419,15 @@ public extension Api {
|
|||
}
|
||||
public extension Api {
|
||||
enum ExportedMessageLink: TypeConstructorDescription {
|
||||
case exportedMessageLink(link: String, html: String)
|
||||
public class Cons_exportedMessageLink {
|
||||
public var link: String
|
||||
public var html: String
|
||||
public init(link: String, html: String) {
|
||||
self.link = link
|
||||
self.html = html
|
||||
}
|
||||
}
|
||||
case exportedMessageLink(Cons_exportedMessageLink)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -288,7 +456,13 @@ public extension Api {
|
|||
}
|
||||
public extension Api {
|
||||
enum ExportedStoryLink: TypeConstructorDescription {
|
||||
case exportedStoryLink(link: String)
|
||||
public class Cons_exportedStoryLink {
|
||||
public var link: String
|
||||
public init(link: String) {
|
||||
self.link = link
|
||||
}
|
||||
}
|
||||
case exportedStoryLink(Cons_exportedStoryLink)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
@ -317,7 +491,19 @@ public extension Api {
|
|||
}
|
||||
public extension Api {
|
||||
enum FactCheck: TypeConstructorDescription {
|
||||
case factCheck(flags: Int32, country: String?, text: Api.TextWithEntities?, hash: Int64)
|
||||
public class Cons_factCheck {
|
||||
public var flags: Int32
|
||||
public var country: String?
|
||||
public var text: Api.TextWithEntities?
|
||||
public var hash: Int64
|
||||
public init(flags: Int32, country: String?, text: Api.TextWithEntities?, hash: Int64) {
|
||||
self.flags = flags
|
||||
self.country = country
|
||||
self.text = text
|
||||
self.hash = hash
|
||||
}
|
||||
}
|
||||
case factCheck(Cons_factCheck)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
#if DEBUG
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import TelegramApi
|
|||
extension ExportedInvitation {
|
||||
init(apiExportedInvite: Api.ExportedChatInvite) {
|
||||
switch apiExportedInvite {
|
||||
case let .chatInviteExported(flags, link, adminId, date, startDate, expireDate, usageLimit, usage, requested, subscriptionExpired, title, pricing):
|
||||
case let .chatInviteExported(chatInviteExportedData):
|
||||
let (flags, link, adminId, date, startDate, expireDate, usageLimit, usage, requested, subscriptionExpired, title, pricing) = (chatInviteExportedData.flags, chatInviteExportedData.link, chatInviteExportedData.adminId, chatInviteExportedData.date, chatInviteExportedData.startDate, chatInviteExportedData.expireDate, chatInviteExportedData.usageLimit, chatInviteExportedData.usage, chatInviteExportedData.requested, chatInviteExportedData.subscriptionExpired, chatInviteExportedData.title, chatInviteExportedData.subscriptionPricing)
|
||||
let _ = subscriptionExpired
|
||||
self = .link(link: link, title: title, isPermanent: (flags & (1 << 5)) != 0, requestApproval: (flags & (1 << 6)) != 0, isRevoked: (flags & (1 << 0)) != 0, adminId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(adminId)), date: date, startDate: startDate, expireDate: expireDate, usageLimit: usageLimit, count: usage, requestedCount: requested, pricing: pricing.flatMap { StarsSubscriptionPricing(apiStarsSubscriptionPricing: $0) })
|
||||
case .chatInvitePublicJoinRequests:
|
||||
|
|
|
|||
|
|
@ -1037,7 +1037,8 @@ extension StoreMessage {
|
|||
|
||||
if let factCheck {
|
||||
switch factCheck {
|
||||
case let .factCheck(_, country, text, hash):
|
||||
case let .factCheck(factCheckData):
|
||||
let (_, country, text, hash) = (factCheckData.flags, factCheckData.country, factCheckData.text, factCheckData.hash)
|
||||
let content: FactCheckMessageAttribute.Content
|
||||
if let text, let country {
|
||||
switch text {
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ public func standaloneUploadedImage(postbox: Postbox, network: Network, peerId:
|
|||
}
|
||||
|> mapToSignal { result -> Signal<StandaloneUploadMediaEvent, StandaloneUploadMediaError> in
|
||||
switch result {
|
||||
case let .encryptedFile(id, accessHash, size, dcId, _):
|
||||
case let .encryptedFile(encryptedFileData):
|
||||
let (id, accessHash, size, dcId) = (encryptedFileData.id, encryptedFileData.accessHash, encryptedFileData.size, encryptedFileData.dcId)
|
||||
return .single(.result(.media(.standalone(media: TelegramMediaImage(imageId: MediaId(namespace: Namespaces.Media.LocalImage, id: Int64.random(in: Int64.min ... Int64.max)), representations: [TelegramMediaImageRepresentation(dimensions: dimensions, resource: SecretFileMediaResource(fileId: id, accessHash: accessHash, containerSize: size, decryptedSize: Int64(data.count), datacenterId: Int(dcId), key: key), progressiveSizes: [], immediateThumbnailData: nil, hasVideo: false, isPersonal: false)], immediateThumbnailData: nil, reference: nil, partialReference: nil, flags: [])))))
|
||||
case .encryptedFileEmpty:
|
||||
return .fail(.generic)
|
||||
|
|
@ -193,7 +194,8 @@ public func standaloneUploadedFile(postbox: Postbox, network: Network, peerId: P
|
|||
|> mapError { _ -> StandaloneUploadMediaError in return .generic }
|
||||
|> mapToSignal { result -> Signal<StandaloneUploadMediaEvent, StandaloneUploadMediaError> in
|
||||
switch result {
|
||||
case let .encryptedFile(id, accessHash, size, dcId, _):
|
||||
case let .encryptedFile(encryptedFileData):
|
||||
let (id, accessHash, size, dcId) = (encryptedFileData.id, encryptedFileData.accessHash, encryptedFileData.size, encryptedFileData.dcId)
|
||||
let media = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: Int64.random(in: Int64.min ... Int64.max)), partialReference: nil, resource: SecretFileMediaResource(fileId: id, accessHash: accessHash, containerSize: size, decryptedSize: size, datacenterId: Int(dcId), key: key), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: mimeType, size: size, attributes: attributes, alternativeRepresentations: [])
|
||||
|
||||
return .single(.result(.media(.standalone(media: media))))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import TelegramApi
|
|||
extension SecretChatFileReference {
|
||||
convenience init?(_ file: Api.EncryptedFile) {
|
||||
switch file {
|
||||
case let .encryptedFile(id, accessHash, size, dcId, keyFingerprint):
|
||||
case let .encryptedFile(encryptedFileData):
|
||||
let (id, accessHash, size, dcId, keyFingerprint) = (encryptedFileData.id, encryptedFileData.accessHash, encryptedFileData.size, encryptedFileData.dcId, encryptedFileData.keyFingerprint)
|
||||
self.init(id: id, accessHash: accessHash, size: size, datacenterId: dcId, keyFingerprint: keyFingerprint)
|
||||
case .encryptedFileEmpty:
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@ private func keyFingerprintFromBytes(_ bytes: Buffer) -> Int64 {
|
|||
extension SecretChatIncomingEncryptedOperation {
|
||||
convenience init(message: Api.EncryptedMessage) {
|
||||
switch message {
|
||||
case let .encryptedMessage(randomId, chatId, date, bytes, file):
|
||||
case let .encryptedMessage(encryptedMessageData):
|
||||
let (randomId, chatId, date, bytes, file) = (encryptedMessageData.randomId, encryptedMessageData.chatId, encryptedMessageData.date, encryptedMessageData.bytes, encryptedMessageData.file)
|
||||
self.init(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))), globallyUniqueId: randomId, timestamp: date, type: .message, keyFingerprint: keyFingerprintFromBytes(bytes), contents: MemoryBuffer(bytes), mediaFileReference: SecretChatFileReference(file))
|
||||
case let .encryptedMessageService(randomId, chatId, date, bytes):
|
||||
case let .encryptedMessageService(encryptedMessageServiceData):
|
||||
let (randomId, chatId, date, bytes) = (encryptedMessageServiceData.randomId, encryptedMessageServiceData.chatId, encryptedMessageServiceData.date, encryptedMessageServiceData.bytes)
|
||||
self.init(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))), globallyUniqueId: randomId, timestamp: date, type: .service, keyFingerprint: keyFingerprintFromBytes(bytes), contents: MemoryBuffer(bytes), mediaFileReference: nil)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
|
|||
let settings = transaction.getPreferencesEntry(key: PreferencesKeys.secretChatSettings)?.get(SecretChatSettings.self) ?? SecretChatSettings.defaultSettings
|
||||
assert((currentPeer == nil) == (currentState == nil))
|
||||
switch chat {
|
||||
case let .encryptedChat(_, _, _, adminId, _, gAOrB, _):
|
||||
case let .encryptedChat(encryptedChatData):
|
||||
let (adminId, gAOrB) = (encryptedChatData.adminId, encryptedChatData.gAOrB)
|
||||
if let currentPeer = currentPeer, let currentState = currentState, adminId == accountPeerId.id._internalGetInt64Value() {
|
||||
if case let .handshake(handshakeState) = currentState.embeddedState, case let .requested(_, p, a) = handshakeState {
|
||||
let pData = p.makeData()
|
||||
|
|
@ -67,7 +68,8 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
|
|||
} else {
|
||||
Logger.shared.log("State", "got encryptedChat, but peer or state don't exist or account is not creator")
|
||||
}
|
||||
case let .encryptedChatDiscarded(flags, _):
|
||||
case let .encryptedChatDiscarded(encryptedChatDiscardedData):
|
||||
let flags = encryptedChatDiscardedData.flags
|
||||
if let currentPeer = currentPeer, let currentState = currentState {
|
||||
let isRemoved = (flags & (1 << 0)) != 0
|
||||
|
||||
|
|
@ -86,9 +88,10 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
|
|||
} else {
|
||||
Logger.shared.log("State", "got encryptedChatDiscarded, but peer doesn't exist")
|
||||
}
|
||||
case .encryptedChatEmpty(_):
|
||||
case .encryptedChatEmpty:
|
||||
break
|
||||
case let .encryptedChatRequested(_, folderId, _, accessHash, date, adminId, participantId, gA):
|
||||
case let .encryptedChatRequested(encryptedChatRequestedData):
|
||||
let (folderId, accessHash, date, adminId, participantId, gA) = (encryptedChatRequestedData.folderId, encryptedChatRequestedData.accessHash, encryptedChatRequestedData.date, encryptedChatRequestedData.adminId, encryptedChatRequestedData.participantId, encryptedChatRequestedData.gA)
|
||||
if currentPeer == nil && participantId == accountPeerId.id._internalGetInt64Value() {
|
||||
if settings.acceptOnThisDevice {
|
||||
let state = SecretChatState(role: .participant, embeddedState: .handshake(.accepting), keychain: SecretChatKeychain(keys: []), keyFingerprint: nil, messageAutoremoveTimeout: nil)
|
||||
|
|
@ -122,7 +125,8 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee
|
|||
} else {
|
||||
Logger.shared.log("State", "got encryptedChatRequested, but peer already exists or this account is creator")
|
||||
}
|
||||
case let .encryptedChatWaiting(_, accessHash, date, adminId, participantId):
|
||||
case let .encryptedChatWaiting(encryptedChatWaitingData):
|
||||
let (accessHash, date, adminId, participantId) = (encryptedChatWaitingData.accessHash, encryptedChatWaitingData.date, encryptedChatWaitingData.adminId, encryptedChatWaitingData.participantId)
|
||||
if let requestData = requestData, currentPeer == nil && adminId == accountPeerId.id._internalGetInt64Value() {
|
||||
let state = SecretChatState(role: .creator, embeddedState: .handshake(.requested(g: requestData.g, p: requestData.p, a: requestData.a)), keychain: SecretChatKeychain(keys: []), keyFingerprint: nil, messageAutoremoveTimeout: nil)
|
||||
let peer = TelegramSecretChat(id: chat.peerId, creationDate: date, regularPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(participantId)), accessHash: accessHash, role: state.role, embeddedState: state.embeddedState.peerState, messageAutoremoveTimeout: nil)
|
||||
|
|
|
|||
|
|
@ -606,15 +606,20 @@ extension Api.Updates {
|
|||
extension Api.EncryptedChat {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .encryptedChat(id, _, _, _, _, _, _):
|
||||
case let .encryptedChat(encryptedChatData):
|
||||
let id = encryptedChatData.id
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id)))
|
||||
case let .encryptedChatDiscarded(_, id):
|
||||
case let .encryptedChatDiscarded(encryptedChatDiscardedData):
|
||||
let id = encryptedChatDiscardedData.id
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id)))
|
||||
case let .encryptedChatEmpty(id):
|
||||
case let .encryptedChatEmpty(encryptedChatEmptyData):
|
||||
let id = encryptedChatEmptyData.id
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id)))
|
||||
case let .encryptedChatRequested(_, _, id, _, _, _, _, _):
|
||||
case let .encryptedChatRequested(encryptedChatRequestedData):
|
||||
let id = encryptedChatRequestedData.id
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id)))
|
||||
case let .encryptedChatWaiting(id, _, _, _, _):
|
||||
case let .encryptedChatWaiting(encryptedChatWaitingData):
|
||||
let id = encryptedChatWaitingData.id
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id)))
|
||||
}
|
||||
}
|
||||
|
|
@ -623,9 +628,11 @@ extension Api.EncryptedChat {
|
|||
extension Api.EncryptedMessage {
|
||||
var peerId: PeerId {
|
||||
switch self {
|
||||
case let .encryptedMessage(_, chatId, _, _, _):
|
||||
case let .encryptedMessage(encryptedMessageData):
|
||||
let chatId = encryptedMessageData.chatId
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId)))
|
||||
case let .encryptedMessageService(_, chatId, _, _):
|
||||
case let .encryptedMessageService(encryptedMessageServiceData):
|
||||
let chatId = encryptedMessageServiceData.chatId
|
||||
return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId)))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ public func _internal_exportMessageLink(postbox: Postbox, network: Network, peer
|
|||
return network.request(Api.functions.channels.exportMessageLink(flags: flags, channel: input, id: sourceMessageId.id)) |> mapError { _ in return }
|
||||
|> map { res in
|
||||
switch res {
|
||||
case let .exportedMessageLink(link, _):
|
||||
case let .exportedMessageLink(exportedMessageLinkData):
|
||||
let (link, _) = (exportedMessageLinkData.link, exportedMessageLinkData.html)
|
||||
return link
|
||||
}
|
||||
} |> `catch` { _ -> Signal<String?, NoError> in
|
||||
|
|
|
|||
|
|
@ -96,7 +96,8 @@ func _internal_getMessagesFactCheckByPeerId(account: Account, peerId: EnginePeer
|
|||
for result in results {
|
||||
let messageId = messageIds[index]
|
||||
switch result {
|
||||
case let .factCheck(_, country, text, hash):
|
||||
case let .factCheck(factCheckData):
|
||||
let (_, country, text, hash) = (factCheckData.flags, factCheckData.country, factCheckData.text, factCheckData.hash)
|
||||
let content: FactCheckMessageAttribute.Content
|
||||
if let text, let country {
|
||||
switch text {
|
||||
|
|
|
|||
|
|
@ -2588,7 +2588,8 @@ func _internal_exportStoryLink(account: Account, peerId: EnginePeer.Id, id: Int3
|
|||
return nil
|
||||
}
|
||||
switch result {
|
||||
case let .exportedStoryLink(link):
|
||||
case let .exportedStoryLink(exportedStoryLinkData):
|
||||
let link = exportedStoryLinkData.link
|
||||
return link
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,8 @@ func _internal_exportChatFolder(account: Account, filterId: Int32, title: String
|
|||
})
|
||||
|
||||
switch invite {
|
||||
case let .exportedChatlistInvite(flags, title, url, peers):
|
||||
case let .exportedChatlistInvite(exportedChatlistInviteData):
|
||||
let (flags, title, url, peers) = (exportedChatlistInviteData.flags, exportedChatlistInviteData.title, exportedChatlistInviteData.url, exportedChatlistInviteData.peers)
|
||||
return .single(ExportedChatFolderLink(
|
||||
title: title,
|
||||
link: url,
|
||||
|
|
@ -172,7 +173,8 @@ func _internal_getExportedChatFolderLinks(account: Account, id: Int32) -> Signal
|
|||
var result: [ExportedChatFolderLink] = []
|
||||
for invite in invites {
|
||||
switch invite {
|
||||
case let .exportedChatlistInvite(flags, title, url, peers):
|
||||
case let .exportedChatlistInvite(exportedChatlistInviteData):
|
||||
let (flags, title, url, peers) = (exportedChatlistInviteData.flags, exportedChatlistInviteData.title, exportedChatlistInviteData.url, exportedChatlistInviteData.peers)
|
||||
result.append(ExportedChatFolderLink(
|
||||
title: title,
|
||||
link: url,
|
||||
|
|
@ -212,7 +214,8 @@ func _internal_editChatFolderLink(account: Account, filterId: Int32, link: Expor
|
|||
}
|
||||
|> map { result in
|
||||
switch result {
|
||||
case let .exportedChatlistInvite(flags, title, url, peers):
|
||||
case let .exportedChatlistInvite(exportedChatlistInviteData):
|
||||
let (flags, title, url, peers) = (exportedChatlistInviteData.flags, exportedChatlistInviteData.title, exportedChatlistInviteData.url, exportedChatlistInviteData.peers)
|
||||
return ExportedChatFolderLink(
|
||||
title: title,
|
||||
link: url,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ func _internal_exportContactToken(account: Account) -> Signal<ExportedContactTok
|
|||
return .single(nil)
|
||||
}
|
||||
|> map { result -> ExportedContactToken? in
|
||||
if let result = result, case let .exportedContactToken(url, expires) = result {
|
||||
if let result = result, case let .exportedContactToken(exportedContactTokenData) = result {
|
||||
let (url, expires) = (exportedContactTokenData.url, exportedContactTokenData.expires)
|
||||
return ExportedContactToken(url: url, expires: expires)
|
||||
} else {
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue