mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-02-22 10:33:18 +00:00
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>
27 lines
1.6 KiB
Swift
27 lines
1.6 KiB
Swift
import Foundation
|
|
import Postbox
|
|
import TelegramApi
|
|
|
|
|
|
private func keyFingerprintFromBytes(_ bytes: Buffer) -> Int64 {
|
|
if let memory = bytes.data, bytes.size >= 4 {
|
|
var fingerprint: Int64 = 0
|
|
memcpy(&fingerprint, memory, 8)
|
|
return fingerprint
|
|
}
|
|
return 0
|
|
}
|
|
|
|
extension SecretChatIncomingEncryptedOperation {
|
|
convenience init(message: Api.EncryptedMessage) {
|
|
switch message {
|
|
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(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)
|
|
}
|
|
}
|
|
}
|