Commit graph

5714 commits

Author SHA1 Message Date
Christine Spang 933ebdfebb [iso-core] Split cert validation error handling off socket error handling
Summary:
Now that we don't do strict validation of certificates for non-major IMAP
providers this shouldn't come up as much, but when it does we're gonna
want a better error message to help support out.

I am not 100% sure there aren't other socket errors that should be fatal,
but this was the one I could figure out by test authing against a server
with a self-signed cert and grepping around the node socket source code.

Test Plan: manual

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3774
2017-01-25 09:45:20 -08:00
Evan Morikawa 313bd18913 bump(version): 1.0.13 2017-01-25 10:20:52 -05:00
Evan Morikawa 96f54829b3 bump(changelog): 1.0.13 2017-01-25 10:20:35 -05:00
Evan Morikawa b5a6739bfb bump(k2) 2017-01-25 10:13:05 -05:00
Evan Morikawa 0be186302a refactor(account): remove unused accont refresh methods
Summary:
This removes `refreshHealthOfAccounts`, which I originally found because I
was trying to refactor it out of the IdentityStore. We need it gone from
the IdentityStore so that store can trigger frequently as things like the
usageLimits constantly update on it.

This also fixes T7520 where we'd get `ECONNREFUSED 127.0.0.1:2578` on
launch unnecessarily.

The concept of refreshing the health of accounts by occassionally polling
the /accounts endpoint is obsolete. This depends on
D3769 which entirely removes the /accounts endpoint
from K2.

Account health is pushed to us by `Actions.updateAccount` which is fired
directly from the main local-sync sync loop.

This also removes `refreshAccounts` and `Actions.refreshAllDeltaConnections`. These were fired by the Identity Store whenever it updated. We no longer need the Identity Store to tell us to reset the delta connections with our local-sync accounts. The delta connections will either be reset by our offline notification button, or when adding or removing an account. The Identity Store was a redundant mechanisms

Test Plan:
Manually verify things work with an existing account. Add a new account
and ensure sync starts. Remove an account and ensure it gets cleaned up.

Reviewers: halla, khamidou, mark, juan

Reviewed By: juan

Maniphest Tasks: T7520

Differential Revision: https://phab.nylas.com/D3770
2017-01-25 10:12:09 -05:00
Evan Morikawa ddcd097c9b [local-sync] remove /account API endpoint
Summary:
It turns out we don't ever use the /account API endpoint.

The GET /accounts endpoint was designed to query all accounts connected to
a system for old K2, but we don't use that anymore. The environment
variable protecting the endpoint isn't set anywhere.

We used to `GET /account` from the N1 AccountStore to attempt to refresh
the health of the accounts. The accompianing diff to this one makes that
obsolete. We never need to query for the account health since the sync
loop pushes it to us through `Actions.updateAccount`.

We also never `DELETE /account` because our local-sync runs a function
called `ensureK2Consistency` that compares its DB against the Nylas Mail
`AccountStore`.

This file has always been a huge source of confusion to me and a massive
red herring for anyone trying to understand how the account system work.
The accompyaning diff has more comments explaining the existing system

Depends on https://phab.nylas.com/D3770

Test Plan:
Manually boot N1. Ensure existing account works. Add a new account. Remove
an account. Open the developer tools and check that all the tabs still
work.

Lots of grepping through the code base.

Reviewers: halla, mark, juan, khamidou

Reviewed By: juan, khamidou

Differential Revision: https://phab.nylas.com/D3769
2017-01-25 10:10:10 -05:00
Evan Morikawa f2517ea7d7 refactor(name): rename worker-sync package to deltas
Summary:
This diff is a rename. No logical changes.

We used to have a set of files called `nylas-sync-worker`. In Old N1 these
used to have a lot of logic to slowly sync mail from our API. Since we
exclusively use local-sync via a soon-to-be-obsolesced delta stream, these
files really just manage the delta streaming connection.

It's incredibly confusing to have a set of files called worker-sync when
there's a sync-worker already in the codebase. This renames everything to
refer to them as account sync workers.

The reason I wanted this rename is because the IdentityStore on initial
launch triggers and fires a fairly scary-sounding
`Actions.refreshAllSyncWorkers()`. In reality all it does is
`Actions.refreshAllDeltaConnections()`. I'm also tired of staring at files
for a full minute before realizing that this is not the sync worker I was
  looking for.

Test Plan:
After rename, booted the app and ensured that deltas were coming through
for new mail and no errors were being thrown

Reviewers: halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3767
2017-01-25 10:08:23 -05:00
Juan Tejada 0b89947c13 [local-sync] Make EnsureMessageInSentFolder save db changes after imap success
Summary:
This will solve T7579 when saving messages to the sent folder. I
attempted to clean up the references code but decided it was better left for a
new diff, so added a bunch of TODO's in this diff

