Support secret chat layer 144

This commit is contained in:
Ali
2022-07-26 15:38:26 +02:00
parent 079f0cdb00
commit 8f3e7f5a96
13 changed files with 2425 additions and 138 deletions

View File

@@ -812,5 +812,43 @@ public extension TelegramEngine.EngineData.Item {
}
}
}
public struct SecretChatLayer: TelegramEngineDataItem, TelegramEngineMapKeyDataItem, PostboxViewDataItem {
public typealias Result = Int?
fileprivate var id: EnginePeer.Id
public var mapKey: EnginePeer.Id {
return self.id
}
public init(id: EnginePeer.Id) {
self.id = id
}
var key: PostboxViewKey {
return .peerChatState(peerId: self.id)
}
func extract(view: PostboxView) -> Result {
guard let view = view as? PeerChatStateView else {
preconditionFailure()
}
if let peerChatState = view.chatState?.getLegacy() as? SecretChatState {
switch peerChatState.embeddedState {
case .terminated:
return nil
case .handshake:
return nil
case .basicLayer:
return 7
case let .sequenceBasedLayer(secretChatSequenceBasedLayerState):
return Int(secretChatSequenceBasedLayerState.layerNegotiationState.activeLayer.rawValue)
}
} else {
return nil
}
}
}
}
}