mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 21:05:18 +00:00
Remove backwards compatibility code
- Remove timestamp conversion for old clients (seconds vs milliseconds) - Remove fallback for old favorite checking method - All clients must now use millisecond timestamps - Simplifies codebase and reduces potential bugs
This commit is contained in:
@@ -804,19 +804,9 @@ class BluetoothMeshService: NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create stored message with original packet timestamp preserved
|
// Create stored message with original packet timestamp preserved
|
||||||
// Handle both seconds and milliseconds timestamps
|
|
||||||
let timestampInSeconds: TimeInterval
|
|
||||||
if packet.timestamp > 1_000_000_000_000 {
|
|
||||||
// Already in milliseconds
|
|
||||||
timestampInSeconds = TimeInterval(packet.timestamp) / 1000.0
|
|
||||||
} else {
|
|
||||||
// Already in seconds
|
|
||||||
timestampInSeconds = TimeInterval(packet.timestamp)
|
|
||||||
}
|
|
||||||
|
|
||||||
let storedMessage = StoredMessage(
|
let storedMessage = StoredMessage(
|
||||||
packet: packet,
|
packet: packet,
|
||||||
timestamp: Date(timeIntervalSince1970: timestampInSeconds),
|
timestamp: Date(timeIntervalSince1970: TimeInterval(packet.timestamp) / 1000.0), // convert from milliseconds
|
||||||
messageID: messageID,
|
messageID: messageID,
|
||||||
isForFavorite: isForFavorite
|
isForFavorite: isForFavorite
|
||||||
)
|
)
|
||||||
@@ -1053,18 +1043,7 @@ class BluetoothMeshService: NSObject {
|
|||||||
|
|
||||||
// Replay attack protection: Check timestamp is within reasonable window (5 minutes)
|
// Replay attack protection: Check timestamp is within reasonable window (5 minutes)
|
||||||
let currentTime = UInt64(Date().timeIntervalSince1970 * 1000) // milliseconds
|
let currentTime = UInt64(Date().timeIntervalSince1970 * 1000) // milliseconds
|
||||||
|
let timeDiff = abs(Int64(currentTime) - Int64(packet.timestamp))
|
||||||
// Handle both seconds and milliseconds timestamps for compatibility
|
|
||||||
let packetTime: UInt64
|
|
||||||
if packet.timestamp > 1_000_000_000_000 {
|
|
||||||
// Already in milliseconds
|
|
||||||
packetTime = packet.timestamp
|
|
||||||
} else {
|
|
||||||
// Convert seconds to milliseconds
|
|
||||||
packetTime = packet.timestamp * 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
let timeDiff = abs(Int64(currentTime) - Int64(packetTime))
|
|
||||||
if timeDiff > 300000 { // 5 minutes in milliseconds
|
if timeDiff > 300000 { // 5 minutes in milliseconds
|
||||||
print("[SECURITY] Dropping packet with timestamp too far from current time: \(timeDiff/1000) seconds")
|
print("[SECURITY] Dropping packet with timestamp too far from current time: \(timeDiff/1000) seconds")
|
||||||
return
|
return
|
||||||
@@ -1420,10 +1399,6 @@ class BluetoothMeshService: NSObject {
|
|||||||
// Favorite came online
|
// Favorite came online
|
||||||
self.sendCachedMessages(to: senderID)
|
self.sendCachedMessages(to: senderID)
|
||||||
}
|
}
|
||||||
} else if let viewModel = self.delegate as? ChatViewModel,
|
|
||||||
viewModel.isFavorite(peerID: senderID) {
|
|
||||||
// Fallback for backwards compatibility
|
|
||||||
NotificationService.shared.sendFavoriteOnlineNotification(nickname: nickname)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user