Test Plan: manual

Reviewers: halla, spang, evan

Reviewed By: spang, evan

Differential Revision: https://phab.nylas.com/D3766
2017-01-25 00:29:30 -08:00
Christine Spang ca5c676c18 [iso-core] 🎨 Use a more descriptive variable name in _resolveIMAPSettings() 2017-01-24 19:22:14 -08:00
Christine Spang 6f25c1de34 [iso-core] Allow self-signed certificates in IMAP connections to non-major providers
Summary:
Unfortunately, many IMAP hosts outside the major ones do not have
certificates issued by a certificate authority, and it is very confusing
to folks to have their account auth not work. This patch relaxes our
certificate requirements for IMAP hosts outside the major providers.

It's cool that node 6 has secure TLS settings by default!

Fixes: T7673

Test Plan: manual

Reviewers: mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3771
2017-01-24 18:52:30 -08:00
Juan Tejada d644fe6396 bump(k2) 2017-01-24 17:43:34 -08:00
Juan Tejada d8c8dd809c fix(auth) Dont allow invalid form submission with Enter key 2017-01-24 17:43:34 -08:00
Halla Moore d3a0d60f0d fix(unpersistModel) Add default value for opts param
Just an empty object, so looking up a property on it doesn't error.
(Also some whitespace changes that automatically changed on save.)
2017-01-24 16:45:49 -08:00
Juan Tejada 5ed1f4da9e 🎨 Fix to using imap-provider-settings package
Summary: see title

Test Plan: manual

Reviewers: spang, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3772
2017-01-24 16:25:03 -08:00
Christine Spang d0bbb1663e fix typo 2017-01-24 13:58:09 -08:00
Juan Tejada b0f2068b08 [*] report sending errors to sentry 2017-01-24 13:13:05 -08:00
Juan Tejada 899538d642 fix(auth) fix timeouts 2017-01-24 12:06:56 -08:00
Juan Tejada ae584a8367 fix(auth) Increment IMAP auth timeout
Given that imap connections can take up to 90 seconds (see `auth-helpers` in k2),
we don't want to hang up our local connection too soon
2017-01-24 12:02:58 -08:00
Christine Spang 7082ddeabf fix(updater): s/N1/Nylas Mail/ 2017-01-24 11:57:08 -08:00
Evan Morikawa 51d17ce937 bump(changelog) 2017-01-24 14:51:51 -05:00
Juan Tejada eecf19717a bump(k2) 2017-01-24 11:46:53 -08:00
Juan Tejada 8b36e2ec90 bump(changelog) 2017-01-24 11:46:46 -08:00
Juan Tejada 6811a6f37e [*] Increment IMAP auth timeout
- More than 50% of auth errors we're seeing still seem to be geniune
timeouts. Increment the timeout to account for this.
2017-01-24 11:35:46 -08:00
Evan Morikawa 2e7e8c2d01 fix(build): add output log interval to prevent travis from dying 2017-01-24 14:27:32 -05:00
Evan Morikawa 677b56f714 feat(build) add npm run local-ci 2017-01-24 14:09:17 -05:00
Tomasz Finc 212120d591 bump(changelog) 2017-01-24 09:36:08 -08:00
Evan Morikawa d96672ab57 bump(version): 1.0.12 2017-01-24 12:23:25 -05:00
Evan Morikawa a20b979208 feat(analytics): add analytics for change mail tasks
Summary:
Adds the following new events:

- Threads Moved to Folder
  - isArchive
  - source
  - folderType
  - folderDisplayName
  - numThreads
  - numMessages
  - description
  - isUndo

- Threads Changed Labels
  - isArchive
  - source
  - labelTypesToAdd
  - labelTypesToRemove
  - labelDisplayNamesToAdd
  - labelDisplayNamesToRemove
  - numThreads
  - numMessages
  - description
  - isUndo

- Threads Starred
  - source
  - numThreads
  - description
  - isUndo

- Threads Unstarred
  - source
  - numThreads
  - description
  - isUndo

- Threads Marked as Read
  - source
  - numThreads
  - description
  - isUndo

- Threads Marked as Unread
  - source
  - numThreads
  - description
  - isUndo

Each new action has a "source" property that's one of the following:
- Category Picker: New Category
- Category Picker: Existing Category
- Toolbar Button: Message List
- Toolbar Button: Thread List
- Send and Archive
- Context Menu: Thread List
- Thread List Icon
- Quick Actions: Thread List
- Swipe
- Keyboard Shortcut
- Dragged Out of List
- Snooze Move
- Important Icon
- Label Remove Icon
- Thread Selected
- Mail Rules
- Dragged Into List

Test Plan: manual

Reviewers: juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3760
2017-01-24 12:22:33 -05:00
Juan Tejada 0e19f4511e fix(auth): Properly wait for acct to be inited before adding to sidebar
Summary:
Previously, when adding an account, we waited for it to be completely loaded (which meant having fetched the folder list) before focusing it on the sidebar. This could take several seconds, so it made the app feel unresponsive or slow when adding an account.

Then, we changed the logic to wait an arbitrary amount of time to focus the newly added account in the sidebar, with the hope that it would be enough time to focus it correctly but that it wouldn't seem too long. This still caused the unwanted effect of focusing it before it had been fully loaded.

This commit changes the auth flow so that the onboarding shows a Success page until the newly added account is fully loaded, and only /then/ closes itself, focuses the main window, and allows the account to be correctly focused in the sidebar.

Test Plan: manual

Reviewers: halla, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3751
2017-01-24 07:34:18 -08:00
Juan Tejada 3ca694fd30 fix(sync) Make category syncback tasks save changes after imap success
Summary:
This will solve T7579 for actions involving categories (folders/labels)
Depends on D3753

Test Plan: manual

Reviewers: halla, mark, khamidou, evan, spang

Reviewed By: evan, spang

Differential Revision: https://phab.nylas.com/D3754
2017-01-24 07:31:37 -08:00
Juan Tejada 8b3944d235 [local-sync] Make category syncback tasks save changes after imap success
Summary: This will solve T7579 for actions involving categories (folders/labels)

Test Plan: manual

Reviewers: khamidou, halla, mark, evan, spang

Reviewed By: evan, spang

Differential Revision: https://phab.nylas.com/D3753
2017-01-24 07:30:43 -08:00
Juan Tejada e909c8dfc7 [local-sync] Make thread syncback tasks save changes after imap success
Summary: This will solve T7579 for thread operations

Test Plan: manual

Reviewers: evan, mark, khamidou, halla, spang

Reviewed By: halla, spang

Differential Revision: https://phab.nylas.com/D3755
2017-01-24 07:29:25 -08:00
Christine Spang 359e32282f [local-sync] Sync draft flag from provider to K2 & exclude drafts from Edgehill
Summary:
We've been syncing drafts messages but not the drafts flag in K2, making
them appear in Edgehill as regular old messages.

This commit makes K2 sync the drafts flag, and also correctly label
folders called "Drafts" with the 'drafts' role.

Because 2-way syncing of drafts is very complex and error-prone since
you need to add new drafts and delete the old ones on every update, and
we reaally don't want to do things like create multiplying draft copies
or accidentally lose a draft someone started composing elsewhere, we
simply exclude messages marked as drafts from being serialized to
Edgehill through the delta stream for now. This removes the confusing
behaviour and also sets a better stage for completing drafts sync later.

Eventually we will also want to add functionality to allow users to
select their drafts folder, but for now this code does the right thing
in many more cases.

While investigating this behaviour, I also discovered a bug we've never
seen before where Gmail isn't applying the \Draft flag to draft
messages, no matter which folder we fetch them from. :-/ This is very
unfortunate and there's no way for us to work around it other than to
fetch messages in the Drafts folder and manually apply the flag locally,
since "drafts" is not a label in Gmail, only another IMAP folder. Brandon
Long from the Gmail team says that this is because they've had
problems with clients which sync drafts, so the Gmail web client and
mobile apps do not set the \Draft flag on drafts. (I don't get how this
solves their problem, but okay.) Let's solve the issue on Gmail if it
comes up by user demand—should be relatively straightforward to
implement, but it adds sync work & complexity.

Fixes T7593

Test Plan: manual

Reviewers: halla, juan

Reviewed By: juan

Maniphest Tasks: T7593

Differential Revision: https://phab.nylas.com/D3749
2017-01-23 20:58:32 -08:00
Christine Spang 902ce10881 [local-sync] Don't be so strict about updating threads from messages
This is how we _add_ messages to a thread in the first place, so we cannot
place the constraint that the thread must contain the message already.
2017-01-23 20:54:01 -08:00
Mark Hahnenberg ac6ad38296 [local-sync] Throttle message processing when on battery
Summary:
We don't want to run message processing full tilt when a user isn't plugged in.
This diff adds some detection logic that causes message processing to be
throttled/unthrottled when a user unplugs/plugs in their computer.

Test Plan: Run locally unplugged and plugged in, verify that CPU use goes up/down

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3759
2017-01-23 18:31:35 -08:00
Halla Moore 9f5631b1fe [local-sync]: Update threads when they have messages removed
Summary:
See title

Depends on D3744

Test Plan: tested locally

Reviewers: spang, evan, juan

Reviewed By: spang, evan, juan

Differential Revision: https://phab.nylas.com/D3745
2017-01-23 17:04:39 -08:00
Juan Tejada 649449ff4d build(notif) Remove appveyor notifs for now 2017-01-23 13:30:27 -08:00
Mark Hahnenberg 5730d23da8 [search-index] Limit search index size
Summary:
This diff modifies the SearchIndexer class to handle limiting the search
index size. It does this by periodically re-evaluating the window of
the n most recent items in a particular index where n is the max size of
the index. It then unindexes the items which are marked as indexed but
are no longer in the window and indexes the things that are in the window
but aren't marked as indexed.

Test Plan:
Run locally with a reduced thread index size, verify that the index
includes the most recent items and that it is the correct size. Also verify that
the queries used properly use fast sqlite indices.

Reviewers: evan, juan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3741
2017-01-23 12:19:34 -08:00
Evan Morikawa 3710438296 bump(k2) 2017-01-23 15:02:17 -05:00
Mark Hahnenberg c7d8f1700d [thread-search] Background on-keypress search queries
Summary:
When the search index got very big the queries we were running during
after keypress would cause jank in the UI which was very noticeable on
subsequent keypresses. This diff backgrounds these queries and adds a
LIMIT to the fts MATCH clauses to avoid having to send too much stuff
across the IPC bridge.

Test Plan: Run locally, make sure that typing is smooth while searching

Reviewers: juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D3757
2017-01-23 11:50:27 -08:00
Halla Moore 6e6bc1239f fix(unindexModel): Don't re-persist unpersisted models
Summary: See title

Test Plan: tested locally

Reviewers: juan, mark, evan

Reviewed By: juan, mark

Subscribers: juan

Differential Revision: https://phab.nylas.com/D3744
2017-01-23 11:32:46 -08:00
Forbes Lindesay bd1a29357e Add the GitHub community plugin (#3197) 2017-01-21 15:52:39 -08:00
Richard Lai 2b6856c9f6 Fix typo (#3173) 2017-01-21 15:52:13 -08:00
Paul Xu acc36a1a2f Normalized size of buttons in preferences (fixes #2753) (#3112)
Normalized size of buttons across signature, accounts and mail rules preferences. Also make signature pane same size as other preference panels
2017-01-21 15:51:49 -08:00
Sachin Agarwal e7c023a742 Update CHANGELOG.md (#3194)
N1 > Nylas Mail
2017-01-21 15:48:41 -08:00
Christine Spang 0db62579bd [local-sync] Keep only one HTML part in multipart/alternative structures
Summary:
I thought it was gonna be OK that we kept all HTML parts in a multipart/alternative
MIME structure because the world is a sane place and nobody would ever put more
than one HTML part in a multipart/alternative structure.

I was wrong.

We have found extraterrestrial life^W^WI mean emails which contain duplicate,
exactly the same MIME parts within a multipart/alternative MIME structure: two
text/plain parts and two text/html parts. This is likely due to a broken MIME
implementation, or perhaps a bug in someone's email script. So, we should
only keep one text/html MIME part if there are multiple.

Test Plan:
manual for now---added this to my mail parsing regression test list
for implementation once we unify the DBs and have a roughly stable code
structure

Reviewers: halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3750
2017-01-20 17:53:57 -08:00
Evan Morikawa 5fe0650058 bump(version): 1.0.11 2017-01-20 13:55:57 -08:00
Evan Morikawa 4a08331799 bump(changelog) 2017-01-20 13:55:46 -08:00
Halla Moore 4d10abcc2c [local-sync] Be more permissive with content transfer encodings (CTEs)
Summary:
Rather than having a strict model where we don't decode the message if we
don't specifically recognize the CTE, treat any CTEs we don't recognize as
having no encoding. There are several CTE strings that could mean this (e.g.
7bit, 7BITS, 8-bit, binary, NONE, utf8), and we don't want to check for them
all. Additionally, if there is a CTE we don't support, the user will likely
see rendering issues and contact support. This will allow us to obtain more
concrete information about these messages.

Test Plan: manual

Reviewers: spang

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D3748
2017-01-20 13:54:53 -08:00
Juan Tejada a3f7300df9 fix(crash): Fix error reporting for unhandled promise rejections
When handling unhandled promise rejections, our error reporter would
completely freeze the worker window when trying to send a Promise
through the ipc bridge, rendering the app unusuable

This fixes T7621
2017-01-20 13:46:57 -08:00