[auth] Add the NotSupportedError exception.
[SCHEMA] Fixes T163: Drafts synced from remote can't be updated/sent via API

Summary:
Kill SpoolMessage, the Message table stores the extra info needed for Inbox-created, synced back drafts.

Also fixes a few minor drafts related bugs.

Test Plan: None (regression tested)

Reviewers: emfree

Reviewed By: emfree

Differential Revision: https://review.inboxapp.com/D255
Fixes T185: Column extra_flags cannot be null
Clarify phrasing in API filtering documentation.
Don't copy created_date in migration 066.

Not using that field anymore.
Update test db dump to not include message.created_date.
[SCHEMA] Set executed status on action log entries.

Summary:
This is a prerequisite to running the syncback service as an actual standalone
service: we can stop and restart it and not need to worry about losing actions.

Test Plan: Unit tests updated.

Reviewers: kav-ya

Reviewed By: kav-ya

Differential Revision: https://review.inboxapp.com/D259
[exceptions/NotSupported] Consolidate the NotSupported exception to a single location. Perhaps exceptions should be put in a util library?

Summary: Remove the NotSupported exception from the util.url file to consolidate.

Test Plan: regression

Reviewers: emfree

Reviewed By: emfree

Differential Revision: https://review.inboxapp.com/D262
Fix assorted drafts/sending bugs.

* Keep track in memory of which syncback actions have been scheduled but not
  completed, so that we don't try to schedule them twice.
* Remove `message.is_draft` assertion from inbox.actions.delete_draft. This was
  failing when we sent a message, then tried to delete the draft-that-it-was.
* Return instead of raising an AssertionError if we try to send a message that
  isn't a draft or is already sent.
* Distinguish between creating a draft and syncing it to the backend,
  and creating a draft only to send it immediately (in the /send API).
* When constructing the In-Reply-To and References headers on a message, don't
  the previous message's Message-Id and References headers may be null. In this
  case, gracefully degrade instead of failing with a TypeError.
Fixes T194: IntegrityError (1452) FolderItem.folder_id -> Folder.id Foreign Key Constraint Fails.

Summary:
Here's what I think the issue is:

We create a new Folder (line 118, mailsync.base.create_db_objects()) but do not add it to the session.
The corresponding FolderItems are created in line 680, mailsync.gmail.add_gmail_attrs() with autoflush disabled.
Then in contacts.process_mail.update_contacts(), we call get_contact_objects();
the db_session.query(Contact).filter(…).all() in this function triggers an autoflush and causes
the IntegrityError (1452): foreign key constraint fails for FolderItem.folder_id -> Folder.id because the FolderItems are in the session but the Folder
is not.

To fix this:
Added the Folder to the session in mailsync.base.create_db_objects()

Note:
I am not certain that this is the issue, I could not repro it to test the fix - hence, the request for review.

Test Plan: Sync runs as before.

Reviewers: emfree

Reviewed By: emfree

Differential Revision: https://review.inboxapp.com/D263
Add a script to run the syncback service independently.

We need this if the API is deployed other than via the bin/inbox-api script.
Moved from pyflakes and pep8 to flake8

Summary: flake8 has some desirable features like annotations to deactivate unneeded warnings.

Test Plan: check if linting still works (it does)

Reviewers: spang, emfree

Reviewed By: emfree

Differential Revision: https://review.inboxapp.com/D258
Potentially fix T197, T194.

Summary:
T197 was due to yesterday's "fix" to T194.
Therefore revert it (i.e. remove the db_session.add(folder) in create_db_objects();
if no new_uids were added, there is no db_commit() before the save_folder_names() which
will try to create the same folder raising the error in T197).

This didn't really fix T194 anyway so it's not a huge loss.

So, take two at fixing T194:
Folder.create() adds the created Folder to the session;
there is some weirdness about association proxy + backref
(See: https://groups.google.com/forum/#!topic/sqlalchemy/6RV6ay3rwIs).
In particular, I'm not sure how autoflush behaves in this case when
the folder the FolderItem is instantiated with may not have been
explicitly added to the session.

As before, not certain this is a guaranteed fix but:
1. I'd like to test it against mg's failing accounts on Gunks.
2. I won't mark anything as resolved till we see it is.
3. It may work.

Test Plan: Sync on inboxapptest runs.

Reviewers: emfree

Reviewed By: emfree

Maniphest Tasks: T194

Differential Revision: https://review.inboxapp.com/D264
Add support for yahoo syncback actions

Summary:
Implemented all actions - needs review.

Christine, could you take a quick look at the code and tell me if it's okay?
I'd like to have your opinion on this specific things:

1. I'm not sure I'm doing the ORM requests the right way. There's probably something
   more efficient than loading all the fields from the db.

2. I'm a bit wary about the race condition we get when deleting a draft which is not yet
   reconciled. I'm open to suggestions about how to handle this.

fixed rebase bug

code for review

rebased latests changes + fixed rebasing bugs

ignore soft deletes - fixes draft deletion bug

draft deletion and reconciliation

refactor - moved draft deletion code from YahooCrispinClient to CrispinClient - ... we won't need it for yahoo because their servers don't support querying a specific header

Test Plan: manual testing, interacting with the REST API using curl.

Reviewers: spang

Reviewed By: spang

Subscribers: kav-ya

Differential Revision: https://review.inboxapp.com/D257
[outlook] Initial outlook support.

Summary: Support hotmail/outlook by mimicking yahoo's generic imap support

Test Plan: auth/sync a hotmail account

Reviewers: khamidou, spang

Reviewed By: spang

Subscribers: khamidou, emfree

Differential Revision: https://review.inboxapp.com/D260
[merge] Fix alembic history / diversion.
[Monocle]
Fully reset sync status on restarting foldersyncs.
Sync type (new/resumed) on account, rather than folder.
Fixes T191: Flanker DecodeError in EAS
[config] Add the default values back in for the client id / client secret for google and ms live.
Fixes  T201: Drafts API should support ?thread=filter.

Summary:
get_drafts() method added to inbox/api/filtering.Filter
draft_query_api() added to inbox/api/ns_api.py

Test Plan: Added test in tests/api/test_drafts.py

Reviewers: emfree

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