2024-09-24 14:50:21 +02:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
|
|
import 'package:http/http.dart';
|
2025-03-12 19:26:56 +05:30
|
|
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
2025-03-14 08:50:26 +05:30
|
|
|
import 'package:immich_mobile/infrastructure/repositories/api.repository.dart';
|
2025-03-12 19:26:56 +05:30
|
|
|
import 'package:immich_mobile/infrastructure/utils/user.converter.dart';
|
2024-09-24 14:50:21 +02:00
|
|
|
import 'package:openapi/api.dart';
|
|
|
|
|
|
2025-06-19 18:25:18 -05:00
|
|
|
class UserApiRepository extends ApiRepository {
|
2024-09-24 14:50:21 +02:00
|
|
|
final UsersApi _api;
|
2025-03-14 08:50:26 +05:30
|
|
|
const UserApiRepository(this._api);
|
2024-09-24 14:50:21 +02:00
|
|
|
|
2025-03-14 08:50:26 +05:30
|
|
|
Future<UserDto?> getMyUser() async {
|
2025-07-25 08:07:22 +05:30
|
|
|
final (adminDto, preferenceDto) = await (_api.getMyUser(), _api.getMyPreferences()).wait;
|
2025-03-14 08:50:26 +05:30
|
|
|
if (adminDto == null) return null;
|
|
|
|
|
|
|
|
|
|
return UserConverter.fromAdminDto(adminDto, preferenceDto);
|
2024-09-24 14:50:21 +02:00
|
|
|
}
|
|
|
|
|
|
2025-07-29 00:34:03 +05:30
|
|
|
Future<String> createProfileImage({required String name, required Uint8List data}) async {
|
|
|
|
|
final res = await checkNull(_api.createProfileImage(MultipartFile.fromBytes('file', data, filename: name)));
|
2025-03-14 08:50:26 +05:30
|
|
|
return res.profileImagePath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<List<UserDto>> getAll() async {
|
|
|
|
|
final dto = await checkNull(_api.searchUsers());
|
|
|
|
|
return dto.map(UserConverter.fromSimpleUserDto).toList();
|
2024-09-24 14:50:21 +02:00
|
|
|
}
|
|
|
|
|
}
|