Skip to content

Commit

Permalink
ws::users > handle_cert_set accept multi param types
Browse files Browse the repository at this point in the history
  • Loading branch information
canewsin committed Jan 23, 2024
1 parent a3eacdf commit c02e8a2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/plugins/websocket/handlers/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,24 @@ pub fn _handle_user_show_master_seed(
pub fn handle_cert_set(ws: &mut ZeruWebsocket, command: &Command) -> Result<Message, Error> {
trace!("Handling CertSet with command: {:?}", command);
let site = ws.address.address.clone();
let provider = command.params.as_str().unwrap().to_string();
let provider = match &command.params {
Value::String(provider) => Ok(provider.clone()),
Value::Array(params) => match params.first() {
Some(Value::String(provider)) => Ok(provider.clone()),
_ => Err(()),
},
Value::Object(params) => match params.get("domain") {
Some(Value::String(provider)) => Ok(provider.clone()),
_ => Err(())
},
_ => Err(())
};
if provider.is_err() {
return Err(Error {
error: "Invalid params".into(),
});
}
let provider = provider.unwrap();
let _ = block_on(ws.user_controller.send(UserSetSiteCertRequest {
user_addr: String::from("current"),
site_addr: site,
Expand Down

0 comments on commit c02e8a2

Please sign in to comment.