Skip to content

Commit

Permalink
chore(server): remove deprecated endpoints (#6984)
Browse files Browse the repository at this point in the history
* chore: remove deprecated endpoints

* chore: open api
  • Loading branch information
jrasm91 authored Feb 8, 2024
1 parent 198e851 commit 90a7f16
Show file tree
Hide file tree
Showing 36 changed files with 140 additions and 2,877 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AssetDescriptionService {

Future<String> readLatest(String assetRemoteId, int localExifId) async {
final latestAssetFromServer =
await _api.assetApi.getAssetById(assetRemoteId);
await _api.assetApi.getAssetInfo(assetRemoteId);
final localExifInfo = await _db.exifInfos.get(localExifId);

if (latestAssetFromServer != null && localExifInfo != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class ImageViewerService {
// Download LivePhotos image and motion part
if (asset.isImage && asset.livePhotoVideoId != null && Platform.isIOS) {
var imageResponse =
await _apiService.assetApi.downloadFileOldWithHttpInfo(
await _apiService.downloadApi.downloadFileWithHttpInfo(
asset.remoteId!,
);

var motionReponse =
await _apiService.assetApi.downloadFileOldWithHttpInfo(
await _apiService.downloadApi.downloadFileWithHttpInfo(
asset.livePhotoVideoId!,
);

Expand Down Expand Up @@ -71,8 +71,8 @@ class ImageViewerService {

return entity != null;
} else {
var res = await _apiService.assetApi
.downloadFileOldWithHttpInfo(asset.remoteId!);
var res = await _apiService.downloadApi
.downloadFileWithHttpInfo(asset.remoteId!);

if (res.statusCode != 200) {
_log.severe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class BackupVerificationService {
ExifInfo? exif = remote.exifInfo;
if (exif != null && exif.lat != null) return false;
if (exif == null || exif.fileSize == null) {
final dto = await apiService.assetApi.getAssetById(remote.remoteId!);
final dto = await apiService.assetApi.getAssetInfo(remote.remoteId!);
if (dto != null && dto.exifInfo != null) {
exif = ExifInfo.fromDto(dto.exifInfo!);
}
Expand Down Expand Up @@ -165,8 +165,8 @@ class BackupVerificationService {
// (skip first few KBs containing metadata)
final Uint64List localImage =
_fakeDecodeImg(local, await file.readAsBytes());
final res = await apiService.assetApi
.downloadFileOldWithHttpInfo(remote.remoteId!);
final res = await apiService.downloadApi
.downloadFileWithHttpInfo(remote.remoteId!);
final Uint64List remoteImage = _fakeDecodeImg(remote, res.bodyBytes);

final eq = const ListEquality().equals(remoteImage, localImage);
Expand Down
6 changes: 3 additions & 3 deletions mobile/lib/modules/trash/services/trash.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TrashService {
try {
List<String> remoteIds =
assetList.where((a) => a.isRemote).map((e) => e.remoteId!).toList();
await _apiService.assetApi.restoreAssetsOld(BulkIdsDto(ids: remoteIds));
await _apiService.trashApi.restoreAssets(BulkIdsDto(ids: remoteIds));
return true;
} catch (error, stack) {
_log.severe("Cannot restore assets ${error.toString()}", error, stack);
Expand All @@ -32,15 +32,15 @@ class TrashService {

Future<void> emptyTrash() async {
try {
await _apiService.assetApi.emptyTrashOld();
await _apiService.trashApi.emptyTrash();
} catch (error, stack) {
_log.severe("Cannot empty trash ${error.toString()}", error, stack);
}
}

Future<void> restoreTrash() async {
try {
await _apiService.assetApi.restoreTrashOld();
await _apiService.trashApi.restoreTrash();
} catch (error, stack) {
_log.severe("Cannot restore trash ${error.toString()}", error, stack);
}
Expand Down
4 changes: 4 additions & 0 deletions mobile/lib/shared/services/api.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class ApiService {
late SharedLinkApi sharedLinkApi;
late SystemConfigApi systemConfigApi;
late ActivityApi activityApi;
late DownloadApi downloadApi;
late TrashApi trashApi;

ApiService() {
final endpoint = Store.tryGet(StoreKey.serverEndpoint);
Expand Down Expand Up @@ -51,6 +53,8 @@ class ApiService {
sharedLinkApi = SharedLinkApi(_apiClient);
systemConfigApi = SystemConfigApi(_apiClient);
activityApi = ActivityApi(_apiClient);
downloadApi = DownloadApi(_apiClient);
trashApi = TrashApi(_apiClient);
}

Future<String> resolveAndSetEndpoint(String serverUrl) async {
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/shared/services/asset.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class AssetService {
// fileSize is always filled on the server but not set on client
if (a.exifInfo?.fileSize == null) {
if (a.isRemote) {
final dto = await _apiService.assetApi.getAssetById(a.remoteId!);
final dto = await _apiService.assetApi.getAssetInfo(a.remoteId!);
if (dto != null && dto.exifInfo != null) {
final newExif = Asset.remote(dto).exifInfo!.copyWith(id: a.id);
if (newExif != a.exifInfo) {
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/shared/services/share.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class ShareService {
final tempDir = await getTemporaryDirectory();
final fileName = asset.fileName;
final tempFile = await File('${tempDir.path}/$fileName').create();
final res = await _apiService.assetApi
.downloadFileOldWithHttpInfo(asset.remoteId!);
final res = await _apiService.downloadApi
.downloadFileWithHttpInfo(asset.remoteId!);

if (res.statusCode != 200) {
_log.severe(
Expand Down
3 changes: 0 additions & 3 deletions mobile/openapi/.openapi-generator/FILES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions mobile/openapi/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 90a7f16

Please sign in to comment.