Commit graph

1244 commits

Author SHA1 Message Date
Juan Tejada 58d2274faa [client-app] Update changelog 2017-04-11 15:41:30 -07:00
Nylas Coffee Machine 545f6a30da bump(version): 2.0.10 2017-04-11 13:34:47 -07:00
Juan Tejada 0525767518 [client-sync] Ensure allmail folder exists before trying to access it
Summary:
When checking for flag updates for gmail accounts, when syncing for the
first time the all mail folder won't be available because we haven't
fetched the folder list, so it will throw a runtime error

Test Plan: manual

Reviewers: mark, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4405
2017-04-11 12:36:39 -07:00
Halla Moore d226eaf4a7 [client-app] Fix SyncbackMetadataTask dependency
Summary:
Add a sequentialId check in isDependentOnTask() so that the first
SyncbackMetadataTask won't get blocked on other SyncbackMetadataTasks
in the queue for the same pluginId.

Addresses T8112

Test Plan: Manual

Reviewers: spang, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4404
2017-04-11 12:22:57 -07:00
Halla Moore 61594021ae [isomorphic-core] Add missing .default to require 2017-04-11 11:09:39 -07:00
Halla Moore 840ebebecf [isomorphic-core] Move buildMime to MessageUtils, add includeBcc option
Summary:
Since buildMime isn't always used explictly for the send operation (we
mostly use it for stuffing the sent folder, which is a separate
operation), move it to MessageUtils. Additionally, add an includeBcc
option. We don't want the BCC header to be visible on outbound messages,
but it needs to be present on the version that is saved to the sent
folder.

When we weren't including the BCC header in the sent folder version, we
were getting an id mismatch between our optimistic message and the
message that gets processed by the sync loop (because we include the bcc
participants when computing the id hash). When the sent message was a
reply, the optimistic message included the threadId, and this had the
side effect of leaving both versions of the sent message in the thread.
Since the optimistic message never receieved it's imap UID, any action
performed on the thread would fail with the missing UID error as seen in
T7941. Adding this BCC header will allow us to compute the proper id
hash and reconcile the synced message with the optimistic message.

Test Plan: manual

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4365
2017-04-11 10:49:58 -07:00
Halla Moore 379edfe0b8 [*] MessageFactory -> MessageUtils, SendUtils -> ModelUtils
Summary: Rename some util files

Test Plan: manual

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4364
2017-04-11 10:49:30 -07:00
Halla Moore f82c72aa88 [client-sync] Don't report stuck sync processes to Sentry
Summary: Just to mixpanel. Addresses T8095

Test Plan: Meh

Reviewers: mark, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4403
2017-04-11 10:45:09 -07:00
Juan Tejada f6f8f16e25 [client-app] Update changelog 2017-04-11 10:37:13 -07:00
Nylas Coffee Machine a412580cad bump(version): 2.0.9 2017-04-11 08:12:13 -07:00
Halla Moore 15c3e328fc [client-sync] Poll for gmail attribute changes from _mailListenerIMAPConn
Summary:
Normally, the imap connection emits an 'update' event when there are any
flag changes. Gmail, however, only emits the 'update' event when there
are new or removed messages. If there's a fairly large batch size being
synced in the sync loop, we don't want to wait until the end of that to
check if the highestmodseq has changed. To get around this, this diff
updates the new mail listener connection to periodically poll for the
highestmodseq and trigger the same update handler when changes are
detected.

Test Plan: manual

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4397
2017-04-10 15:46:02 -07:00
Halla Moore c6db6c3ae2 [client-app] Re-add imap to the onboarding accounts page
Summary:
Put the IMAP option back on the provider selection page within
onboarding. Also remove the 'hidden' property on account types since I
don't think we'll be using it for any other providers, and remove the
'Add Custom IMAP Account' from the application menu.

Addresses T8097

Test Plan: Manual

Reviewers: spang, mark, juan

Reviewed By: mark, juan

Differential Revision: https://phab.nylas.com/D4402
2017-04-10 15:44:26 -07:00
Juan Tejada 07d576d5f4 [client-app] Fix delta streaming connection retries
Summary:
Previously, every time our NylasLongConnection changed its status to
`connected`, we would reset our backoff scheduler, assuming that
every time our status changed to `connected` it meant that we would not
receive any errors.

However, if our backend is down or overloaded (or returning 401s like in
our recent outage), we would do the following:

1. Establish connection, change status to `connected`
2. Reset backoff scheduler
3. Receive error
4. Close connection
5. Schedule next retry using backoff scheduler. Delay will be 1s or less, because scheduler was reset in 2.
6. Retry after delay,
7. Repeat from 1., ad infinitum

This caused us to consistantly hammer our servers and render our
exponential backoff useless.

This commit makes it so we conly reset the backoff scheduler when we
actually receive deltas, and increments the max backoff to 10 minutes

Test Plan:
run against local n1Cloud, manually return 401s from the api, verify that we
didn't backoff at all before this diff, verify that we backoff correctly after
this diff

Reviewers: mark, spang, halla

Reviewed By: mark, spang, halla

Differential Revision: https://phab.nylas.com/D4401
2017-04-10 15:08:48 -07:00
Halla Moore e8957b787e [isomorphic-core] Handle weird MIME edge case with @ symbol
Summary:
Something weird happens with the mime building when the participant name
has an @ symbol in it (e.g. a name and email of hello@gmail.com turns
into 'hello@ <gmail.com hello@gmail.com>'), so replace it with
whitespace.

Test Plan: manual

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4363
2017-04-10 12:40:22 -07:00
Mark Hahnenberg be4b0d773c [client-app] Add benchmark mode
Summary:
There are some settings that apply to dev and prod modes that we don't want
to use while benchmarking. E.g. the folder where we store messages,
whether we generate long stack traces in our bluebird promises, etc.
This diff adds a benchmark mode so that we can change these settings to
something that works better for benchmarking.

Test Plan: Run locally, verify it works

Reviewers: evan, juan, spang

Reviewed By: juan, spang

Differential Revision: https://phab.nylas.com/D4374
2017-04-07 15:33:57 -07:00
Mark Hahnenberg c808438ee9 [client-sync] Transaction-ify processMessage
Summary:
We do lots of writes while processing a single message. To reduce the
write churn from lots of mini-transactions, this diff threads one
overarching transaction to everything in processMessage.

Test Plan: Run locally

Reviewers: spang, evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4394
2017-04-07 15:09:25 -07:00
Mark Hahnenberg b323e38f7c [client-sync] Increase sqlite page_size and cache_size
Summary:
The defaults are a little low. edgehill.db already does this. There's no
obvious effect on smaller dbs, but we should at least make the two
consistent.

Test Plan: Run locally

