Changeset View
Changeset View
Standalone View
Standalone View
services/identity/src/service/update.rs
Show All 12 Lines | use super::proto::{ | ||||
update_user_response::Data::PakeRegistrationResponse, | update_user_response::Data::PakeRegistrationResponse, | ||||
PakeRegistrationRequestAndUserId, PakeRegistrationUploadAndCredentialRequest, | PakeRegistrationRequestAndUserId, PakeRegistrationUploadAndCredentialRequest, | ||||
}; | }; | ||||
use crate::service::PakeLoginResponseStruct; | use crate::service::PakeLoginResponseStruct; | ||||
use crate::token::AuthType; | use crate::token::AuthType; | ||||
use crate::{database::DatabaseClient, pake_grpc}; | use crate::{database::DatabaseClient, pake_grpc}; | ||||
use super::{ | use super::{ | ||||
handle_db_error, pake_login_start, put_token_helper, Status, | handle_db_error, pake_login_start, put_token_helper, send_to_client, Status, | ||||
UpdateUserRequest, UpdateUserResponse, | UpdateUserRequest, UpdateUserResponse, | ||||
}; | }; | ||||
async fn send_to_client( | |||||
tx: &tokio::sync::mpsc::Sender<Result<UpdateUserResponse, Status>>, | |||||
response: Result<UpdateUserResponse, Status>, | |||||
) -> Result<(), Status> { | |||||
let transport_result = match response { | |||||
Ok(message) => tx.send(Ok(message)).await, | |||||
Err(status) => { | |||||
error!("{}", status.message()); | |||||
tx.send(Err(status)).await | |||||
} | |||||
}; | |||||
transport_result.map_err(|_| Status::internal("disconnection")) | |||||
} | |||||
pub(crate) async fn handle_server_update_user_messages( | pub(crate) async fn handle_server_update_user_messages( | ||||
in_stream: Streaming<UpdateUserRequest>, | in_stream: Streaming<UpdateUserRequest>, | ||||
client: DatabaseClient, | client: DatabaseClient, | ||||
tx: tokio::sync::mpsc::Sender<Result<UpdateUserResponse, Status>>, | tx: tokio::sync::mpsc::Sender<Result<UpdateUserResponse, Status>>, | ||||
) { | ) { | ||||
match attempt_update_user(in_stream, &client, &tx).await { | match attempt_update_user(in_stream, &client, &tx).await { | ||||
Ok(user_id) => info!("Successfully updated user {}", user_id), | Ok(user_id) => info!("Successfully updated user {}", user_id), | ||||
// Attempt to send client the failure to receive immediate feedback | // Attempt to send client the failure to receive immediate feedback | ||||
▲ Show 20 Lines • Show All 249 Lines • Show Last 20 Lines |