Граф коммитов

251 Коммитов

Автор SHA1 Сообщение Дата
Phil Booth 0bd766d431
feat(settings): extract provider type to a fully-fledged enum
The provider type was modelled as a newtype struct around a `String` but
there's a finite number of values, so really it should be an enum. This
wasn't too pressing until now but will shortly come in useful for the
configuration stuff, which needs a provider type too.
2018-11-09 16:20:12 +00:00
Phil Booth 664222cd27
chore(deploy): update rust version 2018-11-09 16:00:57 +00:00
Phil Booth 8268f4697e
Merge pull request #236 from mozilla/pb/210
https://github.com/mozilla/fxa-email-service/pull/236
r=brizental
2018-11-09 15:23:17 +00:00
Phil Booth 4297ed2fad
refactor(api): reduce the number of different error kinds we return
The error-handling in this repo grew pretty organically without us
giving much thought to an over-arching strategy. The end result of that
was a proliferation of different error types that weren't really adding
much value.

The API here is simple and the 4xx responses are really limited to bad
requests and bounce/complaint limit violations. Everything else is an
internal server error. As such, the `error` module could be simplified
by employing a blanket `Internal` error type to cover the multitude of
niche errors that should never occur during normal conditions. The
detail for those errors is still available in the `message` property and
Sentry will still log the backtrace of course.

I also noticed that the Rocket catcher stuff wasn't really being used,
so pulled that out too. We have a standard JSON error format like the
rest of the FxA ecosystem, and we always want the response payload to be
the serialisation of that structure.

One side-effect of all these changes is that the errno value has changed
in most cases. However, I took care to preserve the errno for the bounce
and complaint violations, because it's hard-coded in the auth server. It
wouldn't have been that onerous to open a PR for commensurate changes
over there, but the number of errors left here worked out in such a way
that made sense not to bother.
2018-11-09 13:45:31 +00:00
Vlad Filippov 1ef739242c
Merge pull request #234 from mozilla/comment-rm
fix(cargo): remove old rocket comment
2018-11-08 15:57:22 -05:00
Vlad Filippov c706d760f7
fix(cargo): remove old rocket comment 2018-11-08 14:31:23 -05:00
Phil Booth 785e2b3161
Merge pull request #233 from mozilla/pb/allow-sentry-disabled
https://github.com/mozilla/fxa-email-service/pull/233
r=vladikoff
2018-11-08 14:07:17 +00:00
Phil Booth 4f47e93b6a
fix(settings): fix panic when sentry is disabled 2018-11-08 09:18:48 +00:00
Phil Booth 321fd721d5
Merge train-124 into master
https://github.com/mozilla/fxa-email-service/pull/232
r=vladikoff
2018-11-07 18:53:57 +00:00
Phil Booth 6f795044ce
Merge branch 'master' into train-124 2018-11-07 18:13:06 +00:00
Phil Booth a5c9c1f5b8
Merge pull request #229 from mozilla/pb/201
https://github.com/mozilla/fxa-email-service/pull/229
r=vladikoff
2018-11-07 16:37:49 +00:00
Phil Booth d6d01b32c4
chore(package): bump version, update changelog 2018-11-07 16:34:01 +00:00
Phil Booth 1302edf987
Merge pull request #228 from mozilla/pb/emailmessage-dep
https://github.com/mozilla/fxa-email-service/pull/228
r=vladikoff
2018-11-07 16:32:13 +00:00
Phil Booth 5d5ae603de
feat(types): ignore display name part when parsing email addresses
Fixes #201.

Email addresses that we receive from bounce, complaint and delivery
notifications may not be identical matches to what we set on messages.
We already did some normalization by lower-casing the address when
parsing. This change extends that normalization process by trimming
whitespace and unwrapping the address part if it has been wrapped in
angle bracket delimiters to separate it from the display name. This
matches the behaviour of the auth server.
2018-11-07 16:16:58 +00:00
Phil Booth d7aaf59ea4
Merge pull request #230 from mozilla/pb/sentry-updates
https://github.com/mozilla/fxa-email-service/pull/230
r=vladikoff
2018-11-07 16:02:25 +00:00
Phil Booth 0a2d39a33d
chore(package): include debug symbols in release builds 2018-11-07 15:39:06 +00:00
Phil Booth 02408f590a
fix(sentry): capture errors at point of creation rather than when logged
We were sending errors to Sentry at the point where they are logged,
but there are a number of paths where an error is raised without being
logged. Instead, this change captures them at the point of creation,
which should mean we now capture every error.
2018-11-07 15:39:06 +00:00
Phil Booth 608c07eb7e
chore(deps): update sentry 2018-11-07 15:39:03 +00:00
Phil Booth c403c3fb81
Merge pull request #231 from mozilla/pb/205
https://github.com/mozilla/fxa-email-service/pull/231
r=vladikoff
2018-11-07 15:38:51 +00:00
Phil Booth 906f391151
feat(bounces): use timestamps from ses instead of the current time
Fixes #205.

