fix: empty comment gets saved

This commit is contained in:
Max Hohlfeld 2025-07-08 16:07:26 +02:00
parent f5c09e3515
commit 1515f50ed9
2 changed files with 12 additions and 2 deletions

View File

@ -26,9 +26,14 @@ pub async fn post(
availability: None, availability: None,
}; };
let comment = form
.comment
.clone()
.and_then(|c| if !c.trim().is_empty() { Some(c) } else { None });
let mut changeset = AvailabilityChangeset { let mut changeset = AvailabilityChangeset {
time: (start, end), time: (start, end),
comment: form.comment.clone(), comment,
}; };
if let Err(e) = changeset.validate_with_context(&context).await { if let Err(e) = changeset.validate_with_context(&context).await {

View File

@ -29,6 +29,11 @@ pub async fn post(
let start = form.startdate.and_time(form.starttime); let start = form.startdate.and_time(form.starttime);
let end = form.enddate.and_time(form.endtime); 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 { let context = AvailabilityContext {
pool: pool.get_ref(), pool: pool.get_ref(),
user_id: user.id, user_id: user.id,
@ -37,7 +42,7 @@ pub async fn post(
let mut changeset = AvailabilityChangeset { let mut changeset = AvailabilityChangeset {
time: (start, end), time: (start, end),
comment: form.comment.clone(), comment,
}; };
if let Err(e) = changeset.validate_with_context(&context).await { if let Err(e) = changeset.validate_with_context(&context).await {