use prost::Message; use sellershut_core::profile::{ CompleteUserRequest, CreateUserRequest, CreateUserResponse, User, profile_server::Profile, }; use stack_up::redis::AsyncCommands; use tonic::{Request, Response, Status, async_trait}; use tracing::trace; use uuid::Uuid; use crate::state::AppHandle; #[async_trait] impl Profile for AppHandle { #[doc = " Create a new user profile"] async fn create_user( &self, request: Request, ) -> Result, Status> { trace!("creating user"); let data = request.into_inner(); let id = Uuid::now_v7().to_string(); let bytes = data.encode_to_vec(); let mut cache = self .services .cache .get() .await .map_err(|e| Status::internal("storage not ready"))?; cache .set_ex::<_, _, ()>(&id, &bytes, self.local_config.temp_ttl) .await .map_err(|e| Status::internal("storage not ready"))?; Ok(Response::new(CreateUserResponse { temp_id: id })) } #[doc = " Complete Profile"] async fn complete_profile( &self, request: Request, ) -> Result, Status> { todo!() } }