π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat(photos): update memory share link payload and token parsing
AmanRajSinghMourya730a4265a6b4
diff --git a/mobile/apps/photos/lib/services/memory_share_service.dart b/mobile/apps/photos/lib/services/memory_share_service.dartindex e47491ac07..604a98b3f9 100644--- a/mobile/apps/photos/lib/services/memory_share_service.dart+++ b/mobile/apps/photos/lib/services/memory_share_service.dart@@ -36,6 +36,11 @@ class MemoryShareService {_enteDio = NetworkClient.instance.enteDio;_db = MemorySharesDB.instance;await _loadMemoryShareHashCache();+ try {+ await listMemoryShares();+ } catch (e, s) {+ _logger.warning("Failed to refresh memory shares during init", e, s);+ }}void clearCache() {@@ -67,17 +72,20 @@ class MemoryShareService {);final fileItems = <Map<String, dynamic>>[];- for (final file in uploadedFiles) {+ for (var i = 0; i < uploadedFiles.length; i++) {+ final file = uploadedFiles[i];final fileKey = getFileKey(file);final reEncryptedKey = CryptoUtil.encryptSync(fileKey, shareKey);fileItems.add({'fileID': file.uploadedFileID,+ 'position': i,'encryptedKey': CryptoUtil.bin2base64(reEncryptedKey.encryptedData!),'keyDecryptionNonce': CryptoUtil.bin2base64(reEncryptedKey.nonce!),});}final requestData = {+ 'type': MemoryShareType.share.name,'metadataCipher':CryptoUtil.bin2base64(encryptedMetadata.encryptedData!),'metadataNonce': CryptoUtil.bin2base64(encryptedMetadata.nonce!),@@ -139,14 +147,19 @@ class MemoryShareService {return share;}).toList();+ final localSharesByID = {+ for (final share in await _db.getAll()) share.id: share,+ };_memoryShareByHashCache.clear();+ final activeRemoteShareIDs = <int>{};final activeShares = <MemoryShare>[];for (final share in result) {if (share.isDeleted) {await _db.delete(share.id);continue;}- final localShare = await _db.getById(share.id);+ activeRemoteShareIDs.add(share.id);+ final localShare = localSharesByID[share.id];final mergedShare = share.copyWith(memoryHash: share.memoryHash ?? localShare?.memoryHash,previewUploadedFileID: localShare?.previewUploadedFileID,@@ -156,6 +169,11 @@ class MemoryShareService {_updateMemoryShareCache(mergedShare);activeShares.add(mergedShare);}+ for (final localShare in localSharesByID.values) {+ if (!activeRemoteShareIDs.contains(localShare.id)) {+ await _db.delete(localShare.id);+ }+ }return activeShares;} catch (e, s) {@@ -446,8 +464,12 @@ class MemoryShareService {if (tokenFromQuery != null && tokenFromQuery.isNotEmpty) {return tokenFromQuery;}- for (final segment in uri.pathSegments) {- if (segment.isNotEmpty && segment != "memory") {+ const routePrefixes = {"memories"};+ final pathSegments =+ uri.pathSegments.where((segment) => segment.isNotEmpty).toList();+ for (var i = pathSegments.length - 1; i >= 0; i--) {+ final segment = pathSegments[i];+ if (!routePrefixes.contains(segment.toLowerCase())) {return segment;}}