Allow name to be optionally passed when creating an event

This commit is contained in:
Ben Grant 2023-05-13 13:54:16 +10:00
parent fc8e2a4360
commit 8a26cebf3b
2 changed files with 4 additions and 4 deletions

View file

@ -8,7 +8,7 @@ pub type ApiResult<T, A> = Result<Json<T>, ApiError<A>>;
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct EventInput { pub struct EventInput {
pub name: String, pub name: Option<String>,
pub times: Vec<String>, pub times: Vec<String>,
pub timezone: String, pub timezone: String,
} }

View file

@ -19,9 +19,9 @@ pub async fn create_event<A: Adaptor>(
let now = chrono::offset::Utc::now(); let now = chrono::offset::Utc::now();
// Generate a name if none provided // Generate a name if none provided
let name = match input.name.trim() { let name = match input.name {
"" => generate_name(), Some(x) if !x.is_empty() => x.trim().to_string(),
x => x.to_string(), _ => generate_name(),
}; };
// Generate an ID // Generate an ID