mirror of
https://github.com/chatmail/core.git
synced 2026-05-23 00:36:32 +03:00
use structure as suggested by @dignifiedquire
This commit is contained in:
@@ -2,11 +2,11 @@ use crate::provider::*;
|
|||||||
use crate::provider::Protocol::*;
|
use crate::provider::Protocol::*;
|
||||||
use crate::provider::Socket::*;
|
use crate::provider::Socket::*;
|
||||||
use crate::provider::UsernamePattern::*;
|
use crate::provider::UsernamePattern::*;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref PROVIDER_DATA: Vec<Provider> = vec![
|
// nauta.cu
|
||||||
Provider {
|
static ref P1: Provider = Provider {
|
||||||
domains: "nauta.cu",
|
|
||||||
status: Status::OK,
|
status: Status::OK,
|
||||||
before_login_hint: "",
|
before_login_hint: "",
|
||||||
after_login_hint: "",
|
after_login_hint: "",
|
||||||
@@ -15,33 +15,45 @@ lazy_static::lazy_static! {
|
|||||||
Server { protocol: IMAP, socket: STARTTLS, hostname: "imap.nauta.cu", port: 143, username_pattern: EMAIL },
|
Server { protocol: IMAP, socket: STARTTLS, hostname: "imap.nauta.cu", port: 143, username_pattern: EMAIL },
|
||||||
Server { protocol: SMTP, socket: STARTTLS, hostname: "smtp.nauta.cu", port: 25, username_pattern: EMAIL },
|
Server { protocol: SMTP, socket: STARTTLS, hostname: "smtp.nauta.cu", port: 25, username_pattern: EMAIL },
|
||||||
],
|
],
|
||||||
},
|
};
|
||||||
Provider {
|
|
||||||
domains: "outlook.com hotmail.com live.com",
|
// outlook.com, hotmail.com, live.com
|
||||||
|
static ref P2: Provider = Provider {
|
||||||
status: Status::BROKEN,
|
status: Status::BROKEN,
|
||||||
before_login_hint: "Outlook-e-mail-addresses will not work as expected as these servers remove some important transport information.\n\nHopefully sooner or later there will be a fix; for now, we suggest to use another e-mail-address or try Delta Chat again when the issue is fixed.",
|
before_login_hint: "Outlook-e-mail-addresses will not work as expected as these servers remove some important transport information.\n\nHopefully sooner or later there will be a fix; for now, we suggest to use another e-mail-address or try Delta Chat again when the issue is fixed.",
|
||||||
after_login_hint: "",
|
after_login_hint: "",
|
||||||
overview_page: "https://provider.delta.chat/outlook.com",
|
overview_page: "https://provider.delta.chat/outlook.com",
|
||||||
server: vec![
|
server: vec![
|
||||||
],
|
],
|
||||||
},
|
};
|
||||||
Provider {
|
|
||||||
domains: "testrun.org",
|
// testrun.org
|
||||||
|
static ref P3: Provider = Provider {
|
||||||
status: Status::OK,
|
status: Status::OK,
|
||||||
before_login_hint: "",
|
before_login_hint: "",
|
||||||
after_login_hint: "testrun.org is not Delta Chat :)",
|
after_login_hint: "testrun.org is not Delta Chat :)",
|
||||||
overview_page: "",
|
overview_page: "",
|
||||||
server: vec![
|
server: vec![
|
||||||
],
|
],
|
||||||
},
|
};
|
||||||
Provider {
|
|
||||||
domains: "gmail.com googlemail.com",
|
// gmail.com, googlemail.com
|
||||||
|
static ref P4: Provider = Provider {
|
||||||
status: Status::PREPARATION,
|
status: Status::PREPARATION,
|
||||||
before_login_hint: "For Gmail Accounts, you need to create an App-Password if you have \"2-Step Verification\" enabled. If this setting is not available, you need to enable \"Less secure apps\".",
|
before_login_hint: "For Gmail Accounts, you need to create an App-Password if you have \"2-Step Verification\" enabled. If this setting is not available, you need to enable \"Less secure apps\".",
|
||||||
after_login_hint: "",
|
after_login_hint: "",
|
||||||
overview_page: "https://provider.delta.chat/gmail.com",
|
overview_page: "https://provider.delta.chat/gmail.com",
|
||||||
server: vec![
|
server: vec![
|
||||||
],
|
],
|
||||||
},
|
};
|
||||||
];
|
|
||||||
|
pub static ref PROVIDER_DATA: HashMap<&'static str, &'static Provider> = [
|
||||||
|
("nauta.cu", &*P1),
|
||||||
|
("outlook.com", &*P2),
|
||||||
|
("hotmail.com", &*P2),
|
||||||
|
("live.com", &*P2),
|
||||||
|
("testrun.org", &*P3),
|
||||||
|
("gmail.com", &*P4),
|
||||||
|
("googlemail.com", &*P4),
|
||||||
|
].iter().copied().collect();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ impl Server {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Provider {
|
pub struct Provider {
|
||||||
pub domains: &'static str,
|
|
||||||
pub status: Status,
|
pub status: Status,
|
||||||
pub before_login_hint: &'static str,
|
pub before_login_hint: &'static str,
|
||||||
pub after_login_hint: &'static str,
|
pub after_login_hint: &'static str,
|
||||||
@@ -91,12 +90,8 @@ pub fn get_provider_info(addr: &str) -> Option<&Provider> {
|
|||||||
}
|
}
|
||||||
.to_lowercase();
|
.to_lowercase();
|
||||||
|
|
||||||
for record in PROVIDER_DATA.iter() {
|
if let Some(provider) = PROVIDER_DATA.get(domain.as_str()) {
|
||||||
for record_domain in record.domains.split(' ') {
|
return Some(*provider);
|
||||||
if record_domain == domain {
|
|
||||||
return Some(record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|||||||
Reference in New Issue
Block a user