Skip to content

Commit

Permalink
fix(core): Fix default CheckEmailInput
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Jan 9, 2023
1 parent d04f84c commit 09215a1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 91 deletions.
72 changes: 0 additions & 72 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 22 additions & 4 deletions backend/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,6 @@
"type": "number",
"description": "SMTP port to use for email validation. Generally, ports 25, 465, 587 and 2525 are used."
},
"smtp_timeout": {
"type": "number",
"description": "Add optional timeout for the SMTP verification step, in seconds."
},
"yahoo_use_api": {
"type": "boolean",
"description": "For Yahoo email addresses, use Yahoo's API instead of connecting directly to their SMTP servers."
Expand Down Expand Up @@ -369,6 +365,9 @@
"Wrapper"
],
"description": "How to apply TLS to a SMTP client connection."
},
"smtp_timeout": {
"$ref": "#/components/schemas/Duration"
}
},
"required": ["to_email"]
Expand Down Expand Up @@ -403,6 +402,25 @@
}
},
"required": ["host", "port"]
},
"Duration": {
"title": "Duration",
"x-stoplight": {
"id": "0s9q75wxim1iw"
},
"type": "object",
"description": "An object representing a duration (seconds + nanoseconds).",
"properties": {
"secs": {
"type": "number",
"description": "Seconds"
},
"nanos": {
"type": "string",
"description": "Nanoseconds"
}
},
"required": ["secs", "nanos"]
}
},
"securitySchemes": {
Expand Down
1 change: 0 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ serde_json = "1.0.91"
trust-dns-proto = "0.21.2"
md5 = "0.7.0"
levenshtein = "1.0.5"
serde_with = "2.1.0"

[dev-dependencies]
tokio = { version = "1.23.0" }
Expand Down
15 changes: 1 addition & 14 deletions core/src/util/input_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use std::time::Duration;

use async_smtp::{ClientSecurity, ClientTlsParameters};
use serde::{ser::SerializeMap, Deserialize, Serialize, Serializer};
use serde_with::{serde_as, DurationSeconds};

use crate::misc::{MiscDetails, MiscError};
use crate::mx::{MxDetails, MxError};
Expand Down Expand Up @@ -72,20 +71,18 @@ impl SmtpSecurity {

/// Builder pattern for the input argument into the main `email_exists`
/// function.
#[serde_as]
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(default)]
pub struct CheckEmailInput {
/// The email to validate.
pub to_email: String,
/// Email to use in the `MAIL FROM:` SMTP command.
///
/// Defaults to "[email protected]".
#[serde(default)]
pub from_email: String,
/// Name to use in the `EHLO:` SMTP command.
///
/// Defaults to "localhost" (note: "localhost" is not a FQDN).
#[serde(default)]
pub hello_name: String,
/// Perform the email verification via the specified SOCK5 proxy. The usage of a
/// proxy is optional.
Expand All @@ -94,37 +91,30 @@ pub struct CheckEmailInput {
/// and 2525 are used.
///
/// Defaults to 25.
#[serde(default)]
pub smtp_port: u16,
/// Add timeout for the SMTP verification step. Set to None if you don't
/// want to use a timeout.
///
/// Defaults to 10s.
#[serde_as(as = "Option<DurationSeconds>")]
#[serde(default)]
pub smtp_timeout: Option<Duration>,
/// For Yahoo email addresses, use Yahoo's API instead of connecting
/// directly to their SMTP servers.
///
/// Defaults to true.
#[serde(default)]
pub yahoo_use_api: bool,
/// For Gmail email addresses, use Gmail's API instead of connecting
/// directly to their SMTP servers.
///
/// Defaults to false.
#[serde(default)]
pub gmail_use_api: bool,
/// For Microsoft 365 email addresses, use OneDrive's API instead of
/// connecting directly to their SMTP servers.
///
/// Defaults to false.
#[serde(default)]
pub microsoft365_use_api: bool,
// Whether to check if a gravatar image is existing for the given email.
//
// Defaults to false.
#[serde(default)]
pub check_gravatar: bool,
/// For Hotmail/Outlook email addresses, use a headless navigator
/// connecting to the password recovery page instead of the SMTP server.
Expand All @@ -134,17 +124,14 @@ pub struct CheckEmailInput {
///
/// Defaults to None.
#[cfg(feature = "headless")]
#[serde(default)]
pub hotmail_use_headless: Option<String>,
/// Number of retries of SMTP connections to do.
///
/// Defaults to 2 to avoid greylisting.
#[serde(default)]
pub retries: usize,
/// How to apply TLS to a SMTP client connection.
///
/// Defaults to Opportunistic.
#[serde(default)]
pub smtp_security: SmtpSecurity,
}

Expand Down

0 comments on commit 09215a1

Please sign in to comment.