Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
fix not found error
Browse files Browse the repository at this point in the history
  • Loading branch information
ImSoZRious committed Aug 1, 2023
1 parent 4c18af7 commit 57f474d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/service/estamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rpkm66_rust_proto::rpkm66::{
user::v1::{AddEventRequest, GetAllUserEventsByNamespaceIdRequest},
},
};
use tonic::transport::Channel;
use tonic::{transport::Channel, Code};

use crate::{error::Error, handler::user, Result};

Expand Down Expand Up @@ -98,16 +98,22 @@ impl Service {
}

pub async fn has_redeem_item(&self, user_id: String) -> Result<bool> {
self.user_client
let req = self
.user_client
.clone()
.get_user_event_by_event_id(GetUserEventByEventIdRequest {
event_id: "redeem-item".to_string(),
user_id,
})
.await?
.into_inner()
.user_event
.ok_or(Error::NotFound)
.map(|x| x.is_taken)
.await;

match req {
Ok(x) => match x.into_inner().user_event {
Some(y) => Ok(y.is_taken),
None => Ok(false),
},
Err(e) if e.code() == Code::NotFound => Ok(false),
Err(e) => Err(e.into()),
}
}
}

0 comments on commit 57f474d

Please sign in to comment.