This commit is contained in:
Phil Booth 2018-12-06 14:24:03 +00:00
Родитель 659ad55473
Коммит bf5486fc8e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 36FBB106F9C32516
6 изменённых файлов: 28 добавлений и 25 удалений

29
Cargo.lock сгенерированный
Просмотреть файл

@ -600,7 +600,7 @@ dependencies = [
name = "fxa_email_service"
version = "1.126.0"
dependencies = [
"base64 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"config 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"emailmessage 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -608,6 +608,7 @@ dependencies = [
"futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hmac 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"hyperx 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lettre 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -617,7 +618,7 @@ dependencies = [
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"redis 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rocket 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
"rocket_codegen 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
"rocket_contrib 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
@ -626,7 +627,7 @@ dependencies = [
"rusoto_mock 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rusoto_ses 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rusoto_sqs 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sendgrid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sendgrid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sentry 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
@ -640,7 +641,7 @@ dependencies = [
"slog-term 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"socketlabs 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -665,7 +666,7 @@ dependencies = [
"bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -707,7 +708,7 @@ dependencies = [
[[package]]
name = "http"
version = "0.1.10"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
@ -785,7 +786,7 @@ dependencies = [
"futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -834,7 +835,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"base64 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1521,7 +1522,7 @@ dependencies = [
"bytes 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libflate 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1642,7 +1643,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rusoto_core 0.34.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -1770,12 +1771,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "sendgrid"
version = "0.7.1"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"data-encoding 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2620,7 +2621,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum hmac 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44f3bdb08579d99d7dc761c0e266f13b5f2ab8c8c703b9fc9ef333cd8f48f55e"
"checksum hmac 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "efb895368093a17d136b1d9eecdb607c7aa038a452e646c74e37ded2da106285"
"checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e"
"checksum http 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "dca621d0fa606a5ff2850b6e337b57ad6137ee4d67e940449643ff45af6874c6"
"checksum http 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "02096a6d2c55e63f7fcb800690e4f889a25f6ec342e3adb4594e293b625215ab"
"checksum httparse 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b6288d7db100340ca12873fd4d08ad1b8f206a9457798dfb17c018a33fee540"
"checksum httpdate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47"
"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e"
@ -2730,7 +2731,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum security-framework-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab01dfbe5756785b5b4d46e0289e5a18071dfa9a7c2b24213ea00b9ef9b665bf"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum sendgrid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8ac11587805aae635c1b0806519d974c329794bec4aed8a2900c4c9b6b0ca758"
"checksum sendgrid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f53051999483a3580b65ae0ae4c2b0d2717df46fc0c9314adeb2ec340620e9fb"
"checksum sentry 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b565ae999bf4a6399a95315b110560432a8958a207474749b91ea2a078a2bece"
"checksum sentry-types 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1108bf605cb7f136bea4d30d24c9e255ab16ea610a74e004c02d673a2247f6cf"
"checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8"

Просмотреть файл

@ -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,11 +73,10 @@ 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"
@ -87,7 +84,7 @@ impl Provider for SendgridProvider {
)
.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);