- add: ability to refresh the current session
- add: delete type to delete character request - add: ability to update key in redis - add: handle alive packet to refresh the session - fix: delete now actually returns the time remaining correctly - fix: character list now has the correct time until character deletion
This commit is contained in:
@@ -161,10 +161,11 @@ impl CharacterDbClient {
|
||||
Ok(response.into_inner())
|
||||
}
|
||||
|
||||
pub async fn delete_character(&mut self, user_id: &str, char_id: &str) -> Result<DeleteCharacterResponse, Box<dyn std::error::Error>> {
|
||||
pub async fn delete_character(&mut self, user_id: &str, char_id: &str, delete_type: i32) -> Result<DeleteCharacterResponse, Box<dyn std::error::Error>> {
|
||||
let request = tonic::Request::new(DeleteCharacterRequest {
|
||||
user_id: user_id.parse().unwrap(),
|
||||
character_id: char_id.parse().unwrap(),
|
||||
delete_type,
|
||||
});
|
||||
let response = self.client.delete_character(request).await?;
|
||||
Ok(response.into_inner())
|
||||
|
||||
@@ -38,7 +38,7 @@ impl CharacterService for MyCharacterService {
|
||||
character_id: character.id.to_string(),
|
||||
name: character.name,
|
||||
last_played: 0,
|
||||
delete_time: 0,
|
||||
delete_time: character.deleted_at.parse().unwrap_or_default(),
|
||||
stats: serde_json::from_str(&character.stats).unwrap(),
|
||||
looks: serde_json::from_str(&character.looks).unwrap(),
|
||||
items: serde_json::from_str(&character.inventory).unwrap(),
|
||||
@@ -66,7 +66,7 @@ impl CharacterService for MyCharacterService {
|
||||
let req = request.into_inner();
|
||||
debug!("{:?}", req);
|
||||
|
||||
let delete_character_response = self.character_db_client.as_ref().clone().delete_character(&req.user_id, &req.char_id).await.map_err(|_| Status::not_found("Character not found"))?;
|
||||
let delete_character_response = self.character_db_client.as_ref().clone().delete_character(&req.user_id, &req.char_id, req.delete_type).await.map_err(|_| Status::not_found("Character not found"))?;
|
||||
let response = DeleteCharacterResponse { remaining_time: delete_character_response.remaining_time, name: delete_character_response.name };
|
||||
Ok(Response::new(response))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user