mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 18:17:13 +08:00 
			
		
		
		
	refactor(core): Add additional parameters in AppState and refactor AppState references (#2123)
Co-authored-by: Kritik Modi <kritik.modi@juspay.in> Co-authored-by: Kritik Modi <61862301+kritikmodi@users.noreply.github.com> Co-authored-by: Nitesh Balla <nitesh.balla@juspay.in>
This commit is contained in:
		 Abhishek Marrivagu
					Abhishek Marrivagu
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							b39369ced9
						
					
				
				
					commit
					a0a8ef27b3
				
			| @ -17,13 +17,17 @@ use crate::{ | ||||
| }; | ||||
|  | ||||
| pub async fn files_create_core( | ||||
|     state: &AppState, | ||||
|     state: AppState, | ||||
|     merchant_account: domain::MerchantAccount, | ||||
|     key_store: domain::MerchantKeyStore, | ||||
|     create_file_request: api::CreateFileRequest, | ||||
| ) -> RouterResponse<files::CreateFileResponse> { | ||||
|     helpers::validate_file_upload(state, merchant_account.clone(), create_file_request.clone()) | ||||
|         .await?; | ||||
|     helpers::validate_file_upload( | ||||
|         &state, | ||||
|         merchant_account.clone(), | ||||
|         create_file_request.clone(), | ||||
|     ) | ||||
|     .await?; | ||||
|     let file_id = common_utils::generate_id(consts::ID_LENGTH, "file"); | ||||
|     #[cfg(feature = "s3")] | ||||
|     let file_key = format!("{}/{}", merchant_account.merchant_id, file_id); | ||||
| @ -49,7 +53,7 @@ pub async fn files_create_core( | ||||
|         .attach_printable("Unable to insert file_metadata")?; | ||||
|     let (provider_file_id, file_upload_provider, connector_label) = | ||||
|         helpers::upload_and_get_provider_provider_file_id_profile_id( | ||||
|             state, | ||||
|             &state, | ||||
|             &merchant_account, | ||||
|             &key_store, | ||||
|             &create_file_request, | ||||
| @ -65,6 +69,7 @@ pub async fn files_create_core( | ||||
|     }; | ||||
|     state | ||||
|         .store | ||||
|         .as_ref() | ||||
|         .update_file_metadata(file_metadata_object, update_file_metadata) | ||||
|         .await | ||||
|         .change_context(errors::ApiErrorResponse::InternalServerError) | ||||
| @ -77,13 +82,14 @@ pub async fn files_create_core( | ||||
| } | ||||
|  | ||||
| pub async fn files_delete_core( | ||||
|     state: &AppState, | ||||
|     state: AppState, | ||||
|     merchant_account: domain::MerchantAccount, | ||||
|     req: api::FileId, | ||||
| ) -> RouterResponse<serde_json::Value> { | ||||
|     helpers::delete_file_using_file_id(state, req.file_id.clone(), &merchant_account).await?; | ||||
|     helpers::delete_file_using_file_id(&state, req.file_id.clone(), &merchant_account).await?; | ||||
|     state | ||||
|         .store | ||||
|         .as_ref() | ||||
|         .delete_file_metadata_by_merchant_id_file_id(&merchant_account.merchant_id, &req.file_id) | ||||
|         .await | ||||
|         .change_context(errors::ApiErrorResponse::InternalServerError) | ||||
| @ -92,20 +98,21 @@ pub async fn files_delete_core( | ||||
| } | ||||
|  | ||||
| pub async fn files_retrieve_core( | ||||
|     state: &AppState, | ||||
|     state: AppState, | ||||
|     merchant_account: domain::MerchantAccount, | ||||
|     key_store: domain::MerchantKeyStore, | ||||
|     req: api::FileId, | ||||
| ) -> RouterResponse<serde_json::Value> { | ||||
|     let file_metadata_object = state | ||||
|         .store | ||||
|         .as_ref() | ||||
|         .find_file_metadata_by_merchant_id_file_id(&merchant_account.merchant_id, &req.file_id) | ||||
|         .await | ||||
|         .change_context(errors::ApiErrorResponse::FileNotFound) | ||||
|         .attach_printable("Unable to retrieve file_metadata")?; | ||||
|     let (received_data, _provider_file_id) = | ||||
|         helpers::retrieve_file_and_provider_file_id_from_file_id( | ||||
|             state, | ||||
|             &state, | ||||
|             Some(req.file_id), | ||||
|             &merchant_account, | ||||
|             &key_store, | ||||
|  | ||||
		Reference in New Issue
	
	Block a user