mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 03:45:20 +00:00
[codex] Refactor BLE outbound scheduling and Noise queues (#1306)
* Refactor BLE transport event handling * Make image output paths unique * Keep queued Nostr read receipts alive * Refine BLE ingress fanout * Rediscover BLE service after invalidation * Extract BLE notification retry buffer * Extract BLE inbound write buffer * Extract BLE fragment assembly buffer * Tidy secure log handling from device run * Extract BLE outbound fragment scheduler * Harden app CI media tests * Redact BLE message content from logs * Extract BLE Noise session queues * Fix BLE read receipt UI updates * Allow self-authored RSR ingress replies * Harden read receipt queue test timing * Extract BLE outbound policy and incoming file storage * Avoid duplicate BLE link snapshots during send * Canonicalize Nostr relay URLs --------- Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
@@ -11,6 +11,10 @@ private func makeTemporaryFileURL(_ name: String) -> URL {
|
||||
FileManager.default.temporaryDirectory.appendingPathComponent(name)
|
||||
}
|
||||
|
||||
private func makeTemporaryDirectoryURL(_ name: String) -> URL {
|
||||
FileManager.default.temporaryDirectory.appendingPathComponent(name, isDirectory: true)
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
private func makePlatformImage(size: CGSize) -> UIImage {
|
||||
UIGraphicsImageRenderer(size: size).image { context in
|
||||
@@ -55,11 +59,14 @@ struct ImageUtilsTests {
|
||||
@Test
|
||||
func processImage_writesCompressedJpeg() throws {
|
||||
let image = makePlatformImage(size: CGSize(width: 1024, height: 768))
|
||||
let outputURL = try ImageUtils.processImage(image, maxDimension: 256)
|
||||
defer { try? FileManager.default.removeItem(at: outputURL) }
|
||||
let outputDirectory = makeTemporaryDirectoryURL("image-output-\(UUID().uuidString)")
|
||||
defer { try? FileManager.default.removeItem(at: outputDirectory) }
|
||||
|
||||
let outputURL = try ImageUtils.processImage(image, maxDimension: 256, outputDirectory: outputDirectory)
|
||||
|
||||
let data = try Data(contentsOf: outputURL)
|
||||
|
||||
#expect(outputURL.deletingLastPathComponent() == outputDirectory)
|
||||
#expect(outputURL.pathExtension.lowercased() == "jpg")
|
||||
#expect(data.starts(with: Data([0xFF, 0xD8])))
|
||||
#expect(data.count > 0)
|
||||
@@ -68,12 +75,11 @@ struct ImageUtilsTests {
|
||||
@Test
|
||||
func processImage_usesUniqueOutputURLs() throws {
|
||||
let image = makePlatformImage(size: CGSize(width: 64, height: 64))
|
||||
let firstURL = try ImageUtils.processImage(image, maxDimension: 64)
|
||||
let secondURL = try ImageUtils.processImage(image, maxDimension: 64)
|
||||
defer {
|
||||
try? FileManager.default.removeItem(at: firstURL)
|
||||
try? FileManager.default.removeItem(at: secondURL)
|
||||
}
|
||||
let outputDirectory = makeTemporaryDirectoryURL("image-output-\(UUID().uuidString)")
|
||||
defer { try? FileManager.default.removeItem(at: outputDirectory) }
|
||||
|
||||
let firstURL = try ImageUtils.processImage(image, maxDimension: 64, outputDirectory: outputDirectory)
|
||||
let secondURL = try ImageUtils.processImage(image, maxDimension: 64, outputDirectory: outputDirectory)
|
||||
|
||||
#expect(firstURL != secondURL)
|
||||
#expect(FileManager.default.fileExists(atPath: firstURL.path))
|
||||
|
||||
Reference in New Issue
Block a user