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:
parent
986bbfa831
commit
92ec1ce77f
21 changed files with 262 additions and 26 deletions
37
cli/src/api/open-api/api.ts
generated
37
cli/src/api/open-api/api.ts
generated
|
@ -2570,6 +2570,20 @@ export interface QueueStatusDto {
|
|||
*/
|
||||
'isPaused': boolean;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
|
||||
export const ReactionLevel = {
|
||||
Album: 'album',
|
||||
Asset: 'asset'
|
||||
} as const;
|
||||
|
||||
export type ReactionLevel = typeof ReactionLevel[keyof typeof ReactionLevel];
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
|
@ -5065,11 +5079,12 @@ export const ActivityApiAxiosParamCreator = function (configuration?: Configurat
|
|||
* @param {string} albumId
|
||||
* @param {string} [assetId]
|
||||
* @param {ReactionType} [type]
|
||||
* @param {ReactionLevel} [level]
|
||||
* @param {string} [userId]
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getActivities: async (albumId: string, assetId?: string, type?: ReactionType, userId?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
getActivities: async (albumId: string, assetId?: string, type?: ReactionType, level?: ReactionLevel, userId?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'albumId' is not null or undefined
|
||||
assertParamExists('getActivities', 'albumId', albumId)
|
||||
const localVarPath = `/activity`;
|
||||
|
@ -5105,6 +5120,10 @@ export const ActivityApiAxiosParamCreator = function (configuration?: Configurat
|
|||
localVarQueryParameter['type'] = type;
|
||||
}
|
||||
|
||||
if (level !== undefined) {
|
||||
localVarQueryParameter['level'] = level;
|
||||
}
|
||||
|
||||
if (userId !== undefined) {
|
||||
localVarQueryParameter['userId'] = userId;
|
||||
}
|
||||
|
@ -5205,12 +5224,13 @@ export const ActivityApiFp = function(configuration?: Configuration) {
|
|||
* @param {string} albumId
|
||||
* @param {string} [assetId]
|
||||
* @param {ReactionType} [type]
|
||||
* @param {ReactionLevel} [level]
|
||||
* @param {string} [userId]
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async getActivities(albumId: string, assetId?: string, type?: ReactionType, userId?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<ActivityResponseDto>>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getActivities(albumId, assetId, type, userId, options);
|
||||
async getActivities(albumId: string, assetId?: string, type?: ReactionType, level?: ReactionLevel, userId?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<ActivityResponseDto>>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getActivities(albumId, assetId, type, level, userId, options);
|
||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||
},
|
||||
/**
|
||||
|
@ -5259,7 +5279,7 @@ export const ActivityApiFactory = function (configuration?: Configuration, baseP
|
|||
* @throws {RequiredError}
|
||||
*/
|
||||
getActivities(requestParameters: ActivityApiGetActivitiesRequest, options?: AxiosRequestConfig): AxiosPromise<Array<ActivityResponseDto>> {
|
||||
return localVarFp.getActivities(requestParameters.albumId, requestParameters.assetId, requestParameters.type, requestParameters.userId, options).then((request) => request(axios, basePath));
|
||||
return localVarFp.getActivities(requestParameters.albumId, requestParameters.assetId, requestParameters.type, requestParameters.level, requestParameters.userId, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
|
@ -5328,6 +5348,13 @@ export interface ActivityApiGetActivitiesRequest {
|
|||
*/
|
||||
readonly type?: ReactionType
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {ReactionLevel}
|
||||
* @memberof ActivityApiGetActivities
|
||||
*/
|
||||
readonly level?: ReactionLevel
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
|
@ -5394,7 +5421,7 @@ export class ActivityApi extends BaseAPI {
|
|||
* @memberof ActivityApi
|
||||
*/
|
||||
public getActivities(requestParameters: ActivityApiGetActivitiesRequest, options?: AxiosRequestConfig) {
|
||||
return ActivityApiFp(this.configuration).getActivities(requestParameters.albumId, requestParameters.assetId, requestParameters.type, requestParameters.userId, options).then((request) => request(this.axios, this.basePath));
|
||||
return ActivityApiFp(this.configuration).getActivities(requestParameters.albumId, requestParameters.assetId, requestParameters.type, requestParameters.level, requestParameters.userId, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
3
mobile/openapi/.openapi-generator/FILES
generated
3
mobile/openapi/.openapi-generator/FILES
generated
|
@ -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
|
||||
|
|
1
mobile/openapi/README.md
generated
1
mobile/openapi/README.md
generated
|
@ -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)
|
||||
|
|
6
mobile/openapi/doc/ActivityApi.md
generated
6
mobile/openapi/doc/ActivityApi.md
generated
|
@ -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
14
mobile/openapi/doc/ReactionLevel.md
generated
Normal 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)
|
||||
|
||||
|
1
mobile/openapi/lib/api.dart
generated
1
mobile/openapi/lib/api.dart
generated
|
@ -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';
|
||||
|
|
13
mobile/openapi/lib/api/activity_api.dart
generated
13
mobile/openapi/lib/api/activity_api.dart
generated
|
@ -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));
|
||||
}
|
||||
|
|
2
mobile/openapi/lib/api_client.dart
generated
2
mobile/openapi/lib/api_client.dart
generated
|
@ -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':
|
||||
|
|
3
mobile/openapi/lib/api_helper.dart
generated
3
mobile/openapi/lib/api_helper.dart
generated
|
@ -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();
|
||||
}
|
||||
|
|
85
mobile/openapi/lib/model/reaction_level.dart
generated
Normal file
85
mobile/openapi/lib/model/reaction_level.dart
generated
Normal 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;
|
||||
}
|
||||
|
2
mobile/openapi/test/activity_api_test.dart
generated
2
mobile/openapi/test/activity_api_test.dart
generated
|
@ -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
|
||||
});
|
||||
|
|
21
mobile/openapi/test/reaction_level_test.dart
generated
Normal file
21
mobile/openapi/test/reaction_level_test.dart
generated
Normal 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', () {
|
||||
|
||||
});
|
||||
|
||||
}
|
|
@ -31,6 +31,14 @@
|
|||
"$ref": "#/components/schemas/ReactionType"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "level",
|
||||
"required": false,
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ReactionLevel"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "userId",
|
||||
"required": false,
|
||||
|
@ -7728,6 +7736,13 @@
|
|||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ReactionLevel": {
|
||||
"enum": [
|
||||
"album",
|
||||
"asset"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ReactionType": {
|
||||
"enum": [
|
||||
"comment",
|
||||
|
|
|
@ -9,6 +9,11 @@ export enum ReactionType {
|
|||
LIKE = 'like',
|
||||
}
|
||||
|
||||
export enum ReactionLevel {
|
||||
ALBUM = 'album',
|
||||
ASSET = 'asset',
|
||||
}
|
||||
|
||||
export type MaybeDuplicate<T> = { duplicate: boolean; value: T };
|
||||
|
||||
export class ActivityResponseDto {
|
||||
|
@ -39,6 +44,11 @@ export class ActivitySearchDto extends ActivityDto {
|
|||
@ApiProperty({ enumName: 'ReactionType', enum: ReactionType })
|
||||
type?: ReactionType;
|
||||
|
||||
@IsEnum(ReactionLevel)
|
||||
@Optional()
|
||||
@ApiProperty({ enumName: 'ReactionLevel', enum: ReactionLevel })
|
||||
level?: ReactionLevel;
|
||||
|
||||
@ValidateUUID({ optional: true })
|
||||
userId?: string;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
ActivitySearchDto,
|
||||
ActivityStatisticsResponseDto,
|
||||
MaybeDuplicate,
|
||||
ReactionLevel,
|
||||
ReactionType,
|
||||
mapActivity,
|
||||
} from './activity.dto';
|
||||
|
@ -30,7 +31,7 @@ export class ActivityService {
|
|||
const activities = await this.repository.search({
|
||||
userId: dto.userId,
|
||||
albumId: dto.albumId,
|
||||
assetId: dto.assetId,
|
||||
assetId: dto.level === ReactionLevel.ALBUM ? null : dto.assetId,
|
||||
isLiked: dto.type && dto.type === ReactionType.LIKE,
|
||||
});
|
||||
|
||||
|
@ -54,11 +55,12 @@ export class ActivityService {
|
|||
let activity: ActivityEntity | null = null;
|
||||
let duplicate = false;
|
||||
|
||||
if (dto.type === 'like') {
|
||||
if (dto.type === ReactionType.LIKE) {
|
||||
delete dto.comment;
|
||||
[activity] = await this.repository.search({
|
||||
...common,
|
||||
isGlobal: !dto.assetId,
|
||||
// `null` will search for an album like
|
||||
assetId: dto.assetId ?? null,
|
||||
isLiked: true,
|
||||
});
|
||||
duplicate = !!activity;
|
||||
|
|
|
@ -6,10 +6,9 @@ import { ActivityEntity } from '../entities/activity.entity';
|
|||
|
||||
export interface ActivitySearch {
|
||||
albumId?: string;
|
||||
assetId?: string;
|
||||
assetId?: string | null;
|
||||
userId?: string;
|
||||
isLiked?: boolean;
|
||||
isGlobal?: boolean;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
@ -17,11 +16,11 @@ export class ActivityRepository implements IActivityRepository {
|
|||
constructor(@InjectRepository(ActivityEntity) private repository: Repository<ActivityEntity>) {}
|
||||
|
||||
search(options: ActivitySearch): Promise<ActivityEntity[]> {
|
||||
const { userId, assetId, albumId, isLiked, isGlobal } = options;
|
||||
const { userId, assetId, albumId, isLiked } = options;
|
||||
return this.repository.find({
|
||||
where: {
|
||||
userId,
|
||||
assetId: isGlobal ? IsNull() : assetId,
|
||||
assetId: assetId === null ? IsNull() : assetId,
|
||||
albumId,
|
||||
isLiked,
|
||||
},
|
||||
|
|
|
@ -247,6 +247,20 @@ describe(`${ActivityController.name} (e2e)`, () => {
|
|||
expect(body).toEqual(reaction);
|
||||
});
|
||||
|
||||
it('should not confuse an album like with an asset like', async () => {
|
||||
const reaction = await api.activityApi.create(server, admin.accessToken, {
|
||||
albumId: album.id,
|
||||
assetId: asset.id,
|
||||
type: ReactionType.LIKE,
|
||||
});
|
||||
const { status, body } = await request(server)
|
||||
.post('/activity')
|
||||
.set('Authorization', `Bearer ${admin.accessToken}`)
|
||||
.send({ albumId: album.id, type: 'like' });
|
||||
expect(status).toEqual(201);
|
||||
expect(body.id).not.toEqual(reaction.id);
|
||||
});
|
||||
|
||||
it('should add a comment to an asset', async () => {
|
||||
const { status, body } = await request(server)
|
||||
.post('/activity')
|
||||
|
|
37
web/src/api/open-api/api.ts
generated
37
web/src/api/open-api/api.ts
generated
|
@ -2570,6 +2570,20 @@ export interface QueueStatusDto {
|
|||
*/
|
||||
'isPaused': boolean;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
|
||||
export const ReactionLevel = {
|
||||
Album: 'album',
|
||||
Asset: 'asset'
|
||||
} as const;
|
||||
|
||||
export type ReactionLevel = typeof ReactionLevel[keyof typeof ReactionLevel];
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
|
@ -5065,11 +5079,12 @@ export const ActivityApiAxiosParamCreator = function (configuration?: Configurat
|
|||
* @param {string} albumId
|
||||
* @param {string} [assetId]
|
||||
* @param {ReactionType} [type]
|
||||
* @param {ReactionLevel} [level]
|
||||
* @param {string} [userId]
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getActivities: async (albumId: string, assetId?: string, type?: ReactionType, userId?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
getActivities: async (albumId: string, assetId?: string, type?: ReactionType, level?: ReactionLevel, userId?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'albumId' is not null or undefined
|
||||
assertParamExists('getActivities', 'albumId', albumId)
|
||||
const localVarPath = `/activity`;
|
||||
|
@ -5105,6 +5120,10 @@ export const ActivityApiAxiosParamCreator = function (configuration?: Configurat
|
|||
localVarQueryParameter['type'] = type;
|
||||
}
|
||||
|
||||
if (level !== undefined) {
|
||||
localVarQueryParameter['level'] = level;
|
||||
}
|
||||
|
||||
if (userId !== undefined) {
|
||||
localVarQueryParameter['userId'] = userId;
|
||||
}
|
||||
|
@ -5205,12 +5224,13 @@ export const ActivityApiFp = function(configuration?: Configuration) {
|
|||
* @param {string} albumId
|
||||
* @param {string} [assetId]
|
||||
* @param {ReactionType} [type]
|
||||
* @param {ReactionLevel} [level]
|
||||
* @param {string} [userId]
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async getActivities(albumId: string, assetId?: string, type?: ReactionType, userId?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<ActivityResponseDto>>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getActivities(albumId, assetId, type, userId, options);
|
||||
async getActivities(albumId: string, assetId?: string, type?: ReactionType, level?: ReactionLevel, userId?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<ActivityResponseDto>>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getActivities(albumId, assetId, type, level, userId, options);
|
||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||
},
|
||||
/**
|
||||
|
@ -5259,7 +5279,7 @@ export const ActivityApiFactory = function (configuration?: Configuration, baseP
|
|||
* @throws {RequiredError}
|
||||
*/
|
||||
getActivities(requestParameters: ActivityApiGetActivitiesRequest, options?: AxiosRequestConfig): AxiosPromise<Array<ActivityResponseDto>> {
|
||||
return localVarFp.getActivities(requestParameters.albumId, requestParameters.assetId, requestParameters.type, requestParameters.userId, options).then((request) => request(axios, basePath));
|
||||
return localVarFp.getActivities(requestParameters.albumId, requestParameters.assetId, requestParameters.type, requestParameters.level, requestParameters.userId, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
|
@ -5328,6 +5348,13 @@ export interface ActivityApiGetActivitiesRequest {
|
|||
*/
|
||||
readonly type?: ReactionType
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {ReactionLevel}
|
||||
* @memberof ActivityApiGetActivities
|
||||
*/
|
||||
readonly level?: ReactionLevel
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
|
@ -5394,7 +5421,7 @@ export class ActivityApi extends BaseAPI {
|
|||
* @memberof ActivityApi
|
||||
*/
|
||||
public getActivities(requestParameters: ActivityApiGetActivitiesRequest, options?: AxiosRequestConfig) {
|
||||
return ActivityApiFp(this.configuration).getActivities(requestParameters.albumId, requestParameters.assetId, requestParameters.type, requestParameters.userId, options).then((request) => request(this.axios, this.basePath));
|
||||
return ActivityApiFp(this.configuration).getActivities(requestParameters.albumId, requestParameters.assetId, requestParameters.type, requestParameters.level, requestParameters.userId, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
export let assetType: AssetTypeEnum | undefined = undefined;
|
||||
export let albumOwnerId: string;
|
||||
export let disabled: boolean;
|
||||
export let isLiked: ActivityResponseDto | null;
|
||||
|
||||
let textArea: HTMLTextAreaElement;
|
||||
let innerHeight: number;
|
||||
|
@ -105,7 +106,7 @@
|
|||
reactions.splice(index, 1);
|
||||
showDeleteReaction.splice(index, 1);
|
||||
reactions = reactions;
|
||||
if (reaction.type === 'like' && reaction.user.id === user.id) {
|
||||
if (isLiked && reaction.type === 'like' && reaction.id == isLiked.id) {
|
||||
dispatch('deleteLike');
|
||||
} else {
|
||||
dispatch('deleteComment');
|
||||
|
|
|
@ -756,6 +756,7 @@
|
|||
albumOwnerId={album.ownerId}
|
||||
albumId={album.id}
|
||||
assetId={asset.id}
|
||||
{isLiked}
|
||||
bind:reactions
|
||||
on:addComment={handleAddComment}
|
||||
on:deleteComment={handleRemoveComment}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
import { downloadArchive } from '$lib/utils/asset-utils';
|
||||
import { openFileUploadDialog } from '$lib/utils/file-uploader';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { ActivityResponseDto, ReactionType, UserResponseDto, api } from '@api';
|
||||
import { ActivityResponseDto, ReactionLevel, ReactionType, UserResponseDto, api } from '@api';
|
||||
import Icon from '$lib/components/elements/icon.svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { clickOutside } from '$lib/utils/click-outside';
|
||||
|
@ -167,7 +167,6 @@
|
|||
const { data } = await api.activityApi.createActivity({
|
||||
activityCreateDto: { albumId: album.id, type: ReactionType.Like },
|
||||
});
|
||||
|
||||
isLiked = data;
|
||||
reactions = [...reactions, isLiked];
|
||||
}
|
||||
|
@ -183,6 +182,7 @@
|
|||
userId: user.id,
|
||||
albumId: album.id,
|
||||
type: ReactionType.Like,
|
||||
level: ReactionLevel.Album,
|
||||
});
|
||||
if (data.length > 0) {
|
||||
isLiked = data[0];
|
||||
|
@ -687,6 +687,7 @@
|
|||
disabled={!album.isActivityEnabled}
|
||||
albumOwnerId={album.ownerId}
|
||||
albumId={album.id}
|
||||
{isLiked}
|
||||
bind:reactions
|
||||
on:addComment={() => updateNumberOfComments(1)}
|
||||
on:deleteComment={() => updateNumberOfComments(-1)}
|
||||
|
|
Loading…
Reference in a new issue