Add object detection, tracking, mobile notifications, and search to any security camera.
deslop
roryclearcfd7423e1d07
diff --git a/clearcam/FileServer.m b/clearcam/FileServer.mindex 5e9968b..0cb33fa 100644--- a/clearcam/FileServer.m+++ b/clearcam/FileServer.m@@ -886,7 +886,7 @@// Save the context after deletionNSError *saveError = nil;- if (![context save:&saveError]) NSLog(@"Failed to delete DayEntity and EventEntity objects: %@", saveError.localizedDescription);+ [context save:&saveError];}diff --git a/clearcam/GalleryViewController.m b/clearcam/GalleryViewController.mindex e555bc9..9ea45f3 100644--- a/clearcam/GalleryViewController.m+++ b/clearcam/GalleryViewController.m@@ -434,7 +434,7 @@NSString *fileName = [[aesFileURL lastPathComponent] stringByDeletingPathExtension];NSString *keyPrefix = [userProvidedKey substringToIndex:MIN(6, userProvidedKey.length)];NSString *keyIdentifier = [NSString stringWithFormat:@"decryption_key_%@_%@", fileName, keyPrefix];- if (![[SecretManager sharedManager] saveDecryptionKey:userProvidedKey withIdentifier:keyIdentifier error:&saveError]) NSLog(@"Failed to save key to SecretManager: %@", saveError.localizedDescription);+ [[SecretManager sharedManager] saveDecryptionKey:userProvidedKey withIdentifier:keyIdentifier error:&saveError];NSURL *decryptedURL = [self handleDecryptedData:decryptedData fromURL:aesFileURL];if (decryptedURL) {// Reload the table view to reflect the decrypted state@@ -616,9 +616,7 @@[actionSheet addAction:[UIAlertAction actionWithTitle:@"Delete"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction * _Nonnull action) {- NSString *sessionToken = [[StoreManager sharedInstance] retrieveSessionTokenFromKeychain];- if (!sessionToken) NSLog(@"No session token found in Keychain. Proceeding with local deletion only.");-+ NSString *sessionToken = [[StoreManager sharedInstance] retrieveSessionTokenFromKeychain];NSError *localError;NSFileManager *fileManager = [NSFileManager defaultManager];diff --git a/clearcam/Notification.m b/clearcam/Notification.mindex d661c6f..becc654 100644--- a/clearcam/Notification.m+++ b/clearcam/Notification.m@@ -74,58 +74,33 @@imageData = encryptedData;}- // Retrieve session tokenNSString *sessionToken = [[StoreManager sharedInstance] retrieveSessionTokenFromKeychain];- if (!sessionToken) {- NSLog(@"β No session token available");- return;- }-- // Calculate file size (in bytes)+ if (!sessionToken) return;NSUInteger fileSize = [imageData length];-- // πΉ STEP 1: Request a Presigned R2 URL from the ServerNSURLComponents *components = [NSURLComponents componentsWithString:[server stringByAppendingString:@"/upload"]];NSURLQueryItem *fileItem = [NSURLQueryItem queryItemWithName:@"filename" value:fileName];NSURLQueryItem *sessionItem = [NSURLQueryItem queryItemWithName:@"session_token" value:sessionToken];NSURLQueryItem *sizeItem = [NSURLQueryItem queryItemWithName:@"size" value:[NSString stringWithFormat:@"%lu", (unsigned long)fileSize]];- components.queryItems = @[fileItem, sessionItem, sizeItem]; // Include filename, session_token, and size+ components.queryItems = @[fileItem, sessionItem, sizeItem];NSURL *uploadRequestURL = components.URL;NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:uploadRequestURL];[request setHTTPMethod:@"GET"];NSURLSessionDataTask *uploadTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {- if (error) {- NSLog(@"β Server request failed: %@", error.localizedDescription);- return;- }-+ if (error) return;NSError *jsonError;NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];- if (jsonError || !responseDict[@"url"]) {- NSLog(@"β Failed to parse server response or missing URL");- return;- }-- NSString *presignedR2URL = responseDict[@"url"]; // π₯ URL for R2 upload-- // πΉ STEP 2: Upload the File to Cloudflare R2+ if (jsonError || !responseDict[@"url"]) return;+ NSString *presignedR2URL = responseDict[@"url"];NSMutableURLRequest *r2Request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:presignedR2URL]];[r2Request setHTTPMethod:@"PUT"];[r2Request setValue:@"application/octet-stream" forHTTPHeaderField:@"Content-Type"];[r2Request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)fileSize] forHTTPHeaderField:@"Content-Length"]; // Add Content-Length headerNSURLSessionUploadTask *r2UploadTask = [[NSURLSession sharedSession] uploadTaskWithRequest:r2Request fromData:imageData completionHandler:^(NSData *r2Data, NSURLResponse *r2Response, NSError *r2Error) {- if (r2Error) {- NSLog(@"β R2 upload failed: %@", r2Error.localizedDescription);- } else {+ if (!r2Error) {NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)r2Response;- if (httpResponse.statusCode == 200) {- NSLog(@"β Successfully uploaded to Cloudflare R2!");- } else {- NSLog(@"β R2 upload failed with HTTP %ld", (long)httpResponse.statusCode);- }}}];