You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-31 09:24:31 +03:00
mas-email: better errors & aws-sdk upgrade
This commit is contained in:
133
Cargo.lock
generated
133
Cargo.lock
generated
@ -321,9 +321,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "aws-config"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56a636c44c77fa18bdba56126a34d30cfe5538fe88f7d34988fa731fee143ddd"
|
||||
checksum = "e7688e1dfbb9f7804fab0a830820d7e827b8d973906763cf1a855ce4719292f5"
|
||||
dependencies = [
|
||||
"aws-http",
|
||||
"aws-sdk-sso",
|
||||
@ -349,9 +349,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-endpoint"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ca8f374874f6459aaa88dc861d7f5d834ca1ff97668eae190e97266b5f6c3fb"
|
||||
checksum = "253d7cd480bfa59a5323390e9e91885a8f06a275e0517d81eeb1070b6aa7d271"
|
||||
dependencies = [
|
||||
"aws-smithy-http",
|
||||
"aws-smithy-types",
|
||||
@ -363,9 +363,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-http"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78d41e19e779b73463f5f0c21b3aacc995f4ba783ab13a7ae9f5dfb159a551b4"
|
||||
checksum = "4cd1b83859383e46ea8fda633378f9f3f02e6e3a446fd89f0240b5c3662716c9"
|
||||
dependencies = [
|
||||
"aws-smithy-http",
|
||||
"aws-smithy-types",
|
||||
@ -381,9 +381,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-sdk-sesv2"
|
||||
version = "0.21.0"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b2876df7dffcf330a5677b1105c7f9141aacd0db6280484fd8529af5b64125d"
|
||||
checksum = "9a95ab75eb838c9466785d9aa47a4ba277e46582601f6f4178fc166cefd15d53"
|
||||
dependencies = [
|
||||
"aws-endpoint",
|
||||
"aws-http",
|
||||
@ -403,9 +403,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-sdk-sso"
|
||||
version = "0.21.0"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86dcb1cb71aa8763b327542ead410424515cff0cde5b753eedd2917e09c63734"
|
||||
checksum = "bf03342c2b3f52b180f484e60586500765474f2bfc7dcd4ffe893a7a1929db1d"
|
||||
dependencies = [
|
||||
"aws-endpoint",
|
||||
"aws-http",
|
||||
@ -425,9 +425,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-sdk-sts"
|
||||
version = "0.21.0"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdfcf584297c666f6b472d5368a78de3bc714b6e0a53d7fbf76c3e347c292ab1"
|
||||
checksum = "aa1de4e07ea87a30a317c7b563b3a40fd18a843ad794216dda81672b6e174bce"
|
||||
dependencies = [
|
||||
"aws-endpoint",
|
||||
"aws-http",
|
||||
@ -443,13 +443,14 @@ dependencies = [
|
||||
"bytes 1.3.0",
|
||||
"http",
|
||||
"tower",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aws-sig-auth"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12cbe7b2be9e185c1fbce27fc9c41c66b195b32d89aa099f98768d9544221308"
|
||||
checksum = "6126c4ff918e35fb9ae1bf2de71157fad36f0cc6a2b1d0f7197ee711713700fc"
|
||||
dependencies = [
|
||||
"aws-sigv4",
|
||||
"aws-smithy-http",
|
||||
@ -460,27 +461,28 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-sigv4"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03ff4cff8c4a101962d593ba94e72cd83891aecd423f0c6e3146bff6fb92c9e3"
|
||||
checksum = "84c7f88d7395f5411c6eef5889b6cd577ce6b677af461356cbfc20176c26c160"
|
||||
dependencies = [
|
||||
"aws-smithy-http",
|
||||
"form_urlencoded",
|
||||
"hex",
|
||||
"hmac",
|
||||
"http",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"regex",
|
||||
"ring",
|
||||
"sha2",
|
||||
"time 0.3.17",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aws-smithy-async"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b3442b4c5d3fc39891a2e5e625735fba6b24694887d49c6518460fde98247a9"
|
||||
checksum = "3e6a895d68852dd1564328e63ef1583e5eb307dd2a5ebf35d862a5c402957d5e"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"pin-project-lite",
|
||||
@ -490,9 +492,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-smithy-client"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff28d553714f8f54cd921227934fc13a536a1c03f106e56b362fd57e16d450ad"
|
||||
checksum = "f505bf793eb3e6d7c166ef1275c27b4b2cd5361173fe950ac8e2cfc08c29a7ef"
|
||||
dependencies = [
|
||||
"aws-smithy-async",
|
||||
"aws-smithy-http",
|
||||
@ -511,9 +513,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-smithy-http"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf58ed4fefa61dbf038e5421a521cbc2c448ef69deff0ab1d915d8a10eda5664"
|
||||
checksum = "37e4b4304b7ea4af1af3e08535100eb7b6459d5a6264b92078bf85176d04ab85"
|
||||
dependencies = [
|
||||
"aws-smithy-types",
|
||||
"bytes 1.3.0",
|
||||
@ -531,11 +533,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-smithy-http-tower"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20c96d7bd35e7cf96aca1134b2f81b1b59ffe493f7c6539c051791cbbf7a42d3"
|
||||
checksum = "e86072ecc4dc4faf3e2071144285cfd539263fe7102b701d54fb991eafb04af8"
|
||||
dependencies = [
|
||||
"aws-smithy-http",
|
||||
"aws-smithy-types",
|
||||
"bytes 1.3.0",
|
||||
"http",
|
||||
"http-body",
|
||||
@ -546,18 +549,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-smithy-json"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8324ba98c8a94187723cc16c37aefa09504646ee65c3d2c3af495bab5ea701b"
|
||||
checksum = "9e3ddd9275b167bc59e9446469eca56177ec0b51225632f90aaa2cd5f41c940e"
|
||||
dependencies = [
|
||||
"aws-smithy-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aws-smithy-query"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83834ed2ff69ea6f6657baf205267dc2c0abe940703503a3e5d60ce23be3d306"
|
||||
checksum = "13b19d2e0b3ce20e460bad0d0d974238673100edebba6978c2c1aadd925602f7"
|
||||
dependencies = [
|
||||
"aws-smithy-types",
|
||||
"urlencoding",
|
||||
@ -565,10 +568,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-smithy-types"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b02e06ea63498c43bc0217ea4d16605d4e58d85c12fc23f6572ff6d0a840c61"
|
||||
checksum = "987b1e37febb9bd409ca0846e82d35299e572ad8279bc404778caeb5fc05ad56"
|
||||
dependencies = [
|
||||
"base64-simd",
|
||||
"itoa 1.0.4",
|
||||
"num-integer",
|
||||
"ryu",
|
||||
@ -577,18 +581,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "aws-smithy-xml"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "246e9f83dd1fdf5d347fa30ae4ad30a9d1d42ce4cd74a93d94afa874646f94cd"
|
||||
checksum = "37ce3791e14eec75ffac851a5a559f1ce6b31843297f42cc8bfba82714a6a5d8"
|
||||
dependencies = [
|
||||
"xmlparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aws-types"
|
||||
version = "0.51.0"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05701d32da168b44f7ee63147781aed8723e792cc131cb9b18363b5393f17f70"
|
||||
checksum = "6c05adca3e2bcf686dd2c47836f216ab52ed7845c177d180c84b08522c1166a3"
|
||||
dependencies = [
|
||||
"aws-smithy-async",
|
||||
"aws-smithy-client",
|
||||
@ -698,6 +702,15 @@ version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||
|
||||
[[package]]
|
||||
name = "base64-simd"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "781dd20c3aff0bd194fe7d2a977dd92f21c173891f3a03b677359e5fa457e5d5"
|
||||
dependencies = [
|
||||
"simd-abstraction",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64ct"
|
||||
version = "1.5.3"
|
||||
@ -862,9 +875,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.77"
|
||||
version = "1.0.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"
|
||||
checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
]
|
||||
@ -2425,9 +2438,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.6.0"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec947b7a4ce12e3b87e353abae7ce124d025b6c7d6c5aea5cc0bcf92e9510ded"
|
||||
checksum = "11b0d96e660696543b251e58030cf9787df56da39dab19ad60eae7353040917e"
|
||||
|
||||
[[package]]
|
||||
name = "iri-string"
|
||||
@ -2594,9 +2607,9 @@ checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f"
|
||||
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
|
||||
|
||||
[[package]]
|
||||
name = "listenfd"
|
||||
@ -2780,7 +2793,6 @@ dependencies = [
|
||||
name = "mas-email"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"aws-config",
|
||||
"aws-sdk-sesv2",
|
||||
@ -2789,7 +2801,7 @@ dependencies = [
|
||||
"lettre",
|
||||
"mas-http",
|
||||
"mas-templates",
|
||||
"tokio",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
@ -3598,6 +3610,12 @@ version = "6.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
|
||||
|
||||
[[package]]
|
||||
name = "outref"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f222829ae9293e33a9f5e9f440c6760a3d450a64affe1846486b140db81c1f4"
|
||||
|
||||
[[package]]
|
||||
name = "overload"
|
||||
version = "0.1.1"
|
||||
@ -3640,7 +3658,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
|
||||
dependencies = [
|
||||
"instant",
|
||||
"lock_api",
|
||||
"parking_lot_core 0.8.5",
|
||||
"parking_lot_core 0.8.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3655,9 +3673,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.8.5"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
|
||||
checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"instant",
|
||||
@ -3734,9 +3752,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.9"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1"
|
||||
checksum = "cf1c2c742266c2f1041c914ba65355a83ae8747b05f208319784083583494b4b"
|
||||
|
||||
[[package]]
|
||||
name = "pbkdf2"
|
||||
@ -4076,9 +4094,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "prost-build"
|
||||
version = "0.11.3"
|
||||
version = "0.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e330bf1316db56b12c2bcfa399e8edddd4821965ea25ddb2c134b610b1c1c604"
|
||||
checksum = "276470f7f281b0ed53d2ae42dd52b4a8d08853a3c70e7fe95882acbb98a6ae94"
|
||||
dependencies = [
|
||||
"bytes 1.3.0",
|
||||
"heck",
|
||||
@ -4428,7 +4446,7 @@ dependencies = [
|
||||
"errno",
|
||||
"io-lifetimes 1.0.3",
|
||||
"libc",
|
||||
"linux-raw-sys 0.1.3",
|
||||
"linux-raw-sys 0.1.4",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
@ -4797,6 +4815,15 @@ dependencies = [
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simd-abstraction"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cadb29c57caadc51ff8346233b5cec1d240b68ce55cf1afc764818791876987"
|
||||
dependencies = [
|
||||
"outref",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "similar"
|
||||
version = "2.2.1"
|
||||
@ -5345,9 +5372,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.9"
|
||||
version = "0.5.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
|
||||
checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
@ -6,15 +6,14 @@ edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.66"
|
||||
async-trait = "0.1.59"
|
||||
tokio = { version = "1.23.0", features = ["macros"] }
|
||||
tracing = "0.1.37"
|
||||
thiserror = "1.0.37"
|
||||
|
||||
aws-sdk-sesv2 = { version = "0.21.0", default-features = false }
|
||||
aws-config = { version = "0.51.0", default-features = false }
|
||||
aws-smithy-client = { version = "0.51.0", default-features = false, features = ["client-hyper"] }
|
||||
aws-smithy-async = { version = "0.51.0", default-features = false, features = ["rt-tokio"] }
|
||||
aws-sdk-sesv2 = { version = "0.22.0", default-features = false }
|
||||
aws-config = { version = "0.52.0", default-features = false }
|
||||
aws-smithy-client = { version = "0.52.0", default-features = false, features = ["client-hyper"] }
|
||||
aws-smithy-async = { version = "0.52.0", default-features = false, features = ["rt-tokio"] }
|
||||
|
||||
mas-templates = { path = "../templates" }
|
||||
mas-http = { path = "../http", features = ["aws-sdk", "client"] }
|
||||
|
@ -19,6 +19,7 @@ use lettre::{
|
||||
AsyncTransport, Message,
|
||||
};
|
||||
use mas_templates::{EmailVerificationContext, Templates};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::MailTransport;
|
||||
|
||||
@ -31,6 +32,14 @@ pub struct Mailer {
|
||||
reply_to: Mailbox,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[error(transparent)]
|
||||
pub enum Error {
|
||||
Transport(#[from] crate::transport::Error),
|
||||
Templates(#[from] mas_templates::TemplateError),
|
||||
Content(#[from] lettre::error::Error),
|
||||
}
|
||||
|
||||
impl Mailer {
|
||||
/// Constructs a new [`Mailer`]
|
||||
#[must_use]
|
||||
@ -58,7 +67,7 @@ impl Mailer {
|
||||
&self,
|
||||
to: Mailbox,
|
||||
context: &EmailVerificationContext,
|
||||
) -> anyhow::Result<Message> {
|
||||
) -> Result<Message, Error> {
|
||||
let plain = self
|
||||
.templates
|
||||
.render_email_verification_txt(context)
|
||||
@ -105,7 +114,7 @@ impl Mailer {
|
||||
&self,
|
||||
to: Mailbox,
|
||||
context: &EmailVerificationContext,
|
||||
) -> anyhow::Result<()> {
|
||||
) -> Result<(), Error> {
|
||||
let message = self.prepare_verification_email(to, context).await?;
|
||||
self.transport.send(message).await?;
|
||||
Ok(())
|
||||
@ -116,7 +125,7 @@ impl Mailer {
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error if the connection failed
|
||||
pub async fn test_connection(&self) -> Result<(), anyhow::Error> {
|
||||
pub async fn test_connection(&self) -> Result<(), crate::transport::Error> {
|
||||
self.transport.test_connection().await
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ use aws_config::provider_config::ProviderConfig;
|
||||
use aws_sdk_sesv2::{
|
||||
middleware::DefaultMiddleware,
|
||||
model::{EmailContent, RawMessage},
|
||||
output::SendEmailOutput,
|
||||
types::Blob,
|
||||
Client,
|
||||
};
|
||||
@ -27,6 +28,8 @@ use aws_smithy_client::erase::{DynConnector, DynMiddleware};
|
||||
use lettre::{address::Envelope, AsyncTransport};
|
||||
use mas_http::{otel::TraceLayer, ClientInitError};
|
||||
|
||||
pub type Error = aws_smithy_client::SdkError<aws_sdk_sesv2::error::SendEmailError>;
|
||||
|
||||
/// An asynchronous email transport that sends email via the AWS Simple Email
|
||||
/// Service v2 API
|
||||
pub struct Transport {
|
||||
@ -76,17 +79,17 @@ impl Transport {
|
||||
|
||||
#[async_trait]
|
||||
impl AsyncTransport for Transport {
|
||||
type Ok = ();
|
||||
type Error = anyhow::Error;
|
||||
type Ok = SendEmailOutput;
|
||||
type Error = Error;
|
||||
|
||||
async fn send_raw(&self, _envelope: &Envelope, email: &[u8]) -> Result<Self::Ok, Self::Error> {
|
||||
let email = Blob::new(email);
|
||||
let email = RawMessage::builder().data(email).build();
|
||||
let email = EmailContent::builder().raw(email).build();
|
||||
|
||||
let req = self.client.send_email().content(email);
|
||||
req.send().await?;
|
||||
let request = self.client.send_email().content(email);
|
||||
let response = request.send().await?;
|
||||
|
||||
Ok(())
|
||||
Ok(response)
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ use lettre::{
|
||||
AsyncTransport, Tokio1Executor,
|
||||
};
|
||||
use mas_http::ClientInitError;
|
||||
use thiserror::Error;
|
||||
|
||||
pub mod aws_ses;
|
||||
|
||||
@ -119,7 +120,7 @@ impl Transport {
|
||||
/// # Errors
|
||||
///
|
||||
/// Will return `Err` if the connection test failed
|
||||
pub async fn test_connection(&self) -> anyhow::Result<()> {
|
||||
pub async fn test_connection(&self) -> Result<(), Error> {
|
||||
match self.inner.as_ref() {
|
||||
TransportInner::Smtp(t) => {
|
||||
t.test_connection().await?;
|
||||
@ -138,10 +139,18 @@ impl Default for TransportInner {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[error(transparent)]
|
||||
pub enum Error {
|
||||
Smtp(#[from] lettre::transport::smtp::Error),
|
||||
Sendmail(#[from] lettre::transport::sendmail::Error),
|
||||
AwsSes(#[from] self::aws_ses::Error),
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl AsyncTransport for Transport {
|
||||
type Ok = ();
|
||||
type Error = anyhow::Error;
|
||||
type Error = Error;
|
||||
|
||||
async fn send_raw(&self, envelope: &Envelope, email: &[u8]) -> Result<Self::Ok, Self::Error> {
|
||||
match self.inner.as_ref() {
|
||||
|
@ -6,8 +6,8 @@ edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
aws-smithy-http = { version = "0.51.0", optional = true }
|
||||
aws-types = { version = "0.51.0", optional = true }
|
||||
aws-smithy-http = { version = "0.52.0", optional = true }
|
||||
aws-types = { version = "0.52.0", optional = true }
|
||||
axum = { version = "0.6.1", optional = true }
|
||||
bytes = "1.3.0"
|
||||
futures-util = "0.3.25"
|
||||
|
Reference in New Issue
Block a user