mirror of
https://github.com/immich-app/immich.git
synced 2025-01-28 06:32:44 +01:00
refactor(server): /user profile endpoint (#9669)
* refactor(server): user profile endpoint * chore: open api
This commit is contained in:
parent
ecd018a826
commit
8f37784eae
8 changed files with 57 additions and 57 deletions
mobile
open-api
server/src/controllers
web/src/lib
|
@ -6,7 +6,7 @@ import 'package:immich_mobile/entities/user.entity.dart';
|
||||||
|
|
||||||
Widget userAvatar(BuildContext context, User u, {double? radius}) {
|
Widget userAvatar(BuildContext context, User u, {double? radius}) {
|
||||||
final url =
|
final url =
|
||||||
"${Store.get(StoreKey.serverEndpoint)}/user/profile-image/${u.id}";
|
"${Store.get(StoreKey.serverEndpoint)}/users/${u.id}/profile-image";
|
||||||
final nameFirstLetter = u.name.isNotEmpty ? u.name[0] : "";
|
final nameFirstLetter = u.name.isNotEmpty ? u.name[0] : "";
|
||||||
return CircleAvatar(
|
return CircleAvatar(
|
||||||
radius: radius,
|
radius: radius,
|
||||||
|
|
|
@ -24,7 +24,7 @@ class UserCircleAvatar extends ConsumerWidget {
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
bool isDarkTheme = Theme.of(context).brightness == Brightness.dark;
|
bool isDarkTheme = Theme.of(context).brightness == Brightness.dark;
|
||||||
final profileImageUrl =
|
final profileImageUrl =
|
||||||
'${Store.get(StoreKey.serverEndpoint)}/user/profile-image/${user.id}?d=${Random().nextInt(1024)}';
|
'${Store.get(StoreKey.serverEndpoint)}/users/${user.id}/profile-image?d=${Random().nextInt(1024)}';
|
||||||
|
|
||||||
final textIcon = Text(
|
final textIcon = Text(
|
||||||
user.name[0].toUpperCase(),
|
user.name[0].toUpperCase(),
|
||||||
|
|
BIN
mobile/openapi/README.md
generated
BIN
mobile/openapi/README.md
generated
Binary file not shown.
BIN
mobile/openapi/lib/api/user_api.dart
generated
BIN
mobile/openapi/lib/api/user_api.dart
generated
Binary file not shown.
|
@ -6327,49 +6327,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/users/profile-image/{id}": {
|
|
||||||
"get": {
|
|
||||||
"operationId": "getProfileImage",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"schema": {
|
|
||||||
"format": "uuid",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"content": {
|
|
||||||
"application/octet-stream": {
|
|
||||||
"schema": {
|
|
||||||
"format": "binary",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"description": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"bearer": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cookie": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"api_key": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"User"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/users/{id}": {
|
"/users/{id}": {
|
||||||
"delete": {
|
"delete": {
|
||||||
"operationId": "deleteUser",
|
"operationId": "deleteUser",
|
||||||
|
@ -6462,6 +6419,49 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/users/{id}/profile-image": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "getProfileImage",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"format": "uuid",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"content": {
|
||||||
|
"application/octet-stream": {
|
||||||
|
"schema": {
|
||||||
|
"format": "binary",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"bearer": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cookie": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"api_key": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"User"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/users/{id}/restore": {
|
"/users/{id}/restore": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "restoreUser",
|
"operationId": "restoreUser",
|
||||||
|
|
|
@ -2776,16 +2776,6 @@ export function createProfileImage({ createProfileImageDto }: {
|
||||||
body: createProfileImageDto
|
body: createProfileImageDto
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
export function getProfileImage({ id }: {
|
|
||||||
id: string;
|
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
|
||||||
return oazapfts.ok(oazapfts.fetchBlob<{
|
|
||||||
status: 200;
|
|
||||||
data: Blob;
|
|
||||||
}>(`/users/profile-image/${encodeURIComponent(id)}`, {
|
|
||||||
...opts
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
export function deleteUser({ id, deleteUserDto }: {
|
export function deleteUser({ id, deleteUserDto }: {
|
||||||
id: string;
|
id: string;
|
||||||
deleteUserDto: DeleteUserDto;
|
deleteUserDto: DeleteUserDto;
|
||||||
|
@ -2809,6 +2799,16 @@ export function getUserById({ id }: {
|
||||||
...opts
|
...opts
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
export function getProfileImage({ id }: {
|
||||||
|
id: string;
|
||||||
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
|
return oazapfts.ok(oazapfts.fetchBlob<{
|
||||||
|
status: 200;
|
||||||
|
data: Blob;
|
||||||
|
}>(`/users/${encodeURIComponent(id)}/profile-image`, {
|
||||||
|
...opts
|
||||||
|
}));
|
||||||
|
}
|
||||||
export function restoreUser({ id }: {
|
export function restoreUser({ id }: {
|
||||||
id: string;
|
id: string;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ export class UserController {
|
||||||
return this.service.createProfileImage(auth, fileInfo);
|
return this.service.createProfileImage(auth, fileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('profile-image/:id')
|
@Get(':id/profile-image')
|
||||||
@FileResponse()
|
@FileResponse()
|
||||||
@Authenticated()
|
@Authenticated()
|
||||||
async getProfileImage(@Res() res: Response, @Next() next: NextFunction, @Param() { id }: UUIDParamDto) {
|
async getProfileImage(@Res() res: Response, @Next() next: NextFunction, @Param() { id }: UUIDParamDto) {
|
||||||
|
|
|
@ -169,7 +169,7 @@ export const getAssetThumbnailUrl = (...[assetId, format]: [string, ThumbnailFor
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getProfileImageUrl = (...[userId]: [string]) => {
|
export const getProfileImageUrl = (...[userId]: [string]) => {
|
||||||
const path = `/user/profile-image/${userId}`;
|
const path = `/users/${userId}/profile-image`;
|
||||||
return createUrl(path);
|
return createUrl(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue