mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 02:27:08 -04:00 
			
		
		
		
	refactor(server): user info endpoint (#9668)
* refactor(server): user info endpoint * chore: open api
This commit is contained in:
		
							parent
							
								
									202745f14b
								
							
						
					
					
						commit
						ecd018a826
					
				| @ -93,15 +93,15 @@ describe('/users', () => { | ||||
|     }); | ||||
|   }); | ||||
| 
 | ||||
|   describe('GET /users/info/:id', () => { | ||||
|   describe('GET /users/:id', () => { | ||||
|     it('should require authentication', async () => { | ||||
|       const { status } = await request(app).get(`/users/info/${admin.userId}`); | ||||
|       const { status } = await request(app).get(`/users/${admin.userId}`); | ||||
|       expect(status).toEqual(401); | ||||
|     }); | ||||
| 
 | ||||
|     it('should get the user info', async () => { | ||||
|       const { status, body } = await request(app) | ||||
|         .get(`/users/info/${admin.userId}`) | ||||
|         .get(`/users/${admin.userId}`) | ||||
|         .set('Authorization', `Bearer ${admin.accessToken}`); | ||||
|       expect(status).toBe(200); | ||||
|       expect(body).toMatchObject({ | ||||
|  | ||||
							
								
								
									
										2
									
								
								mobile/openapi/README.md
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								mobile/openapi/README.md
									
									
									
										generated
									
									
									
								
							| @ -220,7 +220,7 @@ Class | Method | HTTP request | Description | ||||
| *UserApi* | [**getAllUsers**](doc//UserApi.md#getallusers) | **GET** /users |  | ||||
| *UserApi* | [**getMyUserInfo**](doc//UserApi.md#getmyuserinfo) | **GET** /users/me |  | ||||
| *UserApi* | [**getProfileImage**](doc//UserApi.md#getprofileimage) | **GET** /users/profile-image/{id} |  | ||||
| *UserApi* | [**getUserById**](doc//UserApi.md#getuserbyid) | **GET** /users/info/{id} |  | ||||
| *UserApi* | [**getUserById**](doc//UserApi.md#getuserbyid) | **GET** /users/{id} |  | ||||
| *UserApi* | [**restoreUser**](doc//UserApi.md#restoreuser) | **POST** /users/{id}/restore |  | ||||
| *UserApi* | [**updateUser**](doc//UserApi.md#updateuser) | **PUT** /users |  | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										4
									
								
								mobile/openapi/lib/api/user_api.dart
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								mobile/openapi/lib/api/user_api.dart
									
									
									
										generated
									
									
									
								
							| @ -346,13 +346,13 @@ class UserApi { | ||||
|     return null; | ||||
|   } | ||||
| 
 | ||||
|   /// Performs an HTTP 'GET /users/info/{id}' operation and returns the [Response]. | ||||
|   /// Performs an HTTP 'GET /users/{id}' operation and returns the [Response]. | ||||
|   /// Parameters: | ||||
|   /// | ||||
|   /// * [String] id (required): | ||||
|   Future<Response> getUserByIdWithHttpInfo(String id,) async { | ||||
|     // ignore: prefer_const_declarations | ||||
|     final path = r'/users/info/{id}' | ||||
|     final path = r'/users/{id}' | ||||
|       .replaceAll('{id}', id); | ||||
| 
 | ||||
|     // ignore: prefer_final_locals | ||||
|  | ||||
| @ -6229,48 +6229,6 @@ | ||||
|         ] | ||||
|       } | ||||
|     }, | ||||
|     "/users/info/{id}": { | ||||
|       "get": { | ||||
|         "operationId": "getUserById", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "required": true, | ||||
|             "in": "path", | ||||
|             "schema": { | ||||
|               "format": "uuid", | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "content": { | ||||
|               "application/json": { | ||||
|                 "schema": { | ||||
|                   "$ref": "#/components/schemas/UserResponseDto" | ||||
|                 } | ||||
|               } | ||||
|             }, | ||||
|             "description": "" | ||||
|           } | ||||
|         }, | ||||
|         "security": [ | ||||
|           { | ||||
|             "bearer": [] | ||||
|           }, | ||||
|           { | ||||
|             "cookie": [] | ||||
|           }, | ||||
|           { | ||||
|             "api_key": [] | ||||
|           } | ||||
|         ], | ||||
|         "tags": [ | ||||
|           "User" | ||||
|         ] | ||||
|       } | ||||
|     }, | ||||
|     "/users/me": { | ||||
|       "get": { | ||||
|         "operationId": "getMyUserInfo", | ||||
| @ -6462,6 +6420,46 @@ | ||||
|         "tags": [ | ||||
|           "User" | ||||
|         ] | ||||
|       }, | ||||
|       "get": { | ||||
|         "operationId": "getUserById", | ||||
|         "parameters": [ | ||||
|           { | ||||
|             "name": "id", | ||||
|             "required": true, | ||||
|             "in": "path", | ||||
|             "schema": { | ||||
|               "format": "uuid", | ||||
|               "type": "string" | ||||
|             } | ||||
|           } | ||||
|         ], | ||||
|         "responses": { | ||||
|           "200": { | ||||
|             "content": { | ||||
|               "application/json": { | ||||
|                 "schema": { | ||||
|                   "$ref": "#/components/schemas/UserResponseDto" | ||||
|                 } | ||||
|               } | ||||
|             }, | ||||
|             "description": "" | ||||
|           } | ||||
|         }, | ||||
|         "security": [ | ||||
|           { | ||||
|             "bearer": [] | ||||
|           }, | ||||
|           { | ||||
|             "cookie": [] | ||||
|           }, | ||||
|           { | ||||
|             "api_key": [] | ||||
|           } | ||||
|         ], | ||||
|         "tags": [ | ||||
|           "User" | ||||
|         ] | ||||
|       } | ||||
|     }, | ||||
|     "/users/{id}/restore": { | ||||
|  | ||||
| @ -2750,16 +2750,6 @@ export function updateUser({ updateUserDto }: { | ||||
|         body: updateUserDto | ||||
|     }))); | ||||
| } | ||||
| export function getUserById({ id }: { | ||||
|     id: string; | ||||
| }, opts?: Oazapfts.RequestOpts) { | ||||
|     return oazapfts.ok(oazapfts.fetchJson<{ | ||||
|         status: 200; | ||||
|         data: UserResponseDto; | ||||
|     }>(`/users/info/${encodeURIComponent(id)}`, { | ||||
|         ...opts | ||||
|     })); | ||||
| } | ||||
| export function getMyUserInfo(opts?: Oazapfts.RequestOpts) { | ||||
|     return oazapfts.ok(oazapfts.fetchJson<{ | ||||
|         status: 200; | ||||
| @ -2809,6 +2799,16 @@ export function deleteUser({ id, deleteUserDto }: { | ||||
|         body: deleteUserDto | ||||
|     }))); | ||||
| } | ||||
| export function getUserById({ id }: { | ||||
|     id: string; | ||||
| }, opts?: Oazapfts.RequestOpts) { | ||||
|     return oazapfts.ok(oazapfts.fetchJson<{ | ||||
|         status: 200; | ||||
|         data: UserResponseDto; | ||||
|     }>(`/users/${encodeURIComponent(id)}`, { | ||||
|         ...opts | ||||
|     })); | ||||
| } | ||||
| export function restoreUser({ id }: { | ||||
|     id: string; | ||||
| }, opts?: Oazapfts.RequestOpts) { | ||||
|  | ||||
| @ -41,10 +41,10 @@ export class UserController { | ||||
|     return this.service.getAll(auth, isAll); | ||||
|   } | ||||
| 
 | ||||
|   @Get('info/:id') | ||||
|   @Authenticated() | ||||
|   getUserById(@Param() { id }: UUIDParamDto): Promise<UserResponseDto> { | ||||
|     return this.service.get(id); | ||||
|   @Post() | ||||
|   @Authenticated({ admin: true }) | ||||
|   createUser(@Body() createUserDto: CreateUserDto): Promise<UserResponseDto> { | ||||
|     return this.service.create(createUserDto); | ||||
|   } | ||||
| 
 | ||||
|   @Get('me') | ||||
| @ -53,10 +53,10 @@ export class UserController { | ||||
|     return this.service.getMe(auth); | ||||
|   } | ||||
| 
 | ||||
|   @Post() | ||||
|   @Authenticated({ admin: true }) | ||||
|   createUser(@Body() createUserDto: CreateUserDto): Promise<UserResponseDto> { | ||||
|     return this.service.create(createUserDto); | ||||
|   @Get(':id') | ||||
|   @Authenticated() | ||||
|   getUserById(@Param() { id }: UUIDParamDto): Promise<UserResponseDto> { | ||||
|     return this.service.get(id); | ||||
|   } | ||||
| 
 | ||||
|   @Delete('profile-image') | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user