mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-14 12:46:49 +00:00
feat(config): connection_uri_file added to config
This commit is contained in:
1 parent
ffcf152016
commit
89e07ae239
4 files changed
+45
-12
No files matched your search
+22
-10
@@ -20,16 +20,28 @@ pub struct Service {
|
||||
#[async_trait::async_trait]
|
||||
impl crate::Service for Service {
|
||||
fn build(args: Args<'_>) -> Result<Arc<Self>> {
|
||||
let transport = args
|
||||
.server
|
||||
.config
|
||||
.smtp
|
||||
.as_ref()
|
||||
.map(|config| {
|
||||
Ok((config.sender.clone(), Transport::from_url(&config.connection_uri)?.build()))
|
||||
})
|
||||
.transpose()
|
||||
.map_err(|err: TransportError| err!("Failed to set up SMTP transport: {err}"))?;
|
||||
let transport =
|
||||
args.server
|
||||
.config
|
||||
.smtp
|
||||
.as_ref()
|
||||
.map(|config| -> Result<_> {
|
||||
let connection_uri: String =
|
||||
if let Some(uri) = &config.connection_uri {
|
||||
uri.clone()
|
||||
} else {
|
||||
std::fs::read_to_string(
|
||||
config.connection_uri_file.as_ref().unwrap() // Safe to unwrap here assuming the config checks properly run and throw errors
|
||||
)
|
||||
.map_err(|err| err!("Failed to read SMTP connection URI file: {err}"))?
|
||||
};
|
||||
let transport = Transport::from_url(&connection_uri)
|
||||
.map_err(|err| err!("Failed to set up SMTP transport: {err}"))?
|
||||
.build();
|
||||
|
||||
Ok((config.sender.clone(), transport))
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
Ok(Arc::new(Self { transport }))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user