Support apps hints for Gmail Contacts and Events sync.

Summary:
This revision supports applications proposals to sync contacts and events. The
application that requests the authentication of an account decleare if it is
interested in contacts and events sync (see Application and Proposal in
redwood.git), the hint is recorded in the RDB and is used to start greenlets
as needed.

NOTE: this revision disables event sync for Outlook.com temporarily since we
don't support requesting permission to access them.

Test Plan:
The behavior within this repository should remain the same before and after
this revision. However, some applications of those we've in prod don't require
contacts and events sync; for those applications new accounts shouldn't start
useless greenlets.

Reviewers: khamidou, emfree

Reviewed By: emfree

Subscribers: spang

Differential Revision: https://review.inboxapp.com/D908
Add regression test for numeric Gmail label parsing.

We've had enough regressions with this.
Upgrade test db dump
Short-circuit in _choose_existing_thread_for_gmail.

This avoids an unecessarily expensive lazy load in the common case that there's
exactly one prior thread.
Optimize IMAP update_metadata function.

Summary:
recompute_thread_labels() proves to be a relatively expensive function. The
problem with this is that in generic IMAP sync, we refetch flags for up to
refresh_flags_max=2000 UIDs, and recompute thread labels for each associated
thread, even if there weren't actually any changes. This turns out to be really
expensive in CPU time and query volume.

Instead, check if there are actual flag changes. In the process, rename
`ImapUid.update_imap_flags` to `ImapUid.update_flags_and_labels ` for clarity,
and clean up the relevant code a bit.

Test Plan: Unit tests.

Reviewers: spang

Reviewed By: spang

Differential Revision: https://review.inboxapp.com/D926
Reduce retries from 100 in 5 minutes to 5.

Summary:
This revision reduces the maximum number of retries in the 5 minutes span from
100 to 5 since we definitely cannot reach 100 retries in 5 minutes given the
current load we have.
This should prevent never-ending loops between the account monitors and the
folder engines, something we were observing in our EAS code.

Fix T670.

Test Plan: Non-disruptive change. Nothing bad should happen.

Reviewers: emfree, kav-ya

Reviewed By: kav-ya

Subscribers: spang

Maniphest Tasks: T670

Differential Revision: https://review.inboxapp.com/D925
Batch device delete operations.

Summary:
This commit introduces batching for device delete operations. When the
EAS code invokes del_device() for a certain account, we have to make a
first round-trip to collect all the keys (account:folder) for that
account and, for each key, perform a device delete operation. By
batching these operations, we avoid multiple rount-trips.

Test Plan: Sync an EAS account.

Reviewers: khamidou, kav-ya

Reviewed By: kav-ya

Differential Revision: https://review.inboxapp.com/D935
Escape parameters in log statement to prevent downstream parse errors.

Test Plan: Relentless optimism.

Reviewers: kav-ya

Reviewed By: kav-ya

Differential Revision: https://review.inboxapp.com/D936
Fix GoDaddy MX records.
Clean up unit tests a bit.

Summary:
Splitting out some housekeeping undertaken while writing tests for D933.
* Remove miscellaneous cruft.
* Add fixtures that commit linked Message, Thread, Folder, and ImapUid objects,
  for more concise tests.

Test Plan: Run the tests.

Reviewers: kav-ya

Reviewed By: kav-ya

Differential Revision: https://review.inboxapp.com/D932