SES provides a UTC-based timestamp for bounce and complaint events but
the auth server opted to ignore it. I'm not sure that was the optimal
decision because messages might linger on a queue (either ours or the
provider's) for a length of time before we process it. Given that we
already trust SES et al to deliver sane notifications, it doesn't seem
too great a stretch to also trust the timestamp on those notifications.
2018-11-07 14:05:25 +00:00
Phil Booth 5d03a48dad
fix(mime): use base64 encoding instead of 8bit 2018-11-07 06:43:45 +00:00
Phil Booth 5966d6252d
refactor(providers): eliminate format! invocations in ses send method 2018-11-05 16:12:01 +00:00
Phil Booth 85ffe3ebe8
refactor(ses): upgrade the emailmessage crate 2018-11-05 16:12:01 +00:00
Phil Booth f5023c2f23
Merge pull request #221 from mozilla/pb/tidy-app-errors
https://github.com/mozilla/fxa-email-service/pull/221
r=rfk
2018-11-01 21:13:34 +00:00
Phil Booth 90c6a0110e
refactor(errors): stop exposing AppErrorKind directly from AppError
There was a minor violation of the law of Demeter in our `AppError`
struct, where it was directly exposing its inner `AppErrorKind` to
callers. Not a huge deal, but it meant that any changes made to the
inner structure would leak out and require corresponding changes to the
consuming code (and I am planning some of those inner changes as part of
issue #210). Better to expose just the parts that are necessary via its
own API.

At the same time, I opted to replace the home-baked `AppError::json()`
method with a more conventional `impl Serialize`, because it's less
astonishing and just as easy to use with `serde_json::to_string`.
2018-11-01 11:02:11 +00:00
Phil Booth 12e4a4c37b
Merge train-124 into master
https://github.com/mozilla/fxa-email-service/pull/215
r=shane-tomlinson
2018-10-30 15:51:01 +00:00
Phil Booth c0dfd7a382
chore(package): bump version, update changelog 2018-10-30 14:09:55 +00:00
Phil Booth cb5ccbf78d
Merge pull request #213 from mozilla/pb/tidy-src-tree
https://github.com/mozilla/fxa-email-service/pull/213
r=shane-tomlinson
2018-10-30 13:29:02 +00:00
Phil Booth cf32a4362d
refactor(project): tidy up the directory structure a bit
We've grown a lot of modules in this repo and it's hard to see the wood
for the trees when you look in the `src` directory. This commit attempts
to neaten everything up a bit by scoping some of them under collective
parent modules:

* `auth_db`, `delivery_problems` and `message_data` have moved to `db`,
  and the old `db` has moved to `db/core`.

* `healthcheck` and `send` have moved to `api`.

* `app_errors`, `duration`, `email_address` and `validate` have moved to
  `types`, and `app_errors` is now just `error`.

* `serialize` has moved to `settings` as it was only referenced there.

Hopefully the end result makes it easier to zero in on modules of
interest when working in the repo.
2018-10-30 07:30:21 +00:00
Phil Booth eeb4b60478
Merge pull request #209 from mozilla/pb/update-deps
https://github.com/mozilla/fxa-email-service/pull/209
r=rfk
2018-10-29 22:04:36 +00:00
Phil Booth c152bc8765
fix(code): remove references to old rocket_contrib::JsonValue struct 2018-10-29 21:41:23 +00:00
Phil Booth 5530fddb96
fix(settings): remove references to RocketLoggingLevel::Off enum variant 2018-10-29 21:41:23 +00:00
Phil Booth afe8713277
chore(deps): update rocket and rusoto versions from pinned git hashes 2018-10-29 21:41:23 +00:00
Phil Booth 2057d57ac7
chore(code): cargo fmt 2018-10-29 21:41:23 +00:00
Phil Booth 03f19145e7
chore(toolchain): update to latest rust nightly 2018-10-29 21:41:23 +00:00
Phil Booth 36d0486bfe
Merge pull request #212 from mozilla/pb/asref-str
https://github.com/mozilla/fxa-email-service/pull/212
r=rfk
2018-10-29 21:30:59 +00:00
Phil Booth 48cff69209
fix(code): implement AsRef<str> for cheaper/cleaner &str access
Fixes #211.

For a bunch of types in `src/settings.rs` and for `NotificationType` in
`src/queues/sqs/notification/mod.rs`, we were allocating `String`
instances when it wasn't always necessary. Where an existing slice can
be used, it's preferable.

At the same time, I removed a load of `.0` inner type access for the
newtype structs in `Settings`, because that notation is leaky (if we
want to refactor the struct to something else, all the usage must change
too).
2018-10-29 21:21:53 +00:00
Phil Booth 06eb6a652b
Merge pull request #208 from mozilla/pb/fix-generic-notification-structure
https://github.com/mozilla/fxa-email-service/pull/208
r=rfk
2018-10-29 21:21:03 +00:00
Phil Booth e3e361c667
fix(queues): fix the serialized format of outgoing notifications
The `bounced_recipients` property of the outgoing notification structure
was missing a serde `rename` attribute. That problem went undetected
because we had no test coverage for the outgoing structure, which was a
pretty large hole in our coverage. This change fixes the issue and adds
some serialization assertions.
2018-10-29 07:16:19 +00:00
Phil Booth 18a9584dd1
Merge pull request #203 from mozilla/pb/166
https://github.com/mozilla/fxa-email-service/pull/203
r=brizental,vbudhram
2018-10-17 19:42:37 +01:00
Phil Booth 68a1def7dc
fix(redis): don't pollute our data store with old bounce nomenclature 2018-10-17 08:32:46 +01:00
Phil Booth 1093258f70
refactor(redis): store delivery problems in reverse order 2018-10-16 21:20:14 +01:00
Phil Booth ed83e5b1da
feat(db): write bounce and complaint records to our own db
This is the first step towards migrating away from the FxA auth db.
We'll start by dual-writing to both databases. Then, after we've got
sufficient history to fully evaluate limit violations, we can switch
over to read from our own datastore and ditch the auth db.
2018-10-16 16:27:31 +01:00
Phil Booth 0330c43738
Merge pull request #204 from mozilla/pb/delivery-problem-order
https://github.com/mozilla/fxa-email-service/pull/204
r=vladikoff
2018-10-16 16:21:40 +01:00
Phil Booth 14a5eb774a
chore(tests): add test coverage for the order of delivery problems 2018-10-16 14:07:00 +01:00
Phil Booth fcb250ce18
Merge pull request #198 from mozilla/pb/delivery-problems
https://github.com/mozilla/fxa-email-service/pull/198
r=rfk
2018-10-16 07:22:42 +01:00
Phil Booth 3b32fe021b
refactor(bounces): pull all bounce/complaint code into one module
This change does two things:

1. The old `BounceRecord`, `BounceType` and `BounceSubtype` types are
   removed from the `auth_db` module into `bounces`, so that they can
   more easily be re-used when writing bounce/complaint data to Redis.

2. Those types are renamed to `DeliveryProblem`, `ProblemType` and
   `ProblemSubtype` respectively, and the `bounces` module is renamed to
   `delivery_problems`. That may seem weird at first, but I have good
   reason for it and am open to alternative names if anyone can suggest
   something better.

   Historically we've always treated complaints as a type of bounce
   event, but that's inaccurate because bounces are never preceded by a
   delivery event whereas complaints are always preceded by one. This
   has caught me out in the past when analysing metrics and expecting a
   blanket sum of `deliveries + bounces = sends` to be true. It isn't.
   It's only true if you filter complaints from bounces before
   calculating the sum.

   Because of that, I wanted some different nomenclature that didn't use
   "bounces" as an umbrella term for "bounces and complaints". It won't
   affect the names we use in the metrics but I think it's important for
   language we use in the codebase to be as precise as possible. Things
   like "delivery error" or "delivery failure" also seemed inaccurate
   for the same reason; a complaint implies that the actual delivery
   succeeded. Hence "delivery problems", which seems generic enough to
   legitimately include both event types.
2018-10-16 07:06:12 +01:00
Phil Booth edc09f137a
Merge pull request #202 from mozilla/pb/redis-optional-result
https://github.com/mozilla/fxa-email-service/pull/202
r=vladikoff
2018-10-15 15:08:11 +01:00
Phil Booth 8031ff6f57
refactor(redis): stop treating no data as an error in the getters 2018-10-15 12:23:48 +01:00
Phil Booth 636e44f796
Merge pull request #200 from mozilla/pb/db-json-serialize
https://github.com/mozilla/fxa-email-service/pull/200
r=rfk
2018-10-08 06:51:19 +01:00