mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
fix(server): use UserMetadataKey enum instead of string (#20209)
* fix(server): use UserMetadataKey enum instead of string * fix: mobile
This commit is contained in:
parent
ed5759fe07
commit
25e2d37490
11 changed files with 30 additions and 11 deletions
|
|
@ -20,8 +20,8 @@ import 'package:immich_mobile/infrastructure/entities/user.entity.drift.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.drift.dart';
|
import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.drift.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
import 'package:immich_mobile/infrastructure/repositories/db.repository.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:openapi/api.dart' as api show AssetVisibility, AlbumUserRole;
|
import 'package:openapi/api.dart' as api show AssetVisibility, AlbumUserRole, UserMetadataKey;
|
||||||
import 'package:openapi/api.dart' hide AssetVisibility, AlbumUserRole;
|
import 'package:openapi/api.dart' hide AssetVisibility, AlbumUserRole, UserMetadataKey;
|
||||||
|
|
||||||
class SyncStreamRepository extends DriftDatabaseRepository {
|
class SyncStreamRepository extends DriftDatabaseRepository {
|
||||||
final Logger _logger = Logger('DriftSyncStreamRepository');
|
final Logger _logger = Logger('DriftSyncStreamRepository');
|
||||||
|
|
@ -647,11 +647,11 @@ extension on api.AssetVisibility {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
extension on String {
|
extension on api.UserMetadataKey {
|
||||||
UserMetadataKey toUserMetadataKey() => switch (this) {
|
UserMetadataKey toUserMetadataKey() => switch (this) {
|
||||||
"onboarding" => UserMetadataKey.onboarding,
|
api.UserMetadataKey.onboarding => UserMetadataKey.onboarding,
|
||||||
"preferences" => UserMetadataKey.preferences,
|
api.UserMetadataKey.preferences => UserMetadataKey.preferences,
|
||||||
"license" => UserMetadataKey.license,
|
api.UserMetadataKey.license => UserMetadataKey.license,
|
||||||
_ => throw Exception('Unknown UserMetadataKey value: $this'),
|
_ => throw Exception('Unknown UserMetadataKey value: $this'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
mobile/openapi/README.md
generated
BIN
mobile/openapi/README.md
generated
Binary file not shown.
BIN
mobile/openapi/lib/api.dart
generated
BIN
mobile/openapi/lib/api.dart
generated
Binary file not shown.
BIN
mobile/openapi/lib/api_client.dart
generated
BIN
mobile/openapi/lib/api_client.dart
generated
Binary file not shown.
BIN
mobile/openapi/lib/api_helper.dart
generated
BIN
mobile/openapi/lib/api_helper.dart
generated
Binary file not shown.
Binary file not shown.
BIN
mobile/openapi/lib/model/sync_user_metadata_v1.dart
generated
BIN
mobile/openapi/lib/model/sync_user_metadata_v1.dart
generated
Binary file not shown.
BIN
mobile/openapi/lib/model/user_metadata_key.dart
generated
Normal file
BIN
mobile/openapi/lib/model/user_metadata_key.dart
generated
Normal file
Binary file not shown.
|
|
@ -14403,7 +14403,11 @@
|
||||||
"SyncUserMetadataDeleteV1": {
|
"SyncUserMetadataDeleteV1": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"key": {
|
"key": {
|
||||||
"type": "string"
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/UserMetadataKey"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"userId": {
|
"userId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|
@ -14418,7 +14422,11 @@
|
||||||
"SyncUserMetadataV1": {
|
"SyncUserMetadataV1": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"key": {
|
"key": {
|
||||||
"type": "string"
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/UserMetadataKey"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"userId": {
|
"userId": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|
@ -16132,6 +16140,14 @@
|
||||||
],
|
],
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"UserMetadataKey": {
|
||||||
|
"enum": [
|
||||||
|
"preferences",
|
||||||
|
"license",
|
||||||
|
"onboarding"
|
||||||
|
],
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"UserPreferencesResponseDto": {
|
"UserPreferencesResponseDto": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"albums": {
|
"albums": {
|
||||||
|
|
|
||||||
|
|
@ -301,14 +301,16 @@ export class SyncAssetFaceDeleteV1 {
|
||||||
@ExtraModel()
|
@ExtraModel()
|
||||||
export class SyncUserMetadataV1 {
|
export class SyncUserMetadataV1 {
|
||||||
userId!: string;
|
userId!: string;
|
||||||
key!: string;
|
@ValidateEnum({ enum: UserMetadataKey, name: 'UserMetadataKey' })
|
||||||
|
key!: UserMetadataKey;
|
||||||
value!: UserMetadata[UserMetadataKey];
|
value!: UserMetadata[UserMetadataKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExtraModel()
|
@ExtraModel()
|
||||||
export class SyncUserMetadataDeleteV1 {
|
export class SyncUserMetadataDeleteV1 {
|
||||||
userId!: string;
|
userId!: string;
|
||||||
key!: string;
|
@ValidateEnum({ enum: UserMetadataKey, name: 'UserMetadataKey' })
|
||||||
|
key!: UserMetadataKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExtraModel()
|
@ExtraModel()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { PrimaryGeneratedUuidV7Column } from 'src/decorators';
|
import { PrimaryGeneratedUuidV7Column } from 'src/decorators';
|
||||||
|
import { UserMetadataKey } from 'src/enum';
|
||||||
import { Column, CreateDateColumn, Generated, Table, Timestamp } from 'src/sql-tools';
|
import { Column, CreateDateColumn, Generated, Table, Timestamp } from 'src/sql-tools';
|
||||||
|
|
||||||
@Table('user_metadata_audit')
|
@Table('user_metadata_audit')
|
||||||
|
|
@ -10,7 +11,7 @@ export class UserMetadataAuditTable {
|
||||||
userId!: string;
|
userId!: string;
|
||||||
|
|
||||||
@Column({ indexName: 'IDX_user_metadata_audit_key' })
|
@Column({ indexName: 'IDX_user_metadata_audit_key' })
|
||||||
key!: string;
|
key!: UserMetadataKey;
|
||||||
|
|
||||||
@CreateDateColumn({ default: () => 'clock_timestamp()', indexName: 'IDX_user_metadata_audit_deleted_at' })
|
@CreateDateColumn({ default: () => 'clock_timestamp()', indexName: 'IDX_user_metadata_audit_deleted_at' })
|
||||||
deletedAt!: Generated<Timestamp>;
|
deletedAt!: Generated<Timestamp>;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue