Add redeem invite
This commit is contained in:
parent
fdaa75f43d
commit
7bf91edbaa
|
@ -120,6 +120,10 @@ async fn handle(
|
|||
let bytes = body::to_bytes(req.into_body()).await.unwrap();
|
||||
verify_and_send_issue_invite(bytes, context.ba)
|
||||
}),
|
||||
(&Method::POST, "/redeem") => Ok::<_, Infallible>({
|
||||
let bytes = body::to_bytes(req.into_body()).await.unwrap();
|
||||
verify_and_send_redeem_invite(bytes, context.ba)
|
||||
}),
|
||||
_ => {
|
||||
// Return 404 not found response.
|
||||
Ok(Response::builder()
|
||||
|
@ -219,6 +223,15 @@ fn verify_and_send_issue_invite(request: Bytes, ba: Arc<Mutex<BridgeAuth>>) -> R
|
|||
prepare_header(issue_invite_resp_str)
|
||||
}
|
||||
|
||||
fn verify_and_send_redeem_invite(request: Bytes, ba: Arc<Mutex<BridgeAuth>>) -> Response<Body> {
|
||||
let req: proto::redeem_invite::Request = serde_json::from_slice(&request).unwrap();
|
||||
let mut ba_obj = ba.lock().unwrap();
|
||||
let response = ba_obj.handle_redeem_invite(req).unwrap();
|
||||
let issue_invite_resp_str = serde_json::to_string(&response).unwrap();
|
||||
prepare_header(issue_invite_resp_str)
|
||||
}
|
||||
|
||||
|
||||
|
||||
fn prepare_header(response: String) -> Response<Body> {
|
||||
let mut resp = Response::new(Body::from(response));
|
||||
|
|
Loading…
Reference in New Issue