Permalink
Browse files

Merge pull request #259 from mozilla/pb/update-sendgrid

#259
r=vladikoff
  • Loading branch information...
philbooth committed Dec 6, 2018
2 parents 659ad55 + bf5486f commit 37a6baffb5b8d874b647a173e113c54aa042f6f6
Showing with 28 additions and 25 deletions.
  1. +15 −14 Cargo.lock
  2. +2 −1 Cargo.toml
  3. +4 −3 src/db/auth_db/mod.rs
  4. +1 −0 src/lib.rs
  5. +4 −7 src/providers/sendgrid.rs
  6. +2 −0 src/types/error/mod.rs

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -24,6 +24,7 @@ failure = ">=0.1.2"
futures = ">=0.1.21,<0.2"
hex = ">=0.3.2"
hmac = ">=0.6.2"
http = ">=0.1.14"
hyperx = ">=0.13.1"
lazy_static = ">=1.0"
lettre = "0.8"
@@ -42,7 +43,7 @@ rusoto_credential = ">=0.13.0"
rusoto_mock = ">=0.28.0"
rusoto_ses = ">=0.34.0"
rusoto_sqs = ">=0.34.0"
sendgrid = ">=0.7.1"
sendgrid = ">=0.7.2"
sentry = ">=0.12.0"
serde = ">=1.0"
serde_derive = ">=1.0"
@@ -19,7 +19,8 @@
use std::fmt::Debug;
use hex;
use reqwest::{Client as RequestClient, StatusCode, Url, UrlError};
use http::StatusCode;
use reqwest::{Client as RequestClient, Url, UrlError};
use super::delivery_problems::{
LegacyDeliveryProblem as DeliveryProblem, ProblemSubtype, ProblemType,
@@ -70,7 +71,7 @@ impl Db for DbClient {
.get(self.urls.get_bounces(address)?)
.send()?;
match response.status() {
StatusCode::Ok => response.json::<Vec<DeliveryProblem>>().map_err(From::from),
StatusCode::OK => response.json::<Vec<DeliveryProblem>>().map_err(From::from),
status => Err(AppErrorKind::Internal(format!(
"Auth db get_bounces response: {}",
status
@@ -95,7 +96,7 @@ impl Db for DbClient {
})
.send()?;
match response.status() {
StatusCode::Ok => Ok(()),
StatusCode::OK => Ok(()),
status => Err(AppErrorKind::Internal(format!(
"Auth db create_bounce response: {}",
status
@@ -39,6 +39,7 @@ extern crate failure;
extern crate futures;
extern crate hex;
extern crate hmac;
extern crate http;
extern crate hyperx;
#[macro_use]
extern crate lazy_static;
@@ -2,9 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
use std::str::from_utf8;
use reqwest::StatusCode;
use http::StatusCode;
use sendgrid::v3::{
Content, Email as EmailAddress, Personalization, SGMailV3 as Message, V3Sender as Client,
};
@@ -75,19 +73,18 @@ impl Provider for SendgridProvider {
.map_err(From::from)
.and_then(|mut response| {
let status = response.status();
if status == StatusCode::Ok || status == StatusCode::Accepted {
if status == StatusCode::OK || status == StatusCode::ACCEPTED {
response
.headers()
.get_raw("X-Message-Id")
.and_then(|raw_header| raw_header.one())
.get("X-Message-Id")
.ok_or(
AppErrorKind::Internal(
"Missing or duplicate X-Message-Id header in Sendgrid response"
.to_owned(),
)
.into(),
)
.and_then(|message_id| from_utf8(message_id).map_err(From::from))
.and_then(|message_id| message_id.to_str().map_err(From::from))
.map(|message_id| message_id.to_string())
} else {
Err(AppErrorKind::Internal(format!(
@@ -12,6 +12,7 @@ use std::{
use failure::{Backtrace, Context, Fail};
use hmac::crypto_mac::InvalidKeyLength;
use http::header::ToStrError;
use hyperx::mime::FromStrError;
use lettre::smtp::error::Error as SmtpError;
use lettre_email::error::Error as EmailError;
@@ -280,5 +281,6 @@ to_internal_error!(SendgridError);
to_internal_error!(SendRawEmailError);
to_internal_error!(SmtpError);
to_internal_error!(SocketLabsError);
to_internal_error!(ToStrError);
to_internal_error!(UrlError);
to_internal_error!(Utf8Error);

0 comments on commit 37a6baf

Please sign in to comment.