fix(server,web): correctly show album level like (#4916)

* fix: like in global activity

* refactor: rename isGlobal to ReactionLevel.Album

* chore: open api

* chore: e2e test for album vs comment duplicate like checking

---------

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
martin
2023-11-10 03:32:31 +01:00
committed by GitHub
parent 986bbfa831
commit 92ec1ce77f
21 changed files with 262 additions and 26 deletions

View File

@@ -101,6 +101,7 @@ doc/PersonResponseDto.md
doc/PersonStatisticsResponseDto.md
doc/PersonUpdateDto.md
doc/QueueStatusDto.md
doc/ReactionLevel.md
doc/ReactionType.md
doc/RecognitionConfig.md
doc/ScanLibraryDto.md
@@ -281,6 +282,7 @@ lib/model/person_response_dto.dart
lib/model/person_statistics_response_dto.dart
lib/model/person_update_dto.dart
lib/model/queue_status_dto.dart
lib/model/reaction_level.dart
lib/model/reaction_type.dart
lib/model/recognition_config.dart
lib/model/scan_library_dto.dart
@@ -440,6 +442,7 @@ test/person_response_dto_test.dart
test/person_statistics_response_dto_test.dart
test/person_update_dto_test.dart
test/queue_status_dto_test.dart
test/reaction_level_test.dart
test/reaction_type_test.dart
test/recognition_config_test.dart
test/scan_library_dto_test.dart

View File

@@ -292,6 +292,7 @@ Class | Method | HTTP request | Description
- [PersonStatisticsResponseDto](doc//PersonStatisticsResponseDto.md)
- [PersonUpdateDto](doc//PersonUpdateDto.md)
- [QueueStatusDto](doc//QueueStatusDto.md)
- [ReactionLevel](doc//ReactionLevel.md)
- [ReactionType](doc//ReactionType.md)
- [RecognitionConfig](doc//RecognitionConfig.md)
- [ScanLibraryDto](doc//ScanLibraryDto.md)

View File

@@ -125,7 +125,7 @@ void (empty response body)
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **getActivities**
> List<ActivityResponseDto> getActivities(albumId, assetId, type, userId)
> List<ActivityResponseDto> getActivities(albumId, assetId, type, level, userId)
@@ -151,10 +151,11 @@ final api_instance = ActivityApi();
final albumId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |
final assetId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |
final type = ; // ReactionType |
final level = ; // ReactionLevel |
final userId = 38400000-8cf0-11bd-b23e-10b96e4ef00d; // String |
try {
final result = api_instance.getActivities(albumId, assetId, type, userId);
final result = api_instance.getActivities(albumId, assetId, type, level, userId);
print(result);
} catch (e) {
print('Exception when calling ActivityApi->getActivities: $e\n');
@@ -168,6 +169,7 @@ Name | Type | Description | Notes
**albumId** | **String**| |
**assetId** | **String**| | [optional]
**type** | [**ReactionType**](.md)| | [optional]
**level** | [**ReactionLevel**](.md)| | [optional]
**userId** | **String**| | [optional]
### Return type

14
mobile/openapi/doc/ReactionLevel.md generated Normal file
View File

@@ -0,0 +1,14 @@
# openapi.model.ReactionLevel
## Load the model package
```dart
import 'package:openapi/api.dart';
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -133,6 +133,7 @@ part 'model/person_response_dto.dart';
part 'model/person_statistics_response_dto.dart';
part 'model/person_update_dto.dart';
part 'model/queue_status_dto.dart';
part 'model/reaction_level.dart';
part 'model/reaction_type.dart';
part 'model/recognition_config.dart';
part 'model/scan_library_dto.dart';

View File

@@ -112,8 +112,10 @@ class ActivityApi {
///
/// * [ReactionType] type:
///
/// * [ReactionLevel] level:
///
/// * [String] userId:
Future<Response> getActivitiesWithHttpInfo(String albumId, { String? assetId, ReactionType? type, String? userId, }) async {
Future<Response> getActivitiesWithHttpInfo(String albumId, { String? assetId, ReactionType? type, ReactionLevel? level, String? userId, }) async {
// ignore: prefer_const_declarations
final path = r'/activity';
@@ -131,6 +133,9 @@ class ActivityApi {
if (type != null) {
queryParams.addAll(_queryParams('', 'type', type));
}
if (level != null) {
queryParams.addAll(_queryParams('', 'level', level));
}
if (userId != null) {
queryParams.addAll(_queryParams('', 'userId', userId));
}
@@ -157,9 +162,11 @@ class ActivityApi {
///
/// * [ReactionType] type:
///
/// * [ReactionLevel] level:
///
/// * [String] userId:
Future<List<ActivityResponseDto>?> getActivities(String albumId, { String? assetId, ReactionType? type, String? userId, }) async {
final response = await getActivitiesWithHttpInfo(albumId, assetId: assetId, type: type, userId: userId, );
Future<List<ActivityResponseDto>?> getActivities(String albumId, { String? assetId, ReactionType? type, ReactionLevel? level, String? userId, }) async {
final response = await getActivitiesWithHttpInfo(albumId, assetId: assetId, type: type, level: level, userId: userId, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}

View File

@@ -355,6 +355,8 @@ class ApiClient {
return PersonUpdateDto.fromJson(value);
case 'QueueStatusDto':
return QueueStatusDto.fromJson(value);
case 'ReactionLevel':
return ReactionLevelTypeTransformer().decode(value);
case 'ReactionType':
return ReactionTypeTypeTransformer().decode(value);
case 'RecognitionConfig':

View File

@@ -100,6 +100,9 @@ String parameterToString(dynamic value) {
if (value is PathType) {
return PathTypeTypeTransformer().encode(value).toString();
}
if (value is ReactionLevel) {
return ReactionLevelTypeTransformer().encode(value).toString();
}
if (value is ReactionType) {
return ReactionTypeTypeTransformer().encode(value).toString();
}

View File

@@ -0,0 +1,85 @@
//
// 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 ReactionLevel {
/// Instantiate a new enum with the provided [value].
const ReactionLevel._(this.value);
/// The underlying value of this enum member.
final String value;
@override
String toString() => value;
String toJson() => value;
static const album = ReactionLevel._(r'album');
static const asset = ReactionLevel._(r'asset');
/// List of all possible values in this [enum][ReactionLevel].
static const values = <ReactionLevel>[
album,
asset,
];
static ReactionLevel? fromJson(dynamic value) => ReactionLevelTypeTransformer().decode(value);
static List<ReactionLevel>? listFromJson(dynamic json, {bool growable = false,}) {
final result = <ReactionLevel>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = ReactionLevel.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [ReactionLevel] to String,
/// and [decode] dynamic data back to [ReactionLevel].
class ReactionLevelTypeTransformer {
factory ReactionLevelTypeTransformer() => _instance ??= const ReactionLevelTypeTransformer._();
const ReactionLevelTypeTransformer._();
String encode(ReactionLevel data) => data.value;
/// Decodes a [dynamic value][data] to a ReactionLevel.
///
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
///
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
/// and users are still using an old app with the old code.
ReactionLevel? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
switch (data) {
case r'album': return ReactionLevel.album;
case r'asset': return ReactionLevel.asset;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
return null;
}
/// Singleton [ReactionLevelTypeTransformer] instance.
static ReactionLevelTypeTransformer? _instance;
}

View File

@@ -27,7 +27,7 @@ void main() {
// TODO
});
//Future<List<ActivityResponseDto>> getActivities(String albumId, { String assetId, ReactionType type, String userId }) async
//Future<List<ActivityResponseDto>> getActivities(String albumId, { String assetId, ReactionType type, ReactionLevel level, String userId }) async
test('test getActivities', () async {
// TODO
});

View File

@@ -0,0 +1,21 @@
//
// 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
import 'package:openapi/api.dart';
import 'package:test/test.dart';
// tests for ReactionLevel
void main() {
group('test ReactionLevel', () {
});
}