mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
refactor(server)!: add/remove album assets (#3109)
* refactor: add/remove album assets * chore: open api * feat: remove owned assets from album * refactor: move to bulk id req/res dto * chore: open api * chore: merge main * dev: mobile work * fix: adding asset from web not sync with mobile * remove print statement --------- Co-authored-by: Alex Tran <Alex.Tran@conductix.com>
This commit is contained in:
4
mobile/openapi/lib/api.dart
generated
4
mobile/openapi/lib/api.dart
generated
@@ -47,8 +47,6 @@ part 'model/api_key_create_dto.dart';
|
||||
part 'model/api_key_create_response_dto.dart';
|
||||
part 'model/api_key_response_dto.dart';
|
||||
part 'model/api_key_update_dto.dart';
|
||||
part 'model/add_assets_dto.dart';
|
||||
part 'model/add_assets_response_dto.dart';
|
||||
part 'model/add_users_dto.dart';
|
||||
part 'model/admin_signup_response_dto.dart';
|
||||
part 'model/album_count_response_dto.dart';
|
||||
@@ -69,6 +67,7 @@ part 'model/asset_type_enum.dart';
|
||||
part 'model/audio_codec.dart';
|
||||
part 'model/auth_device_response_dto.dart';
|
||||
part 'model/bulk_id_response_dto.dart';
|
||||
part 'model/bulk_ids_dto.dart';
|
||||
part 'model/change_password_dto.dart';
|
||||
part 'model/check_duplicate_asset_dto.dart';
|
||||
part 'model/check_duplicate_asset_response_dto.dart';
|
||||
@@ -110,7 +109,6 @@ part 'model/people_update_item.dart';
|
||||
part 'model/person_response_dto.dart';
|
||||
part 'model/person_update_dto.dart';
|
||||
part 'model/queue_status_dto.dart';
|
||||
part 'model/remove_assets_dto.dart';
|
||||
part 'model/search_album_response_dto.dart';
|
||||
part 'model/search_asset_dto.dart';
|
||||
part 'model/search_asset_response_dto.dart';
|
||||
|
||||
38
mobile/openapi/lib/api/album_api.dart
generated
38
mobile/openapi/lib/api/album_api.dart
generated
@@ -21,16 +21,16 @@ class AlbumApi {
|
||||
///
|
||||
/// * [String] id (required):
|
||||
///
|
||||
/// * [AddAssetsDto] addAssetsDto (required):
|
||||
/// * [BulkIdsDto] bulkIdsDto (required):
|
||||
///
|
||||
/// * [String] key:
|
||||
Future<Response> addAssetsToAlbumWithHttpInfo(String id, AddAssetsDto addAssetsDto, { String? key, }) async {
|
||||
Future<Response> addAssetsToAlbumWithHttpInfo(String id, BulkIdsDto bulkIdsDto, { String? key, }) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/album/{id}/assets'
|
||||
.replaceAll('{id}', id);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody = addAssetsDto;
|
||||
Object? postBody = bulkIdsDto;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@@ -58,11 +58,11 @@ class AlbumApi {
|
||||
///
|
||||
/// * [String] id (required):
|
||||
///
|
||||
/// * [AddAssetsDto] addAssetsDto (required):
|
||||
/// * [BulkIdsDto] bulkIdsDto (required):
|
||||
///
|
||||
/// * [String] key:
|
||||
Future<AddAssetsResponseDto?> addAssetsToAlbum(String id, AddAssetsDto addAssetsDto, { String? key, }) async {
|
||||
final response = await addAssetsToAlbumWithHttpInfo(id, addAssetsDto, key: key, );
|
||||
Future<List<BulkIdResponseDto>?> addAssetsToAlbum(String id, BulkIdsDto bulkIdsDto, { String? key, }) async {
|
||||
final response = await addAssetsToAlbumWithHttpInfo(id, bulkIdsDto, key: key, );
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
@@ -70,8 +70,11 @@ class AlbumApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'AddAssetsResponseDto',) as AddAssetsResponseDto;
|
||||
|
||||
final responseBody = await _decodeBodyBytes(response);
|
||||
return (await apiClient.deserializeAsync(responseBody, 'List<BulkIdResponseDto>') as List)
|
||||
.cast<BulkIdResponseDto>()
|
||||
.toList();
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -380,14 +383,14 @@ class AlbumApi {
|
||||
///
|
||||
/// * [String] id (required):
|
||||
///
|
||||
/// * [RemoveAssetsDto] removeAssetsDto (required):
|
||||
Future<Response> removeAssetFromAlbumWithHttpInfo(String id, RemoveAssetsDto removeAssetsDto,) async {
|
||||
/// * [BulkIdsDto] bulkIdsDto (required):
|
||||
Future<Response> removeAssetFromAlbumWithHttpInfo(String id, BulkIdsDto bulkIdsDto,) async {
|
||||
// ignore: prefer_const_declarations
|
||||
final path = r'/album/{id}/assets'
|
||||
.replaceAll('{id}', id);
|
||||
|
||||
// ignore: prefer_final_locals
|
||||
Object? postBody = removeAssetsDto;
|
||||
Object? postBody = bulkIdsDto;
|
||||
|
||||
final queryParams = <QueryParam>[];
|
||||
final headerParams = <String, String>{};
|
||||
@@ -411,9 +414,9 @@ class AlbumApi {
|
||||
///
|
||||
/// * [String] id (required):
|
||||
///
|
||||
/// * [RemoveAssetsDto] removeAssetsDto (required):
|
||||
Future<AlbumResponseDto?> removeAssetFromAlbum(String id, RemoveAssetsDto removeAssetsDto,) async {
|
||||
final response = await removeAssetFromAlbumWithHttpInfo(id, removeAssetsDto,);
|
||||
/// * [BulkIdsDto] bulkIdsDto (required):
|
||||
Future<List<BulkIdResponseDto>?> removeAssetFromAlbum(String id, BulkIdsDto bulkIdsDto,) async {
|
||||
final response = await removeAssetFromAlbumWithHttpInfo(id, bulkIdsDto,);
|
||||
if (response.statusCode >= HttpStatus.badRequest) {
|
||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||
}
|
||||
@@ -421,8 +424,11 @@ class AlbumApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'AlbumResponseDto',) as AlbumResponseDto;
|
||||
|
||||
final responseBody = await _decodeBodyBytes(response);
|
||||
return (await apiClient.deserializeAsync(responseBody, 'List<BulkIdResponseDto>') as List)
|
||||
.cast<BulkIdResponseDto>()
|
||||
.toList();
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
8
mobile/openapi/lib/api_client.dart
generated
8
mobile/openapi/lib/api_client.dart
generated
@@ -189,10 +189,6 @@ class ApiClient {
|
||||
return APIKeyResponseDto.fromJson(value);
|
||||
case 'APIKeyUpdateDto':
|
||||
return APIKeyUpdateDto.fromJson(value);
|
||||
case 'AddAssetsDto':
|
||||
return AddAssetsDto.fromJson(value);
|
||||
case 'AddAssetsResponseDto':
|
||||
return AddAssetsResponseDto.fromJson(value);
|
||||
case 'AddUsersDto':
|
||||
return AddUsersDto.fromJson(value);
|
||||
case 'AdminSignupResponseDto':
|
||||
@@ -233,6 +229,8 @@ class ApiClient {
|
||||
return AuthDeviceResponseDto.fromJson(value);
|
||||
case 'BulkIdResponseDto':
|
||||
return BulkIdResponseDto.fromJson(value);
|
||||
case 'BulkIdsDto':
|
||||
return BulkIdsDto.fromJson(value);
|
||||
case 'ChangePasswordDto':
|
||||
return ChangePasswordDto.fromJson(value);
|
||||
case 'CheckDuplicateAssetDto':
|
||||
@@ -315,8 +313,6 @@ class ApiClient {
|
||||
return PersonUpdateDto.fromJson(value);
|
||||
case 'QueueStatusDto':
|
||||
return QueueStatusDto.fromJson(value);
|
||||
case 'RemoveAssetsDto':
|
||||
return RemoveAssetsDto.fromJson(value);
|
||||
case 'SearchAlbumResponseDto':
|
||||
return SearchAlbumResponseDto.fromJson(value);
|
||||
case 'SearchAssetDto':
|
||||
|
||||
125
mobile/openapi/lib/model/add_assets_response_dto.dart
generated
125
mobile/openapi/lib/model/add_assets_response_dto.dart
generated
@@ -1,125 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class AddAssetsResponseDto {
|
||||
/// Returns a new [AddAssetsResponseDto] instance.
|
||||
AddAssetsResponseDto({
|
||||
this.album,
|
||||
this.alreadyInAlbum = const [],
|
||||
required this.successfullyAdded,
|
||||
});
|
||||
|
||||
///
|
||||
/// Please note: This property should have been non-nullable! Since the specification file
|
||||
/// does not include a default value (using the "default:" property), however, the generated
|
||||
/// source code must fall back to having a nullable type.
|
||||
/// Consider adding a "default:" property in the specification file to hide this note.
|
||||
///
|
||||
AlbumResponseDto? album;
|
||||
|
||||
List<String> alreadyInAlbum;
|
||||
|
||||
int successfullyAdded;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is AddAssetsResponseDto &&
|
||||
other.album == album &&
|
||||
other.alreadyInAlbum == alreadyInAlbum &&
|
||||
other.successfullyAdded == successfullyAdded;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(album == null ? 0 : album!.hashCode) +
|
||||
(alreadyInAlbum.hashCode) +
|
||||
(successfullyAdded.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'AddAssetsResponseDto[album=$album, alreadyInAlbum=$alreadyInAlbum, successfullyAdded=$successfullyAdded]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
if (this.album != null) {
|
||||
json[r'album'] = this.album;
|
||||
} else {
|
||||
// json[r'album'] = null;
|
||||
}
|
||||
json[r'alreadyInAlbum'] = this.alreadyInAlbum;
|
||||
json[r'successfullyAdded'] = this.successfullyAdded;
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [AddAssetsResponseDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static AddAssetsResponseDto? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return AddAssetsResponseDto(
|
||||
album: AlbumResponseDto.fromJson(json[r'album']),
|
||||
alreadyInAlbum: json[r'alreadyInAlbum'] is Iterable
|
||||
? (json[r'alreadyInAlbum'] as Iterable).cast<String>().toList(growable: false)
|
||||
: const [],
|
||||
successfullyAdded: mapValueOfType<int>(json, r'successfullyAdded')!,
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<AddAssetsResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <AddAssetsResponseDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = AddAssetsResponseDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, AddAssetsResponseDto> mapFromJson(dynamic json) {
|
||||
final map = <String, AddAssetsResponseDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = AddAssetsResponseDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of AddAssetsResponseDto-objects as value to a dart map
|
||||
static Map<String, List<AddAssetsResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<AddAssetsResponseDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = AddAssetsResponseDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'alreadyInAlbum',
|
||||
'successfullyAdded',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,53 +10,53 @@
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class AddAssetsDto {
|
||||
/// Returns a new [AddAssetsDto] instance.
|
||||
AddAssetsDto({
|
||||
this.assetIds = const [],
|
||||
class BulkIdsDto {
|
||||
/// Returns a new [BulkIdsDto] instance.
|
||||
BulkIdsDto({
|
||||
this.ids = const [],
|
||||
});
|
||||
|
||||
List<String> assetIds;
|
||||
List<String> ids;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is AddAssetsDto &&
|
||||
other.assetIds == assetIds;
|
||||
bool operator ==(Object other) => identical(this, other) || other is BulkIdsDto &&
|
||||
other.ids == ids;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(assetIds.hashCode);
|
||||
(ids.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'AddAssetsDto[assetIds=$assetIds]';
|
||||
String toString() => 'BulkIdsDto[ids=$ids]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
json[r'assetIds'] = this.assetIds;
|
||||
json[r'ids'] = this.ids;
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [AddAssetsDto] instance and imports its values from
|
||||
/// Returns a new [BulkIdsDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static AddAssetsDto? fromJson(dynamic value) {
|
||||
static BulkIdsDto? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return AddAssetsDto(
|
||||
assetIds: json[r'assetIds'] is Iterable
|
||||
? (json[r'assetIds'] as Iterable).cast<String>().toList(growable: false)
|
||||
return BulkIdsDto(
|
||||
ids: json[r'ids'] is Iterable
|
||||
? (json[r'ids'] as Iterable).cast<String>().toList(growable: false)
|
||||
: const [],
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<AddAssetsDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <AddAssetsDto>[];
|
||||
static List<BulkIdsDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <BulkIdsDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = AddAssetsDto.fromJson(row);
|
||||
final value = BulkIdsDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
@@ -65,12 +65,12 @@ class AddAssetsDto {
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, AddAssetsDto> mapFromJson(dynamic json) {
|
||||
final map = <String, AddAssetsDto>{};
|
||||
static Map<String, BulkIdsDto> mapFromJson(dynamic json) {
|
||||
final map = <String, BulkIdsDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = AddAssetsDto.fromJson(entry.value);
|
||||
final value = BulkIdsDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
@@ -79,14 +79,14 @@ class AddAssetsDto {
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of AddAssetsDto-objects as value to a dart map
|
||||
static Map<String, List<AddAssetsDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<AddAssetsDto>>{};
|
||||
// maps a json object with a list of BulkIdsDto-objects as value to a dart map
|
||||
static Map<String, List<BulkIdsDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<BulkIdsDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = AddAssetsDto.listFromJson(entry.value, growable: growable,);
|
||||
map[entry.key] = BulkIdsDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
@@ -94,7 +94,7 @@ class AddAssetsDto {
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'assetIds',
|
||||
'ids',
|
||||
};
|
||||
}
|
||||
|
||||
100
mobile/openapi/lib/model/remove_assets_dto.dart
generated
100
mobile/openapi/lib/model/remove_assets_dto.dart
generated
@@ -1,100 +0,0 @@
|
||||
//
|
||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
||||
//
|
||||
// @dart=2.12
|
||||
|
||||
// ignore_for_file: unused_element, unused_import
|
||||
// ignore_for_file: always_put_required_named_parameters_first
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
|
||||
part of openapi.api;
|
||||
|
||||
class RemoveAssetsDto {
|
||||
/// Returns a new [RemoveAssetsDto] instance.
|
||||
RemoveAssetsDto({
|
||||
this.assetIds = const [],
|
||||
});
|
||||
|
||||
List<String> assetIds;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) => identical(this, other) || other is RemoveAssetsDto &&
|
||||
other.assetIds == assetIds;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
// ignore: unnecessary_parenthesis
|
||||
(assetIds.hashCode);
|
||||
|
||||
@override
|
||||
String toString() => 'RemoveAssetsDto[assetIds=$assetIds]';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final json = <String, dynamic>{};
|
||||
json[r'assetIds'] = this.assetIds;
|
||||
return json;
|
||||
}
|
||||
|
||||
/// Returns a new [RemoveAssetsDto] instance and imports its values from
|
||||
/// [value] if it's a [Map], null otherwise.
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static RemoveAssetsDto? fromJson(dynamic value) {
|
||||
if (value is Map) {
|
||||
final json = value.cast<String, dynamic>();
|
||||
|
||||
return RemoveAssetsDto(
|
||||
assetIds: json[r'assetIds'] is Iterable
|
||||
? (json[r'assetIds'] as Iterable).cast<String>().toList(growable: false)
|
||||
: const [],
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<RemoveAssetsDto> listFromJson(dynamic json, {bool growable = false,}) {
|
||||
final result = <RemoveAssetsDto>[];
|
||||
if (json is List && json.isNotEmpty) {
|
||||
for (final row in json) {
|
||||
final value = RemoveAssetsDto.fromJson(row);
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toList(growable: growable);
|
||||
}
|
||||
|
||||
static Map<String, RemoveAssetsDto> mapFromJson(dynamic json) {
|
||||
final map = <String, RemoveAssetsDto>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
|
||||
for (final entry in json.entries) {
|
||||
final value = RemoveAssetsDto.fromJson(entry.value);
|
||||
if (value != null) {
|
||||
map[entry.key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
// maps a json object with a list of RemoveAssetsDto-objects as value to a dart map
|
||||
static Map<String, List<RemoveAssetsDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
|
||||
final map = <String, List<RemoveAssetsDto>>{};
|
||||
if (json is Map && json.isNotEmpty) {
|
||||
// ignore: parameter_assignments
|
||||
json = json.cast<String, dynamic>();
|
||||
for (final entry in json.entries) {
|
||||
map[entry.key] = RemoveAssetsDto.listFromJson(entry.value, growable: growable,);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/// The list of required keys that must be present in a JSON.
|
||||
static const requiredKeys = <String>{
|
||||
'assetIds',
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user