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)]
|
#[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,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue