Add merge to InboxSession

Summary: Adds merge to InboxSession.

Test Plan: Tested trivially. The motivation for this change is to unbreak a test elsewhere.

Reviewers: emfree

Reviewed By: emfree

Differential Revision: https://review.inboxapp.com/D857
Support EAS contacts, events modules.
Set the 'state' property for drafts synced from the remote.

Summary:
This way drafts created locally and remotely have the same
representation.

Fixes T343.

Test Plan:
Check that drafts created on the backend have the 'state' property
set.

Reviewers: kav-ya

Reviewed By: kav-ya

Maniphest Tasks: T343

Differential Revision: https://review.inboxapp.com/D855
Make async test less flaky.

Poll until timeout rather than just sleeping before checking the syncback
result.
Convert the default string datetime format returned by Elasticsearch to Unix timestamp format.

Summary:
Fixes T653.

This is intended as a quick fix so Edgehill is not blocked on it.
A better solution is to change our mapping and reconfigure the index,
this is what we'll do for prod.

Test Plan: Tested manually.

Reviewers: emfree

Reviewed By: emfree

Subscribers: bengotow

Maniphest Tasks: T653

Differential Revision: https://review.inboxapp.com/D859
Fetch all events in Google calendar sync.

Summary:
Previously we'd unwittingly only sync the first 250 events returned by the
Google calendar API for any given calendar. Fixes T658.

Test Plan:
Run sync, check that more events are synced for large calendars than
were previously.

Reviewers: khamidou, kav-ya

Reviewed By: kav-ya

Maniphest Tasks: T658

Differential Revision: https://review.inboxapp.com/D870
Reduce code duplication between inbox.git and redwood.git.

Summary:
This revision consolidates everthing under inbox.status.* into
inbox.status.sync. In addition, it simplifies the bin/inbox-syncstatus script,
which now shares plenty of code with the admin dashboard.

Addresses https://review.inboxapp.com/T656.

Test Plan: Check if inbox and redwood are working correctly.

Reviewers: emfree, jennie

Reviewed By: jennie

Differential Revision: https://review.inboxapp.com/D863
Don't show remote events in the delta sync API

Summary:
So, Esper have reported that they've got duplicate events in the delta sync output. I turns out that was because of a subtlety of the events sync engine. When we're syncing events, we store two different objects pointing to the same event: a local version (with local changes) and a remote version. The problem is we surface both objects in the delta sync API, which is confusing for our customers.

This patch fixes this, in a myopic way. Going forward, I think we'll have to break up the delta sync API to have one endpoint for each resource. As is, it's pretty complicated to have custom filtering/formatting of the data.

Test Plan: Tested manually. Checked that only local events surfaced.

Reviewers: kav-ya, emfree

Reviewed By: emfree

Subscribers: spang

Projects: #sync-engine, #customers

Maniphest Tasks: T663

Differential Revision: https://review.inboxapp.com/D871
[SCHEMA] Migration for easeventuid.

Summary:
Note this does not include a script to backfill the table
for existing events.

Also note this does not include the msg_uid index because we don't need it
(will update code too).

Test Plan: Run it, visually inspect.

Reviewers: emfree

Reviewed By: emfree

Differential Revision: https://review.inboxapp.com/D874
make default test event local, since remote ones suppress transactions
Handle spurious UIDVALIDITY changes in generic IMAP.

Summary:
We're actually seeing this in the wild. We still can't do a full resync, but at
least this keeps syncs from getting totally stuck in the face of flaky
UIDVALIDITY responses.

Test Plan:
Poison sync logic to sporadically raise UidInvalid, check that
sync cleanly enters and exits uidinvalid state.

Reviewers: siro, spang

Reviewed By: spang

Differential Revision: https://review.inboxapp.com/D876
fix TypeError
Import SearchIndexCursor model too.
Optimize search time format conversion

Summary: Convert datetime to Unix timestamp at index-time rather than at search result processing.

Test Plan: Tested manually.

Reviewers: emfree

Reviewed By: emfree

Differential Revision: https://review.inboxapp.com/D877
Allow account-restricted checks with bin/inbox-syncstatus.
Improve setup.sh to avoid installing software in production.
Overhaul IMAP draft deletion.

Summary:
Basically, in order to do away with soft-deletes we have to restructure
syncback actions such that the syncback service doesn't need to access database
objects that have been legitimately deleted. So we need a strategy for deleting
drafts that were created on the remote (and hence have no X-Inbox-Id header).
Previously we'd delete the entire thread (!), which in any case is definitely
not what we want to do. Now we instead just use either the X-Inbox-Id header or
the Message-Id header to locate the message on the remote.

(This is a prerequisite to fixing T666.)

Test Plan: All manual for now.

Reviewers: kav-ya

Reviewed By: kav-ya

Differential Revision: https://review.inboxapp.com/D881
Dockerfile path fixes
Missing import
Docker entrypoint must be run as root