Allow name to be optionally passed when creating an event
This commit is contained in:
parent
fc8e2a4360
commit
8a26cebf3b
|
|
@ -8,7 +8,7 @@ pub type ApiResult<T, A> = Result<Json<T>, ApiError<A>>;
|
|||
|
||||
#[derive(Deserialize)]
|
||||
pub struct EventInput {
|
||||
pub name: String,
|
||||
pub name: Option<String>,
|
||||
pub times: Vec<String>,
|
||||
pub timezone: String,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ pub async fn create_event<A: Adaptor>(
|
|||
let now = chrono::offset::Utc::now();
|
||||
|
||||
// Generate a name if none provided
|
||||
let name = match input.name.trim() {
|
||||
"" => generate_name(),
|
||||
x => x.to_string(),
|
||||
let name = match input.name {
|
||||
Some(x) if !x.is_empty() => x.trim().to_string(),
|
||||
_ => generate_name(),
|
||||
};
|
||||
|
||||
// Generate an ID
|
||||
|
|
|
|||
Loading…
Reference in a new issue