|
|
|
@ -3,6 +3,7 @@ mod ruma_wrapper; |
|
|
|
|
|
|
|
|
|
|
|
use { |
|
|
|
use { |
|
|
|
directories::ProjectDirs, |
|
|
|
directories::ProjectDirs, |
|
|
|
|
|
|
|
log::debug, |
|
|
|
rocket::{get, post, put, routes, State}, |
|
|
|
rocket::{get, post, put, routes, State}, |
|
|
|
ruma_client_api::{ |
|
|
|
ruma_client_api::{ |
|
|
|
error::{Error, ErrorKind}, |
|
|
|
error::{Error, ErrorKind}, |
|
|
|
@ -40,16 +41,18 @@ fn register_route( |
|
|
|
.try_into() |
|
|
|
.try_into() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Err(_) => { |
|
|
|
Err(_) => { |
|
|
|
|
|
|
|
debug!("Username invalid"); |
|
|
|
return MatrixResult(Err(Error { |
|
|
|
return MatrixResult(Err(Error { |
|
|
|
kind: ErrorKind::InvalidUsername, |
|
|
|
kind: ErrorKind::InvalidUsername, |
|
|
|
message: "Username was invalid.".to_owned(), |
|
|
|
message: "Username was invalid.".to_owned(), |
|
|
|
status_code: http::StatusCode::BAD_REQUEST, |
|
|
|
status_code: http::StatusCode::BAD_REQUEST, |
|
|
|
})) |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
Ok(user_id) => user_id, |
|
|
|
Ok(user_id) => user_id, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if users.contains_key(user_id.to_string()).unwrap() { |
|
|
|
if users.contains_key(user_id.to_string()).unwrap() { |
|
|
|
|
|
|
|
debug!("ID already taken"); |
|
|
|
return MatrixResult(Err(Error { |
|
|
|
return MatrixResult(Err(Error { |
|
|
|
kind: ErrorKind::UserInUse, |
|
|
|
kind: ErrorKind::UserInUse, |
|
|
|
message: "Desired user ID is already taken.".to_owned(), |
|
|
|
message: "Desired user ID is already taken.".to_owned(), |
|
|
|
|