diff --git a/web/src/endpoints/availability/post_new.rs b/web/src/endpoints/availability/post_new.rs index 7e0602da..9e2f46df 100644 --- a/web/src/endpoints/availability/post_new.rs +++ b/web/src/endpoints/availability/post_new.rs @@ -26,9 +26,14 @@ pub async fn post( availability: None, }; + let comment = form + .comment + .clone() + .and_then(|c| if !c.trim().is_empty() { Some(c) } else { None }); + let mut changeset = AvailabilityChangeset { time: (start, end), - comment: form.comment.clone(), + comment, }; if let Err(e) = changeset.validate_with_context(&context).await { diff --git a/web/src/endpoints/availability/post_update.rs b/web/src/endpoints/availability/post_update.rs index 30a3a766..443f4864 100644 --- a/web/src/endpoints/availability/post_update.rs +++ b/web/src/endpoints/availability/post_update.rs @@ -29,6 +29,11 @@ pub async fn post( let start = form.startdate.and_time(form.starttime); let end = form.enddate.and_time(form.endtime); + let comment = form + .comment + .clone() + .and_then(|c| if !c.trim().is_empty() { Some(c) } else { None }); + let context = AvailabilityContext { pool: pool.get_ref(), user_id: user.id, @@ -37,7 +42,7 @@ pub async fn post( let mut changeset = AvailabilityChangeset { time: (start, end), - comment: form.comment.clone(), + comment, }; if let Err(e) = changeset.validate_with_context(&context).await {