feat: Introduce system accounts and verification badges
- Added SystemAccounts enum to manage system account keys and titles. - Refactored Dialog model to replace isVerified with verified level. - Implemented effective verification logic for UI display in Dialog. - Updated DialogRepository to handle user verification levels. - Enhanced ProtocolManager and SessionManager to log user info with verification. - Modified AuthCoordinator to support back navigation to unlock screen. - Improved UnlockView and WelcomeView with new account creation flow. - Added VerifiedBadge component to visually represent account verification levels. - Updated ChatListView and SearchView to display verification badges for users. - Cleaned up debug print statements across various components.
This commit is contained in:
@@ -176,22 +176,25 @@ final class ProtocolManager: @unchecked Sendable {
|
||||
// MARK: - Packet Handling
|
||||
|
||||
private func handleIncomingData(_ data: Data) {
|
||||
print("[Protocol] Incoming data: \(data.count) bytes, first bytes: \(data.prefix(min(8, data.count)).map { String(format: "%02x", $0) }.joined(separator: " "))")
|
||||
#if DEBUG
|
||||
if data.count >= 2 {
|
||||
let peekStream = Stream(data: data)
|
||||
let rawId = peekStream.readInt16()
|
||||
Self.logger.debug("📥 Incoming packet 0x\(String(rawId, radix: 16)), size: \(data.count)")
|
||||
}
|
||||
#endif
|
||||
|
||||
guard let (packetId, packet) = PacketRegistry.decode(from: data) else {
|
||||
// Try to read the packet ID manually to see what it is
|
||||
#if DEBUG
|
||||
if data.count >= 2 {
|
||||
let stream = Stream(data: data)
|
||||
let rawId = stream.readInt16()
|
||||
print("[Protocol] Unknown packet ID: 0x\(String(rawId, radix: 16)) (\(rawId)), data size: \(data.count)")
|
||||
} else {
|
||||
print("[Protocol] Packet too small: \(data.count) bytes")
|
||||
Self.logger.debug("Unknown packet ID: 0x\(String(rawId, radix: 16)), size: \(data.count)")
|
||||
}
|
||||
#endif
|
||||
return
|
||||
}
|
||||
|
||||
print("[Protocol] Received packet 0x\(String(packetId, radix: 16)) (\(type(of: packet)))")
|
||||
|
||||
switch packetId {
|
||||
case 0x00:
|
||||
if let p = packet as? PacketHandshake {
|
||||
@@ -199,17 +202,15 @@ final class ProtocolManager: @unchecked Sendable {
|
||||
}
|
||||
case 0x01:
|
||||
if let p = packet as? PacketUserInfo {
|
||||
print("[Protocol] UserInfo received: username='\(p.username)', title='\(p.title)'")
|
||||
onUserInfoReceived?(p)
|
||||
}
|
||||
case 0x02:
|
||||
if let p = packet as? PacketResult {
|
||||
let code = ResultCode(rawValue: p.resultCode)
|
||||
print("[Protocol] Result received: code=\(p.resultCode) (\(code.map { "\($0)" } ?? "unknown"))")
|
||||
let _ = ResultCode(rawValue: p.resultCode)
|
||||
}
|
||||
case 0x03:
|
||||
if let p = packet as? PacketSearch {
|
||||
print("[Protocol] Search result received: \(p.users.count) users")
|
||||
Self.logger.debug("📥 Search result: \(p.users.count) users, callback=\(self.onSearchResult != nil)")
|
||||
onSearchResult?(p)
|
||||
}
|
||||
case 0x05:
|
||||
|
||||
Reference in New Issue
Block a user