fix(contact): ignore empty honeypot values even if String exists
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 11m3s
All checks were successful
Publish Docker Images / build-and-publish (push) Successful in 11m3s
This commit is contained in:
@@ -93,10 +93,14 @@ impl From<ValidationErrors> for ContactError {
|
|||||||
return Self::ValidationNameError("backend.contact.errors.validation.name".to_owned());
|
return Self::ValidationNameError("backend.contact.errors.validation.name".to_owned());
|
||||||
}
|
}
|
||||||
if validator::ValidationErrors::has_error(&Err(value.clone()), "email") {
|
if validator::ValidationErrors::has_error(&Err(value.clone()), "email") {
|
||||||
return Self::ValidationEmailError("backend.contact.errors.validation.email".to_owned());
|
return Self::ValidationEmailError(
|
||||||
|
"backend.contact.errors.validation.email".to_owned(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if validator::ValidationErrors::has_error(&Err(value), "message") {
|
if validator::ValidationErrors::has_error(&Err(value), "message") {
|
||||||
return Self::ValidationMessageError("backend.contact.errors.validation.message".to_owned());
|
return Self::ValidationMessageError(
|
||||||
|
"backend.contact.errors.validation.message".to_owned(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Self::ValidationError("backend.contact.errors.validation.other".to_owned())
|
Self::ValidationError("backend.contact.errors.validation.other".to_owned())
|
||||||
}
|
}
|
||||||
@@ -113,9 +117,13 @@ impl From<ContactError> for ContactResponse {
|
|||||||
success: false,
|
success: false,
|
||||||
message: match value {
|
message: match value {
|
||||||
ContactError::CouldNotParseRequestEmailAddress(_)
|
ContactError::CouldNotParseRequestEmailAddress(_)
|
||||||
| ContactError::ValidationEmailError(_) => "backend.contact.errors.validation.email",
|
| ContactError::ValidationEmailError(_) => {
|
||||||
|
"backend.contact.errors.validation.email"
|
||||||
|
}
|
||||||
ContactError::ValidationNameError(_) => "backend.contact.errors.validation.name",
|
ContactError::ValidationNameError(_) => "backend.contact.errors.validation.name",
|
||||||
ContactError::ValidationMessageError(_) => "backend.contact.errors.validation.message",
|
ContactError::ValidationMessageError(_) => {
|
||||||
|
"backend.contact.errors.validation.message"
|
||||||
|
}
|
||||||
ContactError::CouldNotParseSettingsEmail(_)
|
ContactError::CouldNotParseSettingsEmail(_)
|
||||||
| ContactError::FailedToBuildMessage(_)
|
| ContactError::FailedToBuildMessage(_)
|
||||||
| ContactError::CouldNotSendEmail(_)
|
| ContactError::CouldNotSendEmail(_)
|
||||||
|
|||||||
@@ -161,7 +161,9 @@ impl ContactApi {
|
|||||||
remote_addr: Option<poem::web::Data<&poem::web::RemoteAddr>>,
|
remote_addr: Option<poem::web::Data<&poem::web::RemoteAddr>>,
|
||||||
) -> ContactApiResponse {
|
) -> ContactApiResponse {
|
||||||
let body = body.0;
|
let body = body.0;
|
||||||
if body.honeypot.is_some() {
|
if let Some(ref honeypot) = body.honeypot
|
||||||
|
&& !honeypot.trim().is_empty()
|
||||||
|
{
|
||||||
tracing::event!(
|
tracing::event!(
|
||||||
target: "backend::contact",
|
target: "backend::contact",
|
||||||
tracing::Level::INFO,
|
tracing::Level::INFO,
|
||||||
|
|||||||
Reference in New Issue
Block a user