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