philbooth · GitHub

Conversation

Closed

@philbooth

philbooth

philbooth

@@ -1,5 +1,9 @@
{
"provider": "ses",

philbooth

philbooth

body_text: String,
body_html: Option<String>,
) -> Result<String, ProviderError>;
}

philbooth

pub struct Providers
{
settings: Settings,
providers: HashMap<String, Box<Provider>>,

philbooth


match self.providers.get(resolved_provider_id) {
Some(ref provider) => match provider.send(to, cc, subject, body_text, body_html) {
Ok(message_id) => Ok(format!("{}:{}", resolved_provider_id, message_id)),

philbooth

#[serde(deserialize_with = "deserialize::aws_access")]
pub access: String,
#[serde(deserialize_with = "deserialize::aws_secret")]
pub secret: String,

philbooth

{
#[serde(deserialize_with = "deserialize::aws_region")]
pub region: String,
pub keys: Option<AwsKeys>,

philbooth

lazy_static! {
// HACK: mutex to prevent tests clobbering each other's environment variables
static ref ENVIRONMENT_MUTEX: Mutex<bool> = Mutex::new(true);
}

philbooth

mod test;

lazy_static! {
static ref AWS_ACCESS_FORMAT: Regex = Regex::new("^[A-Z0-9]+$").unwrap();

philbooth


lazy_static! {
static ref AWS_ACCESS_FORMAT: Regex = Regex::new("^[A-Z0-9]+$").unwrap();
static ref AWS_SECRET_FORMAT: Regex = Regex::new("^[A-Za-z0-9+/=]+$").unwrap();

philbooth

fn invalid_aws_region()
{
assert_eq!(validate::aws_region("us-east-1a"), false);
assert_eq!(validate::aws_region("us-east-1 "), false);

@philbooth

philbooth

mod test;

#[derive(Debug, Deserialize)]
pub struct AwsKeys

philbooth


pub fn provider(value: &str) -> bool
{
PROVIDER_FORMAT.is_match(value)

@philbooth

@philbooth

rfk

rfk approved these changes May 7, 2018

fn send(
&self,
to: String,
cc: Vec<String>,
pub struct Providers
{
settings: Settings,
providers: HashMap<String, Box<Provider>>,
}
}

unsafe impl Sync for Providers {}
#[serde(deserialize_with = "deserialize::aws_access")]
pub access: String,
#[serde(deserialize_with = "deserialize::aws_secret")]
pub secret: String,
email.to.clone(),
cc,
email.subject.clone(),
email.body.text.clone(),
let mut message = Message::default();
message.subject.data = subject;
message.body.text = Some(Content {
charset: None,

Closed

@philbooth

@philbooth

@philbooth

Read the original on github.com ↗