Reviewers: spang, evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4395
2017-04-07 13:08:13 -07:00
Juan Tejada 3befaf2d6e [client-app] Update changelog 2017-04-07 12:14:51 -07:00
Nylas Coffee Machine a30e63c91a bump(version): 2.0.8 2017-04-07 11:42:30 -07:00
Juan Tejada 763010326e [client-app] Ensure SyncbackMetadataTask dependency to prevent version conflicts
Summary:
Previously, SyncbackMetadataTasks for the same plugin did not depend on
each other, so they could try to modify the same piece of metadata
concurrently, which would likely produce version conflict errors.

This was happening with send reminders because we were queuing 2 of
these tasks back to back upn send success. Adding this dependency fixes
the version conflict errors when setting the metadata

Test Plan: manual

Reviewers: evan, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4393
2017-04-07 11:41:21 -07:00
Juan Tejada 17ade153f8 bump(version): 2.0.7 2017-04-06 19:32:30 -07:00
Karim Hamidou 01318370d4 [cloud-workers] [send-later] Fix send later token expiration
Summary:
Fixes T8076. So, the Gmail OAuth API returns us an expiration time in milliseconds, but we convert it to seconds everywhere, except in the cloud-api. This caused us to never refresh tokens because we'd be comparing seconds to milliseconds.

Fix this by converting the `expiry_date` from our credentials to seconds.

Test Plan: Tested manually. Will do more testing tomorrow, after my credentials expire.

Reviewers: evan, juan

Reviewed By: evan, juan

Maniphest Tasks: T8076

Differential Revision: https://phab.nylas.com/D4390
2017-04-06 18:57:16 -07:00
Evan Morikawa 236c71ea6a [iso-core, cloud-*] catch JSON parse errors in DB columns
Summary:
MySQL would insert bad JSON due to emoji errors. This would cause JSON
parse errors and prevent us from ever reading objects from the DB. We now
catch and return null instead with an error which will at least let the
query complete to let us isolate and deal with the malformed obeject (like
destroy it)

Test Plan: manual

Reviewers: spang, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4389
2017-04-06 18:22:29 -07:00
Christine Spang d09312c27f [cloud-*] Switch MySQL charset to utf8mb4
Summary:
We need this in order to be able to store 4-byte emoji and other
extended unicode characters in the database.

