mirror of
https://github.com/immich-app/immich.git
synced 2026-07-20 21:02:55 +08:00
CLI Build / CLI Publish (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Docker / pre-job (push) Has been cancelled
Docs build / pre-job (push) Has been cancelled
Zizmor / Zizmor (push) Has been cancelled
Static Code Analysis / pre-job (push) Has been cancelled
Test / pre-job (push) Has been cancelled
Test / ShellCheck (push) Has been cancelled
Test / OpenAPI Clients (push) Has been cancelled
Test / SQL Schema Checks (push) Has been cancelled
CLI Build / Docker (push) Has been cancelled
Docker / Re-Tag ML () (push) Has been cancelled
Docker / Re-Tag ML (-armnn) (push) Has been cancelled
Docker / Re-Tag ML (-cuda) (push) Has been cancelled
Docker / Re-Tag ML (-openvino) (push) Has been cancelled
Docker / Re-Tag ML (-rknn) (push) Has been cancelled
Docker / Re-Tag ML (-rocm) (push) Has been cancelled
Docker / Re-Tag Server () (push) Has been cancelled
Docker / Build and Push ML (armnn, linux/arm64, -armnn) (push) Has been cancelled
Docker / Build and Push ML (cpu) (push) Has been cancelled
Docker / Build and Push ML (cuda, linux/amd64, -cuda) (push) Has been cancelled
Docker / Build and Push ML (openvino, linux/amd64, -openvino) (push) Has been cancelled
Docker / Build and Push ML (rknn, linux/arm64, -rknn) (push) Has been cancelled
Docker / Build and Push ML (rocm, linux/amd64, {"linux/amd64": "pokedex-large"}, -rocm) (push) Has been cancelled
Docker / Build and Push Server (push) Has been cancelled
Docker / Docker Build & Push Server Success (push) Has been cancelled
Docker / Docker Build & Push ML Success (push) Has been cancelled
Docs build / Docs Build (push) Has been cancelled
Static Code Analysis / Run Dart Code Analysis (push) Has been cancelled
Test / Scripts unit tests (push) Has been cancelled
Test / Test & Lint Server (push) Has been cancelled
Test / Unit Test CLI (push) Has been cancelled
Test / Unit Test CLI (Windows) (push) Has been cancelled
Test / Lint Web (push) Has been cancelled
Test / Test Web (push) Has been cancelled
Test / Test i18n (push) Has been cancelled
Test / End-to-End Lint (push) Has been cancelled
Test / Medium Tests (Server) (push) Has been cancelled
Test / End-to-End Tests (Server & CLI) (ubuntu-24.04-arm) (push) Has been cancelled
Test / End-to-End Tests (Server & CLI) (ubuntu-latest) (push) Has been cancelled
Test / End-to-End Tests (Web) (ubuntu-24.04-arm) (push) Has been cancelled
Test / End-to-End Tests (Web) (ubuntu-latest) (push) Has been cancelled
Test / End-to-End Tests Success (push) Has been cancelled
Test / Unit Test Mobile (push) Has been cancelled
Test / Unit Test ML (push) Has been cancelled
Test / .github Files Formatting (push) Has been cancelled
* feat(web): recently added link in sidebar * chore(mobile): update openapi patches
75 lines
2.5 KiB
Dart
75 lines
2.5 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
abstract interface class _Dynamic {
|
|
Object? resolve();
|
|
}
|
|
|
|
class _CurrentTimestamp implements _Dynamic {
|
|
const _CurrentTimestamp();
|
|
|
|
@override
|
|
Object? resolve() => DateTime.now().toIso8601String();
|
|
}
|
|
|
|
const _now = _CurrentTimestamp();
|
|
|
|
@visibleForTesting
|
|
final Map<String, Map<String, Object?>> openApiPatches = {
|
|
'UserPreferencesResponseDto': {
|
|
'download.includeEmbeddedVideos': false,
|
|
'folders': FoldersResponse(enabled: false, sidebarWeb: false).toJson(),
|
|
'memories': MemoriesResponse(enabled: true, duration: 5).toJson(),
|
|
'ratings': RatingsResponse(enabled: false).toJson(),
|
|
'people': PeopleResponse(enabled: true, sidebarWeb: false).toJson(),
|
|
'tags': TagsResponse(enabled: false, sidebarWeb: false).toJson(),
|
|
'sharedLinks': SharedLinksResponse(enabled: true, sidebarWeb: false).toJson(),
|
|
'cast': CastResponse(gCastEnabled: false).toJson(),
|
|
'albums': {'defaultAssetOrder': 'desc'},
|
|
'recentlyAdded': RecentlyAddedResponse(sidebarWeb: false).toJson(),
|
|
},
|
|
'ServerConfigDto': {
|
|
'mapLightStyleUrl': 'https://tiles.immich.cloud/v1/style/light.json',
|
|
'mapDarkStyleUrl': 'https://tiles.immich.cloud/v1/style/dark.json',
|
|
'minFaces': 3,
|
|
},
|
|
'UserResponseDto': {'profileChangedAt': _now},
|
|
'AssetResponseDto': {'visibility': 'timeline', 'createdAt': _now, 'isEdited': false},
|
|
'UserAdminResponseDto': {'profileChangedAt': _now},
|
|
'LoginResponseDto': {'isOnboarded': false},
|
|
'SyncUserV1': {'profileChangedAt': _now, 'hasProfileImage': false},
|
|
'SyncAssetV1': {'isEdited': false},
|
|
'ServerFeaturesDto': {'ocr': false, 'realtimeTranscoding': false},
|
|
'MemoriesResponse': {'duration': 5},
|
|
};
|
|
|
|
void upgradeDto(dynamic value, String targetType) {
|
|
if (value is! Map) {
|
|
return;
|
|
}
|
|
final fields = openApiPatches[targetType];
|
|
if (fields == null) {
|
|
return;
|
|
}
|
|
fields.forEach((key, defaultValue) {
|
|
addDefault(value, key, defaultValue is _Dynamic ? defaultValue.resolve() : defaultValue);
|
|
});
|
|
}
|
|
|
|
addDefault(dynamic value, String keys, dynamic defaultValue) {
|
|
// Loop through the keys and assign the default value if the key is not present
|
|
List<String> keyList = keys.split('.');
|
|
dynamic current = value;
|
|
|
|
for (int i = 0; i < keyList.length - 1; i++) {
|
|
if (current[keyList[i]] == null) {
|
|
current[keyList[i]] = {};
|
|
}
|
|
current = current[keyList[i]];
|
|
}
|
|
|
|
if (current[keyList.last] == null) {
|
|
current[keyList.last] = defaultValue;
|
|
}
|
|
}
|