summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2022-10-13 10:40:13 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2022-10-13 10:40:48 +0300
commit55ed962425ba25d2317946705ff6861a77eb770f (patch)
tree558deadac41d472c07a15960e6ebb72985da1e7d
parent46a038dc68093b28b69c3af38de4dd09431efae2 (diff)
downloadmeli-55ed962425ba25d2317946705ff6861a77eb770f.zip
melib/jmap: use server_url instead of server_hostname + server_port in config
-rw-r--r--docs/meli.conf.511
-rw-r--r--docs/samples/sample-config.toml10
-rw-r--r--melib/src/backends/jmap.rs9
-rw-r--r--melib/src/backends/jmap/connection.rs16
4 files changed, 23 insertions, 23 deletions
diff --git a/docs/meli.conf.5 b/docs/meli.conf.5
index cd9dafe9..4e45c94c 100644
--- a/docs/meli.conf.5
+++ b/docs/meli.conf.5
@@ -303,18 +303,15 @@ On startup, meli should evaluate this command which if successful must only retu
.Ss JMAP only
JMAP specific options
.Bl -tag -width 36n
-.It Ic server_hostname Ar String
+.It Ic server_url Ar String
example:
-.Qq mail.example.com
+.Qq http://mail.example.com
+.Qq http://mail.example.com:8080
+.Qq https://mail.example.com
.It Ic server_username Ar String
Server username
.It Ic server_password Ar String
Server password
-.It Ic server_port Ar number
-.Pq Em optional
-The port to connect to
-.\" default value
-.Pq Em 443
.It Ic danger_accept_invalid_certs Ar boolean
.Pq Em optional
Do not validate TLS certificates.
diff --git a/docs/samples/sample-config.toml b/docs/samples/sample-config.toml
index 22a4675c..5498128d 100644
--- a/docs/samples/sample-config.toml
+++ b/docs/samples/sample-config.toml
@@ -77,6 +77,16 @@
### Gmail auto saves sent mail to Sent folder, so don't duplicate the effort:
#composing.store_sent_mail = false
#
+##[accounts."jmap account"]
+##root_mailbox = "INBOX"
+##format = "jmap"
+##server_url="http://localhost:8080"
+##server_username="user@hostname.local"
+##server_password="changeme"
+##listing.index_style = "Conversations"
+##identity = "user@hostname.local"
+##subscribed_mailboxes = ["*", ]
+##composing.send_mail = 'server_submission'
#
#[pager]
#filter = "COLUMNS=72 /usr/local/bin/pygmentize -l email"
diff --git a/melib/src/backends/jmap.rs b/melib/src/backends/jmap.rs
index f8de9321..141e040d 100644
--- a/melib/src/backends/jmap.rs
+++ b/melib/src/backends/jmap.rs
@@ -100,10 +100,9 @@ pub struct EnvelopeCache {
#[derive(Debug, Clone)]
pub struct JmapServerConf {
- pub server_hostname: String,
+ pub server_url: String,
pub server_username: String,
pub server_password: String,
- pub server_port: u16,
pub danger_accept_invalid_certs: bool,
pub timeout: Option<Duration>,
}
@@ -139,10 +138,9 @@ macro_rules! get_conf_val {
impl JmapServerConf {
pub fn new(s: &AccountSettings) -> Result<Self> {
Ok(JmapServerConf {
- server_hostname: get_conf_val!(s["server_hostname"])?.to_string(),
+ server_url: get_conf_val!(s["server_url"])?.to_string(),
server_username: get_conf_val!(s["server_username"])?.to_string(),
server_password: get_conf_val!(s["server_password"])?.to_string(),
- server_port: get_conf_val!(s["server_port"], 443)?,
danger_accept_invalid_certs: get_conf_val!(s["danger_accept_invalid_certs"], false)?,
timeout: get_conf_val!(s["timeout"], 16_u64).map(|t| {
if t == 0 {
@@ -904,10 +902,9 @@ impl JmapType {
.unwrap_or_else(|| Ok($default))
};
}
- get_conf_val!(s["server_hostname"])?;
+ get_conf_val!(s["server_url"])?;
get_conf_val!(s["server_username"])?;
get_conf_val!(s["server_password"])?;
- get_conf_val!(s["server_port"], 443)?;
get_conf_val!(s["danger_accept_invalid_certs"], false)?;
Ok(())
}
diff --git a/melib/src/backends/jmap/connection.rs b/melib/src/backends/jmap/connection.rs
index 1cff3a95..02b41b09 100644
--- a/melib/src/backends/jmap/connection.rs
+++ b/melib/src/backends/jmap/connection.rs
@@ -57,15 +57,11 @@ impl JmapConnection {
if self.store.online_status.lock().await.1.is_ok() {
return Ok(());
}
- let mut jmap_session_resource_url = self.server_conf.server_hostname.to_string();
- if self.server_conf.server_port != 443 {
- jmap_session_resource_url.push(':');
- jmap_session_resource_url.push_str(&self.server_conf.server_port.to_string());
- }
+ let mut jmap_session_resource_url = self.server_conf.server_url.to_string();
jmap_session_resource_url.push_str("/.well-known/jmap");
let mut req = self.client.get_async(&jmap_session_resource_url).await.map_err(|err| {
- let err = MeliError::new(format!("Could not connect to JMAP server endpoint for {}. Is your server hostname setting correct? (i.e. \"jmap.mailserver.org\") (Note: only session resource discovery via /.well-known/jmap is supported. DNS SRV records are not suppported.)\nError connecting to server: {}", &self.server_conf.server_hostname, &err)).set_source(Some(Arc::new(err)));
+ let err = MeliError::new(format!("Could not connect to JMAP server endpoint for {}. Is your server url setting correct? (i.e. \"jmap.mailserver.org\") (Note: only session resource discovery via /.well-known/jmap is supported. DNS SRV records are not suppported.)\nError connecting to server: {}", &self.server_conf.server_url, &err)).set_source(Some(Arc::new(err)));
//*self.store.online_status.lock().await = (Instant::now(), Err(err.clone()));
err
})?;
@@ -75,7 +71,7 @@ impl JmapConnection {
let res_text = req.text().await.unwrap_or_default();
let err = MeliError::new(format!(
"Could not connect to JMAP server endpoint for {}. Reply from server: {}",
- &self.server_conf.server_hostname, res_text
+ &self.server_conf.server_url, res_text
))
.set_kind(kind.into());
*self.store.online_status.lock().await = (Instant::now(), Err(err.clone()));
@@ -86,7 +82,7 @@ impl JmapConnection {
let session: JmapSession = match serde_json::from_str(&res_text) {
Err(err) => {
- let err = MeliError::new(format!("Could not connect to JMAP server endpoint for {}. Is your server hostname setting correct? (i.e. \"jmap.mailserver.org\") (Note: only session resource discovery via /.well-known/jmap is supported. DNS SRV records are not suppported.)\nReply from server: {}", &self.server_conf.server_hostname, &res_text)).set_source(Some(Arc::new(err)));
+ let err = MeliError::new(format!("Could not connect to JMAP server endpoint for {}. Is your server url setting correct? (i.e. \"jmap.mailserver.org\") (Note: only session resource discovery via /.well-known/jmap is supported. DNS SRV records are not suppported.)\nReply from server: {}", &self.server_conf.server_url, &res_text)).set_source(Some(Arc::new(err)));
*self.store.online_status.lock().await = (Instant::now(), Err(err.clone()));
return Err(err);
}
@@ -96,7 +92,7 @@ impl JmapConnection {
.capabilities
.contains_key("urn:ietf:params:jmap:core")
{
- let err = MeliError::new(format!("Server {} did not return JMAP Core capability (urn:ietf:params:jmap:core). Returned capabilities were: {}", &self.server_conf.server_hostname, session.capabilities.keys().map(String::as_str).collect::<Vec<&str>>().join(", ")));
+ let err = MeliError::new(format!("Server {} did not return JMAP Core capability (urn:ietf:params:jmap:core). Returned capabilities were: {}", &self.server_conf.server_url, session.capabilities.keys().map(String::as_str).collect::<Vec<&str>>().join(", ")));
*self.store.online_status.lock().await = (Instant::now(), Err(err.clone()));
return Err(err);
}
@@ -104,7 +100,7 @@ impl JmapConnection {
.capabilities
.contains_key("urn:ietf:params:jmap:mail")
{
- let err = MeliError::new(format!("Server {} does not support JMAP Mail capability (urn:ietf:params:jmap:mail). Returned capabilities were: {}", &self.server_conf.server_hostname, session.capabilities.keys().map(String::as_str).collect::<Vec<&str>>().join(", ")));
+ let err = MeliError::new(format!("Server {} does not support JMAP Mail capability (urn:ietf:params:jmap:mail). Returned capabilities were: {}", &self.server_conf.server_url, session.capabilities.keys().map(String::as_str).collect::<Vec<&str>>().join(", ")));
*self.store.online_status.lock().await = (Instant::now(), Err(err.clone()));
return Err(err);
}