Test Plan: deploy to staging - need the change that sets the connection charset on staging :(

Reviewers: khamidou, juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D4387
2017-04-06 16:25:09 -07:00
Nylas Coffee Machine 3074ee2912 bump(version): 2.0.6 2017-04-06 16:12:23 -07:00
Juan Tejada 5880f2ace7 [client-app] Always fetch and update identity regardless of env
Summary:
This was annoying because we wouldn't fetch the identity when running `local`
env which produced all sorts of errors

Test Plan: manual

Reviewers: evan, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4380
2017-04-06 13:28:09 -07:00
Nylas Coffee Machine 50c0329591 bump(version): 2.0.5 2017-04-06 11:56:10 -07:00
Evan Morikawa 2ee67d2a7a [iso-core, cloud-*] move generate XOAuth2 & fix first auth usage
Summary:
We were not generating the XOAuth2 token on the first go when connecting
accounts. This would cause the first send later to fail. Since this
happens in ISO core, we needed to move the function out of cloud-core and
import from other places that use it

Test Plan: Manual

Reviewers: khamidou, juan, halla, spang

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D4375
2017-04-06 11:53:39 -07:00
Juan Tejada 8633058488 [isomorphic-core] Ensure IMAPConnPool uses updated account credentials
Summary:
Previously, we would initialize an `AccountPool` with an account
instance and reference the account as an instance variable. Then,
every time we created a connection, we used the account we had a
reference to obtain the credentials.

However, if the credentials on the account changed, e.g. when we refresh
the access token for gmail accounts, the connection pool would never
realize that the account had new credentials and always try to create
the connection with the old credentials, causing the sync worker to
enter an error loop of `Invalid credentials` errors

To fix this, we could reload the account every time we try to create a
connection, but it seems that the fresh credentials should just be
passed every time we create connections without the pool having to be
aware of potential changes under the rug.

This commit makes it so the pool no longer holds a reference to the
account, but rather it is passed in every time we check out a connection

Test Plan: manual. how did this even work before? :(

Reviewers: evan, halla, spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4370
2017-04-06 10:32:42 -07:00
Nylas Coffee Machine bb03d3c78e bump(version): 2.0.4 2017-04-05 17:54:09 -07:00
Nylas Coffee Machine 68b5550d54 bump(version): 2.0.3 2017-04-05 17:51:11 -07:00
Christine Spang cfe2971c2e [*] Revamp SSL options (including user-facing)
Summary:
Previously, the generic IMAP auth screen presented one security option to
users: "Require SSL". This was ambiguous and difficult to translate into
the correct security options behind the scenes, causing confusion and problems
connecting some accounts.

This patch does the following:
* Separates security settings for IMAP and SMTP, as these different protocols
  may also require different SSL/TLS settings

* Reworks the generic IMAP auth page to allow specifying security settings
  with higher fidelity. We looked at various different email apps and decided
  that the best solution to this problem was to allow more detailed
  specification of security settings and to ease the burden of more options
  by having sane defaults that work correctly in the majority of cases.
  This new screen allows users to pick from "SSL / TLS", "STARTTLS", or "none"
  for the security settings for a protocol, and also to instruct us that
  they're OK with us using known insecure SSL settings to connect to their
  server by checking a checkbox.

  We default to port 993 / SSL/TLS for IMAP and port 587 / STARTTLS for SMTP.
  These are the most common settings for providers these days and will work
  for most folks.

* Significantly tightens our default security. Now that we can allow folks to
  opt-in to bad security, by default we should protect folks as best we can.

* Removes some now-unnecessary jank like specifying the SSLv3 "cipher"
  in some custom SMTP configs. I don't think this was actually necessary
  as SSLv3 is a protocol and not a valid cipher, but these custom
  configs may have been necessary because of how the ssl_required flag was
  linked between IMAP and SMTP before (and thus to specify different
  settings for SMTP you'd have to override the SMTP config).

* Removes hard-coding of Gmail & Office365 settings in several
  locations. (This was a major headache while working on the patch.)

This depends on version 2.0.1 of imap-provider-settings, which has major
breaking changes from version 1.0. See commit for more info:
9851054f91

Among other things, I did a serious audit of the settings in this file and
"upgraded" a few servers which weren't using the SSL-enabled ports for their
provider to the secure ones. Hurray for nmap and openssl.

Test Plan: manual

Reviewers: evan, mark, juan, halla

Reviewed By: juan, halla

Differential Revision: https://phab.nylas.com/D4316
2017-04-05 17:49:43 -07:00
Halla Moore b5a19dd3e3 bump(version): 2.0.2 2017-04-05 16:04:42 -07:00
Evan Morikawa 4904a9ae85 [client-app] Updates to feature limiting
This is a squash of a bunch of commits releated to feature limiting.
Includes making the upgrade path seamless by accessing billing through a
WebView and making sure that the feature is enabled after upgrading, or
canceled if the upgrade path is stopped by the user in any way.

Included diffs
---------------
Differential Revision: https://phab.nylas.com/D4078
Differential Revision: https://phab.nylas.com/D4136
Differential Revision: https://phab.nylas.com/D4137
Differential Revision: https://phab.nylas.com/D4143
Differential Revision: https://phab.nylas.com/D4147
Differential Revision: https://phab.nylas.com/D4171
Differential Revision: https://phab.nylas.com/D4173
2017-04-05 16:02:53 -07:00
Halla Moore d9a9d66f5f [client-sync] Fix syncWorker arg
Summary: It needs to be wrapped in an object.

Test Plan: manual

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4367
2017-04-05 15:44:13 -07:00
Juan Tejada fc7856b4d0 [client-sync] Fix runtime error when getting sync activity for account
Summary:
Make sure SyncActivity.getLastSyncActivityForAccount returns a sensible
default to prevent runtime errors when the SyncProcessManager uses it

Test Plan: manual

Reviewers: evan, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4366
2017-04-05 14:10:01 -07:00
Nylas Coffee Machine 3653a66be2 bump(version): 2.0.1 2017-04-05 11:21:56 -07:00
Juan Tejada f708e3af0b [iso-core] IMAPConnectionPool now correctly disposes connections onDone
Summary:
Previously, calling the IMAPConnectionPool `onDone` callback when checking out a connection would just return the connection to the pool without re-establishing it the next time we checked it out of the pool.

When the `onDone` callback was called in an error scenario, this had the unintended consequence of returning a bad connection to the pool, and then re-using this bad connection. The only scenario when the connection was re-established was if `onConnected` threw an error, but if the connection was kept open outside the scope of onConnected, this logic would never run.

To make things simpler and more consistent, `onDone` will always destroy all connections and connections will always be re-established from scratch every time they are checked out of the pool. The pool acts more as a limit to the number of connections per account, than an actual shared pool of connections.

Test Plan: manual

Reviewers: evan, spang, halla, mark

Reviewed By: halla, mark

Differential Revision: https://phab.nylas.com/D4360
2017-04-05 11:10:41 -07:00
Juan Tejada 5269c11ee0 [client-sync] Prevent IMAP connection leaking in sync worker
Summary:
When the sync worker got stuck inside `performSync`, we would never
release the connection back to the connection pool. We would then try to
start a new sync worker, and it would claim a new connection. If this
happened enough times, we would eventually exhaust the whole pool and
keep the sync worker blocked forever.

Test Plan: manual

Reviewers: evan, spang, halla, mark

Reviewed By: halla, mark

Differential Revision: https://phab.nylas.com/D4359
2017-04-05 11:08:20 -07:00
Evan Morikawa 78a15700c8 [cloud-*] remove old SignalFX reporter & add docs
Summary:
This removes the old SignalFX reporter that we weren't using
Adding documentation around logging

Test Plan: manual

Reviewers: juan, halla, spang

Reviewed By: juan, halla, spang

Differential Revision: https://phab.nylas.com/D4341
2017-04-05 10:51:38 -07:00
Evan Morikawa 08a697e4c9 [cloud-*] log errors according to bunyan specs
Summary:
According to bunyan, https://github.com/trentm/node-bunyan, errors are
treated special. They either need to be the first argument of a log, or
they need to be attached to the special `err` (NOT `error`) key of the
logger object.

Test Plan: manual

Reviewers: halla, juan, spang

Reviewed By: halla, juan, spang

Differential Revision: https://phab.nylas.com/D4337
2017-04-05 10:47:56 -07:00
Juan Tejada a3072f6b04 [client-sync] 🎨 logging 2017-04-05 09:22:00 -07:00
Juan Tejada d75a5ee243 [client-app] Add better logging when restarting stuck sync worker
Summary: see title

Test Plan: manual

Reviewers: halla, mark, spang, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4358
2017-04-04 21:37:55 -07:00
Juan Tejada f8d84a76e2 [iso-core] Remove unused vars from IMAPConnectionPool
Summary: see title

Test Plan: manual

Reviewers: mark, halla, spang, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4357
2017-04-04 21:34:20 -07:00
Juan Tejada 2949ecffd5 [client-sync] 🎨 sync worker
Summary: Just renaming some stuff

Test Plan: manual

Reviewers: mark, spang, evan, halla

Reviewed By: spang, evan, halla

Differential Revision: https://phab.nylas.com/D4342
2017-04-04 17:53:13 -07:00
Halla Moore 5c8915f144 [client-app] Fix the unapply transformation for overlaid components
Summary:
The unapply transformation was incorrectly passing the props parameter
to buildAnchorTag() as a string, even though it expects an object.
buildAnchorTag() goes on to stringify this parameter, which causes extra
surrounding quotations and escape slashes in front of all the other
quotations. The unapply transform is applied on several re-renders,
which causes the number of escape characters to unboundedly increase.
Firstly, this was causing inline images to not appear properly in the
draft, and secondly, the large number of escape characters was making
the draft body large enough to make the app unresponsive.

This generally wasn't an issue because the unapply transformation is
only applied when there has been an apply transformation, and this is
triggered by the SyncbackDraftTask. This task was previously only queued
upon send, in which case the user never re-opens the draft. Now,
enabling send-later on a draft will queue the task, and these issues
appear if the user re-opens the draft for editing.

This diff makes it so that the unapply transform passes in the props as
an object, like the buildAnchorTag function expects.

Test Plan: manual

Reviewers: evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D4348
2017-04-04 16:43:05 -07:00
Halla Moore 2b39af5aba [client-app] Allow the packageMigrationManager to re-enable packages
Summary:
Remove packages from the disabled package list when they have been
migrated to be enabled by default.

Also, the last migration would not have worked properly anyways because
the daily channel was already on 1.0.56, and we check for greater-than
rather than equal-to. Bump that version to match the next update.

Test Plan: manual

Reviewers: juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D4335
2017-04-04 16:36:39 -07:00
Juan Tejada 7d99567855 [client-app] Make sure to fetch latest update url every time we check for updates
Summary:
Previously, is you signed out of your NylasID, you would not pick up new
updates because we never updated the autoupdater url to use the new id.

Test Plan: manual

Reviewers: mark, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4346
2017-04-04 16:30:52 -07:00
Juan Tejada d1b81b6afe [client-app] Prevent from making any requests when NylasID isn't present
Summary:
Sometimes, when logging out of your NylasID and restarting the app, we
would continue making some requests from the worker window that required a
NylasID. This would make the app enter a restart loop and become
completely unresponsive because when we made a request without a
NylasID, we would force the user to log out and restart the app, and
then we would again make the requests without the id, ad infinitum.

To fix this, we make sure we have a NylasID before making any requests
that require it

Test Plan: manual

Reviewers: halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4344
2017-04-04 16:26:32 -07:00
Juan Tejada a461490e41 [client-sync] Ensure we use refreshed access token for mail listener conn
Summary:
Before this commit, we would just establish a single mail listener imap
connection and never check if we needed to re-connect it due to an
expired access token. Even though we correctly refreshed the access
token at the beggining of each sync loop (hidden under
`ensureSMTPConnection`), we would never re-establish the mail listener
connection with the new access token.

This would cause the app to enter an `Invalid Credentials` error loop in
the sync loop, preventing from syncing any mail at all (T8064)

Test Plan: manual

Reviewers: spang, halla, mark, evan

Reviewed By: mark, evan

Differential Revision: https://phab.nylas.com/D4338
2017-04-04 13:27:43 -07:00
Juan Tejada 7dec807b28 [client-sync] Fix mail listener imap connection
Summary:
Given that we keep the imap mail listener conenction open outside of the
imap connection pool, it might close itself after a while or after
putting your computer to sleep.

Previously, if we had the connection object we just assumed it was
connected and proceeded with sync, and if it wasn't, we would fall into
an error loop in the sync worker preventing it from syncing at all (T8065)

To fix this, we just call `connect` every time to ensure the connection is open.
(This was the case before we introduced the connection pool)

Test Plan: manual

Reviewers: mark, spang, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4334
2017-04-04 13:27:04 -07:00
Mark Hahnenberg e06f729275 [client-app] Limit search to focused perspective
Summary:
Previously we would always search all mail. Now, if the user has focused
a particular folder we will limit our search to that folder. The inbox
is an exception--it will always search all mail unless the user
explicitly uses an "in:" clause.

Test Plan: Run locally, verify that searching folders returns the correct results.

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4328
2017-04-04 12:48:04 -07:00
Evan Morikawa f6bc2c4e5f bump(version): 2.0.0 2017-04-04 09:05:53 -07:00
Nylas Coffee Machine dfde1b9672 bump(version): 1.0.56 2017-04-04 09:03:34 -07:00
Halla Moore 7079b21b05 [client-sync] Don't assign duplicate roles in folder fetch
Summary:
Check that there aren't any other categories with a role before we try
to assign it to the current category.

Addresses T7835

Test Plan: manual

Reviewers: juan, evan, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4298
2017-04-03 17:04:25 -07:00
Evan Morikawa 2f082f8beb [client-app] re-setup IdentityStore in new window
Summary:
Before this patch, the IdentityStore would initialize in our empty hot
window. However, hot windows don't receive any `action-bridge-message`s,
which include DB updates. Since the hot window loads first, it was with a
stale verison of the Identity. The main window fetches a fresh identity,
but that fresh update failed to get to new composers because the hot
window wasn't listening to changes to the DB.

This makes it such that the IdentityStore properly boots up when the
window props change.

Test Plan: manual

Reviewers: halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4327
2017-04-03 16:44:01 -07:00
Evan Morikawa 368201f334 [client-app] add feature limits to reminders and send later
Summary:
This adds feature limit modals (graphics pending) for reminders and send
later

Test Plan: manual

Reviewers: juan, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4322
2017-04-03 15:38:47 -07:00
Evan Morikawa 11684c6f9e [client-app] enable snooze, send later, reminders on 1.0.56
Summary: This enables packages on 1.0.56

Test Plan: manual

Reviewers: juan, halla

Reviewed By: juan, halla

Differential Revision: https://phab.nylas.com/D4320
2017-04-03 15:38:31 -07:00
Juan Tejada 020fd79db1 [client-app] Update changelog 2017-03-31 17:41:22 -07:00
Juan Tejada be237d076e [client-app] Remove unecessary db setup for mail rules
Summary: This shaves off ~150ms trying to issue this query

Test Plan: manual

Reviewers: evan, spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4317
2017-03-31 17:38:22 -07:00
Nylas Coffee Machine 7e0194e6c3 bump(version): 1.0.55 2017-03-31 16:14:55 -07:00
Evan Morikawa 96685bed01 [client-app] don't override existing bodies on K2
Summary:
Bodies that already exist on K2 shouldn't be overridden.
See the comment for how this caused open/link tracking to fail in certain
cases when a lot of messages were being sent

Test Plan: manual

Reviewers: halla, mark, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4319
2017-03-31 16:13:52 -07:00
Halla Moore 1864a2d48a [client-sync] Add comment about reason for try/catch block 2017-03-31 15:34:52 -07:00
Mark Hahnenberg 70bb602246 [client-sync] Split Contact ranking query
Summary:
We were using a join for the contact ranking query and for whatever
reason on large databases this was extremely slow in SQLite. This diff
splits the query into first finding the sent Folder/Label and then
searching for non-draft Messages in that category.

Test Plan: Run locally, verify the query is faster

Reviewers: juan, evan, spang

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D4315
2017-03-31 15:29:20 -07:00
Juan Tejada c4763d4bd5 [client-app] Update changelog 2017-03-31 15:01:10 -07:00
Mark Hahnenberg f6a0ead259 [client-app] Remove getUnindexedAccounts
Summary: It was really slow, and we no longer need it.

Test Plan: Run locally, verify that we no longer do that super slow query

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4312
2017-03-31 14:49:31 -07:00
Evan Morikawa e6b399ea27 [client-app] remove the ANALYZE in favor of pragma.optimize
Summary:
Removes some VERY long running `ANLAYZE` queries. Was taking up to 50
seconds on my 9GB database on every boot
https://sqlite.org/pragma.html#pragma_optimize

Test Plan:
I tested to make sure the app still quits quickly. It does. The SQLite
docs also say this should be fast.

Reviewers: halla, spang, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4314
2017-03-31 14:45:14 -07:00
Nylas Coffee Machine 328ea428be bump(version): 1.0.54 2017-03-31 12:22:21 -07:00
Mark Hahnenberg 0205ac3f61 [client-sync] Simplify Contact ranking query
Summary:
We were using a couple of left outer joins to avoid checking whether we
should be joining on Labels or Folders. We can greatly simplify the query
by just checking which we should use and issuing the correct inner join.

Test Plan: Run locally, verify contact ranking still works.

Reviewers: spang, juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D4310
2017-03-31 12:19:58 -07:00
Evan Morikawa 4deef8b90c [client-app] delay building new hot window to improve win perf
Summary:
This improves window open times by about 70ms
We would spend a very long time in the backend browser process building a
new hot window when we didn't need to do that until much later

Test Plan: manual

Reviewers: halla, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4311
2017-03-31 12:17:34 -07:00
Juan Tejada 590b17ae6f [client-app] Don't imeout removing sync worker when removing an account
Summary:
Most of the times when removing a sync worker (i.e. when removing an
account), we would see database errors in the console. This happened
because more often than not we would interrupt in the middle of message
processing, but `processMessage` is not interruptible, which means that
the worker would be interrupted right after processing its current
message. However, if `processMessage` would take more than 500ms (the
current timeout for stopping the worker), we would destroy the database
before processing was done and it would throw a bunch of errors.

To fix this, we just don't set a timeout when removing the worker as a consequence
of removing an account. However, when we are removing the worker when we
detect that it is stuck, we set a time out of 5 seconds.

Test Plan: manually test removing accounts, verify that it doesn't error

Reviewers: mark, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4308
2017-03-31 12:09:20 -07:00
Juan Tejada 9181914453 [client-app] Ensure sync worker can never continue running after being destroyed
Summary:
Previously, it was possible for the sync worker to continue running after being
interrupted, e.g. it would break out of `performSync` and then try to run
`onSyncCompleted`. This is fine if we were just interrupting to restart the loop,
but when we stop it we don't want it to continue running anything at all.

This also refactors the syncworker to have a single `destroy` method, which sets
a `destroyed` flag and uses that one exclusively instead of the `stopped` flag.

Test Plan: manually check it works

Reviewers: spang, halla, mark, evan

Reviewed By: mark, evan

Differential Revision: https://phab.nylas.com/D4307
2017-03-31 12:08:48 -07:00
Juan Tejada 58cf02a824 [client-app] Don't hit contact rankings endpoint until account is ready
Summary:
This prevents us from hitting the endpoint before the database for that
account is initialized and it's actually syncing.

Before this commit, we would throw errors upon adding an account

Test Plan: manually add, remove accounts, run benchmark script

Reviewers: mark, halla, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4305
2017-03-31 11:21:56 -07:00
Halla Moore af6e6e669a [client-sync] Wrap more syncWorker args
Turns out the SyncWorker isn't the only one who initiates SyncTasks
2017-03-31 11:12:50 -07:00
Halla Moore ae2e2122e9 [client-sync] Properly wrap the SyncWorker arg in an object
The argument structure for runTask() changed and needs it this way.
2017-03-31 10:58:16 -07:00
Halla Moore c6a339df1a [client-sync] Fix the new syncback-task structure
Summary:
- Change files to .es6 so they recognize the syntax
- Pass arguments down to _run()
- Make sure the responses get returned

Test Plan: manual, even though that somehow failed before. :(

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4309
2017-03-31 10:52:42 -07:00
Nylas Coffee Machine 13ac2fa3b4 bump(version): 1.0.53 2017-03-31 09:07:20 -07:00
Evan Morikawa ae278fa5f2 [client-app] add DatabaseStore.write which doesn't use Transactions
Summary:
Creates a new `DatabaseStore.write` method alongside
`DatabaseStore.inTransaction` that doesn't always wrap trivial queries in
a transaction. SQLite does this automatically.

Test Plan: manual

Reviewers: spang, mark, halla, juan

Reviewed By: halla, juan

Differential Revision: https://phab.nylas.com/D4303
2017-03-30 17:38:32 -07:00
Evan Morikawa 559ecb1cda [client-app] rename DatabaseTransaction -> DatabaseWriter
Summary: Renamed in prep for next few diffs

Test Plan: manual

Reviewers: juan, mark, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4302
2017-03-30 17:38:07 -07:00
Evan Morikawa f9c0a93d1c [client-app] use debug library for DB
Summary:
Use the wonderful `debug` library instead of all our random flags.
You can now do things like: `DEBUG="app:*,sync:*" npm start` to print out
everything.

Test Plan: manual

Reviewers: mark, halla, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4297
2017-03-30 17:26:33 -07:00
Halla Moore f5f5b60140 [client-sync] Add provider to syncbackTask perf metric 2017-03-30 16:24:32 -07:00
Halla Moore a776e6dfb7 [client-sync] Report metrics about SyncbackTask runs
Summary:
Report how long they take and if they're stopped (due to timeout).

Part of T7978

Test Plan: manual

Reviewers: evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D4272
2017-03-30 16:15:09 -07:00
Mark Hahnenberg 5c08018382 [client-app] Add search support for "has:attachment"
Summary: See title

Test Plan: Run locally, verify that attachments are returned

Reviewers: spang, evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4293
2017-03-30 16:11:19 -07:00
Halla Moore 4c1af8f184 [client-sync] Convert syncback tasks to interruptible generators
Summary:
Make `run()` functions generators and change most awaits to yields

Part of T7978

Test Plan: specs from D4269, but really needs some heavy QA

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4270
2017-03-30 15:51:25 -07:00
Halla Moore c11a7ff830 [client-sync] Interrupt long-running syncback tasks
Summary:
Interrupt retryable syncback tasks that are taking too long so that we can
return control to the sync loop. The sync loop will retry the task later.
This diff adds a `forceReject` param to `interrupt()` so that we can return
control immediately instead of waiting for the current operation to finish
(for instance, the syncback task could be stuck in an imap operation, and a
normal interrupt would still have to wait for that to finish before returning
control to the callee)

Part of T7978

Test Plan: specs

Reviewers: evan, spang, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4269
2017-03-30 15:50:34 -07:00
Juan Tejada 2d1a3714d8 [client-app] Update changelog 2017-03-30 10:18:48 -07:00
Evan Morikawa b72e0829f2 [client-app] Add silent flag to DB persists for thread indexing
Summary:
Every persistModel would trigger a large number of downstream updates.
These weren't necessary for thread indexing and causing a lot of
unnecessary DB thrashing. This adds a `silent` flag to `persistModel` and
its ilk that just does the write.

significantly improve performance, and also contribute to T8046

Test Plan: manual

Reviewers: spang, mark, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4295
2017-03-30 09:36:07 -07:00
Evan Morikawa 2b67f139ea [client-app] Add better DB logging with ENABLE_SEQUELIZE_DEBUG_LOGGING
Summary:
This adds better logging to the DB

You can use `ENABLE_SEQUELIZE_DEBUG_LOGGING=true` and
`ENABLE_RXDB_DEBUG_LOGGING=true` to spit out the raw queries of both DBs.

Test Plan: manual

Reviewers: mark, halla, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4294
2017-03-30 09:32:52 -07:00
Nylas Coffee Machine 5196f0eee7 bump(version): 1.0.52 2017-03-29 23:50:58 -07:00
Mark Hahnenberg df1acb84b1 [client-app] Fix thread reindexing loop
Summary:
We would mark modified threads for reindexing, the thread search indexer
would reindex them, which would trigger a notification that the thread
had been modified, so we would mark the thread for reindexing, ...

Now we keep track in memory of which threads we've marked for reindexing
so we avoid re-marking them when the update notification arrives later.

Test Plan:
Run locally, verify same threads aren't getting continuously
reindexed and that the in-memory set doesn't grow unboundedly

Reviewers: spang, juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D4289
2017-03-29 17:00:40 -07:00
Juan Tejada c7e4c2bb87 [client-app] Fix references to RetryableError imports
Summary: See title

Test Plan: manual

Reviewers: spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4292
2017-03-29 15:51:09 -07:00
Juan Tejada caac7cd247 [client-app] Log duration of db ANALYZE query
Summary: See title

Test Plan: manual

Reviewers: mark, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4290
2017-03-29 15:01:31 -07:00
Juan Tejada ec51e982eb [client-app] Improve logging for queries
Summary:
This commit makes a few changes to how we log database queries:

- We log queries in 2 different places now:
  - When `DatabaseStore._executeLocally` takes longer than 100ms. This might be due to the actual db operation taking long, or it might be due to our retry logic, or potentially other factors.
  - When the actual raw database operation takes more than 100ms.
- When raw database queries take more than 100ms, we log out the query plan if it is a `SELECT` query and we are in dev mode.
- If `DEBUG_TO_LOG` is true, we always log all queries (including background queries)

Test Plan: manual

Reviewers: mark, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4288
2017-03-29 15:01:07 -07:00
Juan Tejada d26a3e7448 [client-app] Improve logging for background database queries
Summary:
- Rename `databaseAgent` usage to `background`, in the code and in the logs, which I
believe is less confusing. Often times found myself asking what was this agent thing in
the logs.
- Make messaging more explicit

Test Plan: manual

Reviewers: evan, mark, halla

Reviewed By: mark, halla

Differential Revision: https://phab.nylas.com/D4285
2017-03-29 15:00:44 -07:00
Juan Tejada 8e03ca65ef [client-app] Reduce max retry delay for db queries
Summary:
This commit makes it so that when we retry database queries after
encountering a db locked error, we back off for at most 500ms, instead
of the current max of 3s. This meant that a single query could
potentially take 3+ seconds and block the transaction queue for that long.

Test Plan: manual

Reviewers: evan, mark, halla

Reviewed By: mark, halla

Differential Revision: https://phab.nylas.com/D4283
2017-03-29 15:00:12 -07:00
Juan Tejada 745dac7582 [client-app] Don't delay db queries unless we are retrying
Summary:
After introducing retry logic, we would always defer db queries to the
next tick even if there was no retry delay present.

This would cause almost all db queries take more than 100ms even if the
actual db operation was really fast. This affected app performance
negatively

Test Plan: manual

Reviewers: evan, halla, mark

Reviewed By: halla, mark

Differential Revision: https://phab.nylas.com/D4282
2017-03-29 14:59:34 -07:00
Evan Morikawa 9d15ff7ff7 [client-app] ensure gmail msg to 1 person get tracking stripped
Summary:
The problem actually was that we weren't applying the transform for Gmail
messages sent to 1 recipient

Test Plan: manual

Reviewers: halla, juan

Reviewed By: halla, juan

Differential Revision: https://phab.nylas.com/D4291
2017-03-29 14:53:57 -07:00
Evan Morikawa d8e22aa936 [client-app] don't trigger your own opens & link clicks
Summary:
We weren't stripping link and open items from messages we sent properly.
While we stripped it from the first outgoing message, when the sync loop
came back around it would have them back in. This adds it in the message
processor to extra ensure that ANYTHING that comes from us (or one of our
aliases) gets the open/link tracking stripped

Test Plan: New tests

Reviewers: juan, halla

Reviewed By: juan, halla

Differential Revision: https://phab.nylas.com/D4287
2017-03-29 14:53:40 -07:00
Mark Hahnenberg 78b9cf81c5 [client-sync] Fix "in:" for IMAP search
Summary:
Prior to this diff, the "in:" search query syntax didn't work for IMAP.
This diff implements "in:" by changing the IMAP search backend to take
folder context into account and emit the appropriate queries for each
folder. Queries that include "in:foo" will replace the corresponding AST
nodes with 'ALL' or 'NOT ALL' depending on whether or not the current folder
is "foo". We also now filter which folders we search based on which
folders are referenced in the query.

Test Plan: Run locally, verify that in: works quickly

Reviewers: evan, juan, spang

Reviewed By: juan, spang

Differential Revision: https://phab.nylas.com/D4284
2017-03-29 13:48:46 -07:00
Mark Hahnenberg 69aa71e575 [client-app] Reindex threads when they're updated
This commit is the same as 7d409f5.

This commit was accidentally reverted in 95ec679, because I (juan) was being
dumb. So I'm re-committing here.

Summary:
We weren't doing that, so we would have accurate search index info for
threads when they were, e.g., moved to another folder.

Test Plan: Run locally

Reviewers: spang, evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D4260
2017-03-29 11:55:28 -07:00
Christine Spang c2a0df174f [dev] Default billing server URL to staging for development, allow override
Summary:
By default, the 'local'/'development' environment assumes that all services
are running locally. This makes sense.

However, if you're not making changes to auxiliary services such as
billing.nylas.com and hence do not have them running locally, firing up
Nylas Mail with the 'local' env will not work. It's a bit of a pain to
get a local billing service running locally, especially if you're not
making any changes to that service. To ease development, change the
default billing URL during development to staging, and allow manually
overriding the billing server URL to point to localhost in the case
that you're making changes to the billing service also.

To override the billing URL for local development, run like this:

    npm run cloud -- --env billing_local
    BILLING_URL=http://billing.lvh.me:5555 npm start

This is both a problem that I've run into during development as well as
(my hunch) why Karim accidentally landed a global override of the
billing server URL.

Test Plan: manual

Reviewers: evan, khamidou, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4202
2017-03-29 11:12:47 -07:00
Juan Tejada 7e123d4894 [client-app] Update changelog 2017-03-29 10:52:37 -07:00
Nylas Coffee Machine 8e7e8ef833 bump(version): 1.0.51 2017-03-28 23:07:37 -07:00
Juan Tejada ca50e6cf52 [client-sync] Make sure to attach route files ending in .es6 to local-api
Summary:
This prevented the /health endpoint from being available in the
local-api

Test Plan: manual

Reviewers: mark, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4280
2017-03-28 17:50:59 -07:00
Evan Morikawa 9a7ce16616 [client-app] add SHOW_HOT_WINDOW env for prod debugging of window launches 2017-03-28 16:31:27 -07:00
Evan Morikawa 212dd4439a [client-app] properly relaunch windows on autoupdate 2017-03-28 16:15:02 -07:00
Juan Tejada 6202a4618e [client-sync] Fix runtime error introduced in 08975c0
Summary:
If `gmailInitialUIDsRemaining` was defined, we need to set `initialUids`
to that value. We were previously setting it to a key in
`folder.syncState` that didn't exist, which caused a runtime error.

This was introduced in d6a2b6935c

Test Plan: manual

Reviewers: spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4279
2017-03-28 16:00:06 -07:00
Christine Spang a57e4bdd20 [cloud-api] Verify SMTP credentials in /auth endpoint
Summary:
This patch will prevent users from being able to connect accounts which sync
mail but fail to send.

This commit includes a couple pieces:
* Adds a call to nodemailer's `verify()` function in the /auth endpoint
* Adds Error object conversion for SMTP errors. Since we don't implement our
  own connection object or connection pool for SMTP, we simply wrap the couple
  places we call functions from nodemailer that connect to SMTP, namely
  SendmailClient's _send() and the new verify() call in /auth.
* Moves RetryableError to the 'errors' module since it's now a base class for
  retryable IMAP //and// SMTP errors.
* Moves the main `smtpConfig()` logic which used to live on the Account model
  into AuthHelpers so it can be shared between the Account model and the verify
  code.
* Converts a few different places to use `import` syntax instead of
  `require` syntax for module imports. Apologies for not splitting this out
  into a separate diff—would have been a fair amount of work and looks not too
  difficult to skim over in the context of the rest of the patch.
* Fixing a bug in a previous commit where erroring sends would crash because of
  using `this._transporter.options` instead of `this._transporter.transporter.options`

Test Plan: manual

Reviewers: evan, halla, juan

Reviewed By: halla, juan

Differential Revision: https://phab.nylas.com/D4200
2017-03-28 15:47:44 -07:00
Juan Tejada 76234eaa9b [client-app] Correctly listen for new mail in between sync loops
Summary:
When using the IMAPConnectionPool in the sync-worker, we requested 2
connections from the pool: 1 to listen for new mail, and 1 to actually
operate on the mailbox. These 2 connections would be closed and returned
to the pool at the end of each sync loop iteration.

However, we never want to close the connection to listen for new mail.
Closing this connection caused us to not listen for new mail in between
sync loops, which was especially noticeable when initial sync was done
because the delay between sync loops is 5 minutes.

This commit makes it so we request the 2 connections separately from the
connection pool, and keep the listener connection always open until we
dispose of the sync-worker.

Test Plan:
manually make sure that I got new mail event listeners in between
sync loops :(

Reviewers: evan, spang, halla, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4276
2017-03-28 14:09:41 -07:00
Juan Tejada cfb5c20fc1 [client-sync] 🎨 typo 2017-03-28 14:01:02 -07:00
Mark Hahnenberg d6a2b6935c [client-sync] Also prioritize sent label for initial Gmail sync
Summary:
Sent mail is important for initial sync because it's used for contact
ranking. Prior to this diff we would delay syncing sent mail because we
would prioritize the inbox label over all other labels (including sent).
This diff includes the sent folder in the initial set of messages to sync.

Test Plan: Run locally, verify we get sent mail quickly

Reviewers: evan, spang, juan

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D4268
2017-03-28 11:25:21 -07:00
Mark Hahnenberg da018c3639 [client-app] Report battery state changes to Mixpanel
Summary:
This diff will give us insight into how people use Nylas Mail on their
computers with respect to how mobile they are (i.e. whether they use NM
on battery or plugged in).

Test Plan: Run locally

Reviewers: evan, spang, juan

Reviewed By: juan

Subscribers: gleb

Differential Revision: https://phab.nylas.com/D4267
2017-03-28 10:53:31 -07:00
Mark Hahnenberg 0508180712 [client-sync] Don't throttle while syncing first 500 threads
Summary:
We want to get to a usable inbox as quickly as possible, and throttling
prevents this. We should basically only be throttling for historical
mail syncing.

Test Plan: Run initial sync benchmark, it's 117% faster on battery

Reviewers: evan, juan, spang

Reviewed By: juan, spang

Differential Revision: https://phab.nylas.com/D4266
2017-03-28 10:52:34 -07:00
Mark Hahnenberg 60e6113f87 [client-sync] Implement the /contacts/rankings endpoint
Summary:
Prior to Nylas Mail, the Nylas Cloud API provided an endpoint that
returned rankings for contacts which it computed based on how frequently
and how recently a user sent mail to a recipient. This diff reimplements
that functionality in Nylas Mail. This should improve contact
auto-complete when composing emails to frequently contacted recipients.

Test Plan: Run locally, verify that frequent contacts are suggested earlier

Reviewers: spang, evan, juan

Reviewed By: evan, juan

Maniphest Tasks: T7948

Differential Revision: https://phab.nylas.com/D4253
2017-03-28 10:51:24 -07:00
Evan Morikawa da74dc2c18 [client-app] change file description on Windows 2017-03-28 09:56:29 -07:00
Juan Tejada 254b8dfb90 [client-app] Update changelog 2017-03-28 09:23:00 -07:00
Nylas Coffee Machine cc61b32710 bump(version): 1.0.50 2017-03-28 09:18:03 -07:00
Juan Tejada ff9d49e752 [client-app] Fix runtime error in FetchMessagesInFolderTask
We were accessing `this._db.accountId` before `this._db` was set, which
caused an error when attempting to run the task
2017-03-28 09:15:03 -07:00
Juan Tejada 1a1db50a84 [client-app] Update changelog 2017-03-28 09:10:15 -07:00
Juan Tejada caf5380659 [client-app] Fix importing SyncActivity
In some places we were not accessing `.default` when using `require`,
and when using `import` we couldn't really destructure unless we
accessed `.default` too, or if the functions were regular exports
instead of properties on a default exported object.

This was causing our sync loop to error.

To remain consistent, we always just `require` or `import` the
SyncActivity singleton and access that
2017-03-28 09:09:39 -07:00
Nylas Coffee Machine 60549fe8db bump(version): 1.0.49 2017-03-27 22:40:10 -07:00
Halla Moore adff6896e6 [client-sync] Change where we report sync activity
Summary:
These locations will provide enough activity for monitoring and are also
more helpful in helping us debug what the sync loop was doing when it
got stuck.

Test Plan: manual

Reviewers: juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4274
2017-03-27 21:49:56 -07:00
Evan Morikawa 83cab70d68 [client-app] add better documentation to windows update 2017-03-27 18:19:50 -07:00
Evan Morikawa ddee8b83f7 [client-app] directly call windows relaunch on squirrel update 2017-03-27 18:06:11 -07:00
Evan Morikawa fc5645b9eb [client-app] remap windows dev shortcuts 2017-03-27 17:13:42 -07:00
Halla Moore 4ad4596e2f [client-app, client-sync] Add specs for detecting stuck sync/worker window
Summary: See title. Part of T7681.

Test Plan: ran the specs

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4264
2017-03-27 15:45:33 -07:00
Halla Moore 73f0f3eeda [client-app] Detect when the worker window is unavailable
Summary:
Periodically ping client-sync's /health endpoint and store the latest
sync activity. If we get an ECONNREFUSED error, the worker window is
unavailable. Report the last known activity and restart the worker
window. Part of T7681.

Test Plan: manual, specs

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4263
2017-03-27 15:42:18 -07:00
Halla Moore 619c69a522 [client-sync] Detect when sync workers are stuck
Summary:
Periodically check the latest sync activity times to determine if a sync
worker has been inactive for too long. If it has been too long, discard
the worker and create a new one for that account. Part of T7681.

Test Plan: manual, specs

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4262
2017-03-27 15:41:31 -07:00
Halla Moore b6887e386e [client-sync] Report latest sync activity
Summary:
Add infrastructure to report and retrieve the latest sync activity, and
start reporting when we download a message or detect that a folder
has no new messages. This will be used to detect if the sync loop is
stuck. Part of T7681.

Test Plan: manual, specs

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4261
2017-03-27 15:39:53 -07:00
Halla Moore 7355527397 [client-app] Retry queries when database is locked
Summary:
We still don't know exactly what scenarios cause us to get 'database is
locked' errors, but generically this means that we have multiple
processes trying to access the database at the same time. In an attempt
to handle this gracefully, this diff makes it so that we retry the
queries in these cases. Theoretically, the database should free up once
the other process is done using it, and the erroring process just needs
to wait its turn. We still throw an error after 5 retries, so if there's
a larger issue, we'll still be able to tell in Sentry.

Addresses T7992

Test Plan:
I opened a transaction in the worker window and then tried to
do the same in the main window. If I didn't release the transaction in
the worker window, the main window eventually errored. If I did release
the transaction, the main window continued creating its own transaction.

Reviewers: mark, juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D4254
2017-03-27 15:22:28 -07:00
Juan Tejada 88dd9523ba [cloud-api] Timeout streaming API connections every 15 minutes
Summary: Should help a fair bit with our redis connection pileup.

Test Plan: Tested manually.

Reviewers: mark, spang, juan, evan

Reviewed By: mark, spang, evan

Differential Revision: https://phab.nylas.com/D3916
2017-03-27 12:13:34 -07:00
Christine Spang 951c874e2b [iso-core] Add indexes from SQL review
Summary:
These only really matter for n1cloud, and are being added manually in
production, so no migration file necessary. I am adding them to the
model definitions to prevent them getting out of sync with production
for development.

See T7999 for full SQL review

Test Plan: ship it

Reviewers: evan, khamidou, juan

Reviewed By: juan

Subscribers: vlad, jerm

Differential Revision: https://phab.nylas.com/D4230
2017-03-27 11:11:18 -07:00
Juan Tejada 9216ef1ca7 [client-app] Update changelog 2017-03-27 08:37:34 -07:00
Nylas Coffee Machine 8a3e47df4e bump(version): 1.0.48 2017-03-27 00:04:26 -07:00
Mark Hahnenberg 11aa686809 [client-app] Reindex threads when they're updated
Summary:
We weren't doing that, so we would have accurate search index info for
threads when they were, e.g., moved to another folder.

Test Plan: Run locally

Reviewers: spang, evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D4260
2017-03-24 15:14:58 -07:00
Juan Tejada ae1c667e37 [client-app] Fix in identity store 2017-03-24 14:04:44 -07:00
Juan Tejada 41ad424752 [client-app] Don't try to restart sync on every IdentityStore change
Summary:
The IdentityStore can trigger any number of times, but we only want to
start sync if we previously didn't have an identity available

Test Plan: manual

Reviewers: spang, evan, halla

Reviewed By: evan, halla

Differential Revision: https://phab.nylas.com/D4246
2017-03-24 13:06:47 -07:00
Juan Tejada 43738771ac [client-app] Correctly remove inline images with x button
Summary:
Before this commit, it was impossible to remove inline images via the x
button

Test Plan: manual

Reviewers: mark, halla

Reviewed By: mark, halla

Differential Revision: https://phab.nylas.com/D4257
2017-03-24 13:03:28 -07:00
Juan Tejada cd6d04c4a6 [ei] Update changelog 2017-03-24 10:21:03 -07:00
Nylas Coffee Machine c5af73f358 bump(version): 1.0.47 2017-03-23 22:55:20 -07:00
Karim Hamidou a8aee89ae0 [client-app] Report hard crashes using Electron's built-in crash reporter
Summary:
I had a bit of downtime this morning so I decided to look into how to store Electron crash data. Electron, like Chromium, stores crash data in an arcane file format named minidump.

There's a bunch of services you can use to store files formatted in this format, like Mozilla's Socorro or zcbenz's own mini-breakpad-server but they're all pretty hard to install. Luckily, it turns out there's a Ruby gem to process minidump files and send them to Sentry! Seeing that, I whipped up a quick sinatra service and hosted it on Heroku – you can take a look at the source code here if you're curious: https://github.com/khamidou/electron-breakpad-sentry

This diff adds the client-side code we need to start sending crash reports.

Test Plan: Tested manually.

Reviewers: juan, evan

Reviewed By: juan, evan

Maniphest Tasks: T7926

Differential Revision: https://phab.nylas.com/D4259
2017-03-23 15:18:27 -07:00
Juan Tejada 09b88a759c [client-app] Consolidate file download metric reporting
Summary: See title

Test Plan: manual

Reviewers: gleb, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4256
2017-03-23 13:26:28 -07:00
Juan Tejada 1298d4c529 [client-app] Update changelog 2017-03-23 12:23:34 -07:00
Mark Hahnenberg 4ef8e7614e [client-sync] Don't handle IMAP timeouts in the connection pool
Summary:
Different clients can have different policies for retrying after
timeouts.

Test Plan: Run locally, run tests

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4247
2017-03-23 11:33:53 -07:00
Mark Hahnenberg e13d4832ff [client-app] Record file download times
Summary:
We'd like to get an idea of how long the client app is having to wait
when requesting a file. Waiting can cause things like inline image
attachments to appear very slow to load.

Test Plan: Run locally

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4255
2017-03-23 11:32:19 -07:00
Nylas Coffee Machine ce17f70f26 bump(version): 1.0.46 2017-03-22 22:28:54 -07:00
Halla Moore 9caefdc687 [client-app] Rename downloadDataForFile(s) -> getDownloadDataForFile(s)
Summary:
The original name seems like it's initiating the download, when really
it's just returning the data of an already in-progress/completed
download.

Test Plan: Manual, specs

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4251
2017-03-22 17:17:08 -07:00
Halla Moore 470e6563ec [client-app] Ensure files get transferred in forwarded messages
Summary:
We need to download the files and then treat them as uploads. Rather
than using an actual Upload object, which would require another data
transfer, we create an object with all the necessary Upload-like
properties and point it to the downloaded file.

Addresses part of T7960

Test Plan: Manual, some specs

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4249
2017-03-22 12:05:35 -07:00
Karim Hamidou 3e3b0b84f1 Switch type of Metadata value column
Summary:
Found a funny send-later bug I didn't catch when testing on staging: sometimes the data we're saving in the metadata table overflows. That's because MySQL's TEXT column are at most 64k, which is easy to reach when you have a draft + clearbit information and additional stuff.

To work around this, I decided to switch the database type of the metadata table to LONGTEXT. Since it can store 4Gb of text, we should be good. This diff makes those code changes. Obviously, we'll have to run migrations both on staging and prod.

Test Plan: Ran a basic smoke test. Shouldn't break anything.

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4250
2017-03-22 12:03:11 -07:00
Halla Moore b849793a72 [client-app] Fix DraftFactory specs
Summary: Using `await` instead of `advanceClock()` fixes all the things!

Test Plan: Ran the spec file

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4248
2017-03-21 15:46:48 -07:00