Fix reconcile_messages() regression to only reconcile with local Inbox-created messages.

Summary:
Filtering by the inbox-uid header alone is not sufficient; more than one
message on the remote backend may have the same inbox-uid header.
Reconciliation should only occur with messages created locally, not messages synced;
that is incorrect and also causes issues like T550.

Test Plan: Regression test in inbox-eas.

Reviewers: emfree

Reviewed By: emfree

Differential Revision: https://review.inboxapp.com/D596
[api] Fix logging of the client_address when we're behind a proxy. This gets set to '' instead of None when retrieving it from WSGI.
[events/participants] Gracefully handle getting a participant without a status.

Summary: If we get a participant without a status, set it to 'noreply'
Fixes T555

Test Plan: review code

Reviewers: emfree

Subscribers:
[stop-sync] Re-work the logic around stopping syncs to make sure that the events and contacts syncs get stopped too.

Summary:
Previously stopping a sync would result in the events / contacts syncs continuing to run. Re-work the logic so that
we actually stop these syncs too (and remove some redundant checking).

Test Plan: review the code, start / stop syncs and make sure contacts / events sync stop too.

Reviewers: kav-ya

Reviewed By: kav-ya

Subscribers: emfree

Differential Revision: https://review.inboxapp.com/D608
[schedule/work-stealing] Make work-stealing be a configurable option.

Summary: add a configuration option to control when machines should work-steal accounts.

Test Plan: read the code

Reviewers: kav-ya

Reviewed By: kav-ya

Subscribers: emfree

Differential Revision: https://review.inboxapp.com/D610
[SCHEMA] Add index on thread table for improved API performance.

Summary:
Diminishes API response times for /n/<ns_id>/threads?tag=inbox from >10 seconds
to ~780ms.

Test Plan:
Run migration script; benchmark against read replica of prod DB with
and without index.

Reviewers: khamidou

Reviewed By: khamidou

Differential Revision: https://review.inboxapp.com/D616
[SCHEMA] Add account.name column, and "name" attribute to API namespaces.

Summary:
Right now we have this for Gmail and Outlook, and set it from the OAuth
response. But we really need to save this for all accounts, so that we can set
the `From:` header appropriately when sending mail. (We'll add a field to the
login form for generic/eas accounts.) Also expose it in the API's namespace
representation.

Test Plan: Run migration; curl /n/ endpoint.

Reviewers: kav-ya

Reviewed By: kav-ya

Differential Revision: https://review.inboxapp.com/D620
Use a more performant IMAP command for CONDSTORE queries.

For some reason, doing the MODSEQ search is deadly slow on Gmail, but doing
FETCH 1:* (...) (CHANGEDSINCE <modseq>) is fast.
Simplify IMAP sync concurrency; don't sync both Inbox and All Mail for Gmail.

This commit implements the late-night realization that it's totally unnecessary
to have two greenlets trying to concurrently modify the download stack during
initial sync.

Concretely:

* For generic IMAP, we can just periodically interrupt the initial sync and
  recompute the set of uids on the remote, i.e., the contents of the download
  stack. No concurrency is best concurrency. (We now need a separate flags
  refresh poller, but it's pretty lightweight).

* For condstore, the change poller greenlet checks for updates on the remote,
  and if there are any, communicates them to the main downloading greenlet via
  a `changed_uid_channel` (which is really a JoinableQueue, but conceptually
  resembles as a Go-style channel). So all manipulation of the download stack
  happens on one greenlet, removing much of the need for locking and careful
  reasoning.

* For Gmail, no longer sync Inbox and All Mail concurrently. Doing so was super
  complicated and inefficient. Instead, just sync All Mail. (It used to be that
  condstore was super slow on large folders, so we couldn't do this and get new
  Inbox messages in a timely manner. But we were actually just doing condstore
  wrong, so this is no longer a concern.)

* For simplicity, expand threads when syncing Gmail spam and trash. This
  doesn't change the sync behavior much, just makes for less and simpler code.

* Includes a schema migration only to force all Gmail inbox folder syncs to
  stop, because otherwise things might break.