Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Refactor

Neeraj Guptac6d57fe6896b
diff --git a/mobile/lib/services/collections_service.dart b/mobile/lib/services/collections_service.dart
index ce0addb91b..a9540cb236 100644
--- a/mobile/lib/services/collections_service.dart
+++ b/mobile/lib/services/collections_service.dart
@@ -1212,8 +1212,6 @@ class CollectionsService {
BuildContext context,
int collectionID,
) async {
- final authToken = await getSharedPublicAlbumToken(collectionID);
- final jwtToken = await getSharedPublicAlbumTokenJWT(collectionID);
final key = await getSharedPublicAlbumKey(collectionID);
if (key.isEmpty) {
throw Exception("Collection key not found");
@@ -1231,10 +1229,7 @@ class CollectionsService {
"encryptedKey": CryptoUtil.bin2base64(encryptedKey),
},
options: Options(
- headers: {
- "X-Auth-Access-Token": authToken,
- "X-Auth-Access-Token-JWT": jwtToken,
- },
+ headers: publicCollectionHeaders(collectionID),
),
);
}
@@ -1253,13 +1248,6 @@ class CollectionsService {
return null;
}
- Future<String?> getSharedPublicAlbumTokenJWT(int collectionID) async {
- if (_cachedPublicAlbumJWT.containsKey(collectionID)) {
- return _cachedPublicAlbumJWT[collectionID];
- }
- return null;
- }
-
Map<String, String> publicCollectionHeaders(int collectionID) {
final String? albumToken = _cachedPublicAlbumToken[collectionID];
final String? albumJwtToken = _cachedPublicAlbumJWT[collectionID];
diff --git a/mobile/lib/services/sync/diff_fetcher.dart b/mobile/lib/services/sync/diff_fetcher.dart
index 405978f2f8..45794bf3d3 100644
--- a/mobile/lib/services/sync/diff_fetcher.dart
+++ b/mobile/lib/services/sync/diff_fetcher.dart
@@ -24,18 +24,10 @@ class DiffFetcher {
bool sortAsc,
) async {
try {
- final authToken = await CollectionsService.instance
- .getSharedPublicAlbumToken(collectionID);
- final authJWTToken = await CollectionsService.instance
- .getSharedPublicAlbumTokenJWT(collectionID);
bool hasMore = false;
final sharedFiles = <EnteFile>[];
-
- final headers = {
- "X-Auth-Access-Token": authToken,
- if (authJWTToken != null) "X-Auth-Access-Token-JWT": authJWTToken,
- };
-
+ final headers =
+ CollectionsService.instance.publicCollectionHeaders(collectionID);
int sinceTime = 0;
do {
diff --git a/mobile/lib/utils/file_download_util.dart b/mobile/lib/utils/file_download_util.dart
index 628c08e750..4828d775c1 100644
--- a/mobile/lib/utils/file_download_util.dart
+++ b/mobile/lib/utils/file_download_util.dart
@@ -29,8 +29,7 @@ import "package:photos/utils/standalone/fake_progress.dart";
final _logger = Logger("file_download_util");
Future<File?> downloadAndDecryptPublicFile(
- EnteFile file,
- String authToken, {
+ EnteFile file, {
ProgressCallback? progressCallback,
}) async {
final String logPrefix = 'Public File-${file.uploadedFileID}:';
@@ -42,13 +41,8 @@ Future<File?> downloadAndDecryptPublicFile(
final String decryptedFilePath = "$tempDir${file.uploadedFileID}.decrypted";
try {
- final authJWTToken = await CollectionsService.instance
- .getSharedPublicAlbumTokenJWT(file.collectionID!);
-
- final headers = {
- "X-Auth-Access-Token": authToken,
- if (authJWTToken != null) "X-Auth-Access-Token-JWT": authJWTToken,
- };
+ final headers =
+ CollectionsService.instance.publicCollectionHeaders(file.collectionID!);
final response = (await NetworkClient.instance.getDio().download(
FileUrl.getUrl(file.uploadedFileID!, FileUrlType.publicDownload),
encryptedFilePath,
@@ -102,12 +96,8 @@ Future<File?> downloadAndDecrypt(
ProgressCallback? progressCallback,
}) async {
if (CollectionsService.instance.isSharedPublicLink(file.collectionID!)) {
- final authToken = await CollectionsService.instance
- .getSharedPublicAlbumToken(file.collectionID!);
-
return await downloadAndDecryptPublicFile(
file,
- authToken!,
progressCallback: progressCallback,
);
}
diff --git a/mobile/lib/utils/thumbnail_util.dart b/mobile/lib/utils/thumbnail_util.dart
index 169137e880..7fdde7e7eb 100644
--- a/mobile/lib/utils/thumbnail_util.dart
+++ b/mobile/lib/utils/thumbnail_util.dart
@@ -163,16 +163,8 @@ Future<void> _downloadAndDecryptThumbnail(FileDownloadItem item) async {
Uint8List encryptedThumbnail;
try {
if (CollectionsService.instance.isSharedPublicLink(file.collectionID!)) {
- final authToken = await CollectionsService.instance
- .getSharedPublicAlbumToken(file.collectionID!);
- final authJWTToken = await CollectionsService.instance
- .getSharedPublicAlbumTokenJWT(file.collectionID!);
-
- final headers = {
- "X-Auth-Access-Token": authToken,
- if (authJWTToken != null) "X-Auth-Access-Token-JWT": authJWTToken,
- };
-
+ final headers = CollectionsService.instance
+ .publicCollectionHeaders(file.collectionID!);
encryptedThumbnail = (await NetworkClient.instance.getDio().get(
FileUrl.getUrl(
file.uploadedFileID!,