Ower creation now gives back prettier output + server meta vars as well
This commit is contained in:
parent
e893800dab
commit
ab1c9e40f7
@ -158,7 +158,11 @@ async fn attempt_owner_creation(name: &str) {
|
||||
match response {
|
||||
db::Response::Row(mut owner) => {
|
||||
owner.secret = owner_secret; // giving the secret itself back to the user
|
||||
println!("{}", serde_json::to_string(&owner).expect("SQL query passed but serde couldn't parse the data for some reason"))
|
||||
let server_config = serde_json::json!({
|
||||
"user": owner,
|
||||
"server": meta::get_config()
|
||||
});
|
||||
println!("{}", serde_json::to_string_pretty(&server_config).unwrap());
|
||||
},
|
||||
db::Response::Empty => {
|
||||
eprintln!("SQL server failed to return owner data, check configs and also the members table to make sure there's nothing there by accident");
|
||||
|
@ -6,20 +6,22 @@ use serde_json::to_string;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive( Serialize)]
|
||||
struct Config {
|
||||
name: String,
|
||||
description: String,
|
||||
hostname: String,
|
||||
port: u16
|
||||
pub struct Config {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub hostname: String,
|
||||
pub port: u16
|
||||
}
|
||||
|
||||
|
||||
pub async fn server_meta(response: &mut Response<Body>) {
|
||||
let payload = Config {
|
||||
pub fn get_config() -> Config {
|
||||
Config {
|
||||
name: var("SERVER_NAME").unwrap_or("No name".into()),
|
||||
description: var("SERVER_DESCRIPTION").unwrap_or("No description".into()),
|
||||
hostname: var("SERVER_HOSTNAME").expect("Couldn't get url from environment"),
|
||||
port: var("SERVER_PORT").expect("Couldn't get port from environment").parse::<u16>().unwrap(),
|
||||
};
|
||||
*response.body_mut() = Body::from(to_string(&payload).unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn server_meta(response: &mut Response<Body>) {
|
||||
*response.body_mut() = Body::from(to_string(&get_config()).unwrap());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user