Commit graph

2132 commits

Author SHA1 Message Date
Scott Nonnenberg
2786baf2b5 Additional logging when we can't decrypt a user's profile (#1483)
Found a number of 'Illegal buffer' errors in an Electron log submitted
today. As far as I can tell, these same profiles are succeedig for me,
so it's time to collect more data.

FREEBIE
2017-09-18 15:33:08 -07:00
Lilia
4449a5f110 Upgrade emoji support (#1482)
* Upgrade emoji deps and move to node_modules

Add support for Emoji 3.0 and switch from bower to yarn for managing emoji
dependencies.

// FREEBIE

* Delete old emoji deps

// FREEBIE

* Don't copy emoji on windows

It is no longer necessary since the symlinked image dir is gone.

// FREEBIE

* Update emoji test

// FREEBIE

* Fix emoji tests; remove all overrides of emoji-js functions

FREEBIE
2017-09-15 13:22:11 -07:00
Scott Nonnenberg
48f625c392
Move app theming from index to app view (#1479)
Apply theming one level higher so it applies to the debug log.

// FREEBIE
2017-09-14 17:48:15 -07:00
Lilia
f698d0bc51
Better install view error handling (#1472)
If linking fails because an http request didn't connect, show a message and
allow the user to start over.

// FREEBIE
2017-09-14 17:04:03 -07:00
Lilia
fc952fbaf6
Handle provisioning messages with no profile key (#1470)
This can happen while linking to an older mobile client.

// FREEBIE
2017-09-14 17:04:03 -07:00
Lilia
c832324cb9
Trigger empty event on keepalive timeout (#1466) 2017-09-14 17:04:03 -07:00
Scott Nonnenberg
420cfc46be
Additional logging to help track down socket disconnect problems (#1469)
FREEBIE
2017-09-14 17:04:03 -07:00
Lilia
ae190fed44
Profiles (#1453)
* Add AES-GCM encryption for profiles

With tests.

* Add profileKey to DataMessage protobuf

// FREEBIE

* Decrypt and save profile names

// FREEBIE

* Save incoming profile keys

* Move pad/unpad to crypto module

// FREEBIE

* Support fetching avatars from the cdn

// FREEBIE

* Translate failed authentication errors

When AES-GCM authentication fails, webcrypto returns a very generic error. The
same error is thrown for invalid length inputs, but our earlier checks in
decryptProfile should rule out those failure modes and leave us safe to assume
that we either had bad ciphertext or the wrong key.

// FREEBIE

* Handle profile avatars (wip) and log decrypt errors

// FREEBIE

* Display profile avatars

Synced contact avatars will still override profile avatars.

* Display profile names in convo list

Only if we don't have a synced contact name.

// FREEBIE

* Make cdn url an environment config

Use different ones for staging and production

// FREEBIE

* Display profile name in conversation header

* Display profile name in group messages

* Update conversation header if profile avatar changes

// FREEBIE

* Style profile names small with ~

* Save profileKeys from contact sync messages

// FREEBIE

* Save profile keys from provisioning messages

For standalone accounts, generate a random profile key.

// FREEBIE

* Special case for one-time sync of our profile key

Android will use a contact sync message to sync a profile key from Android
clients who have just upgraded and generated their profile key. Normally we
should receive this data in a provisioning message.

// FREEBIE

* Infer profile sharing from synced data messages

* Populate profile keys on outgoing messages

Requires that `profileSharing` be set on the conversation.

// FREEBIE

* Support for the profile key update flag

When receiving a message with this flag, don't init a message record, just
process the profile key and move on.

// FREEBIE

* Display profile names in group member list

* Refresh contact's profile on profile key changes

// FREEBIE

* Catch errors on profile save

// FREEBIE

* Save our own synced contact info

Don't return early if we get a contact sync for our own number

// FREEBIE
2017-09-14 17:04:00 -07:00
Scott Nonnenberg
02571b7ae9
Copy audio-related files into js/ instead of symlinking them (#1456)
This adds a new copy:deps task into the overall default task, and it
needs to be run before running the product for the first time, and after
upgrading audio-related deps.

FREEBIE
2017-09-14 17:03:18 -07:00
Scott Nonnenberg
db869c6ce4
Scroll to bottom when adding a new message (#1450)
Added a comment to try to make this easier to understand as you read it.

FREEBIE
2017-09-14 17:03:18 -07:00
Lilia
1b444a5e23
Make os notifications respect our sound setting (#1445)
This removes our custom notification sound in favor of the system sound, and
ensures that the system sound is disabled if the user unchecks the audio
notification option.

// FREEBIE
2017-09-14 17:03:18 -07:00
Michael Kirk
f389380b26
scroll only when needed (#1441)
I believe this was just a simple typo

// FREEBIE
2017-09-14 17:03:18 -07:00
Scott Nonnenberg
af81b1a045
Fix unlinked loading screen hang, fix error dialog on start (#1440)
* main.js: check for truthiness of mainwindow, not === null

FREEBIE

* background.js: Connect to websocket even if we are unlinked

We know registration isn't done, but it has been done before. So instead
of sitting tight, we connect to the socket to start everything up and
attempt to the websocket once more.

FREEBIE
2017-09-14 17:03:18 -07:00
Lilia
50c470e53d
Certificate pinning via node XMLHttpRequest implementation (#1394)
* Add certificate pinning on https service requests

Make https requests to the server using node apis instead of browser apis, so we
can specify our own CA list, which contains only our own CA.

This protects us from MITM by a rogue CA.

As a bonus, this let's us drop the use of non-standard ports and just use good
ol' default 443 all the time, at least for http requests.

// FREEBIE

* Make certificateAuthorities an option on requests

Modify node-based xhr implementation based on driverdan/node-XMLHttpRequest,
adding support for setting certificate authorities on each request.

This allows us to pin our master CA for requests to the server and cdn but not
to the s3 attachment server, for instance. Also fix an exception when sending
binary data in a request: it is submitted as an array buffer, and must be
converted to a node Buffer since we are now using a node based request api.

// FREEBIE

* Import node-based xhr implementation

Add a copy of https://github.com/driverdan/node-XMLHttpRequest@86ff70e, and
expose it to the renderer in the preload script.

In later commits this module will be extended to support custom certificate
authorities.

// FREEBIE

* Support "arraybuffer" responseType on requests

When fetching attachments, we want the result as binary data rather than a utf8
string. This lets our node-based XMLHttpRequest honor the responseType property
if it is set on the xhr.

Note that naively using the raw `.buffer` from a node Buffer won't work, since
it is a reuseable backing buffer that is often much larger than the actual
content defined by the Buffer's offset and length.

Instead, we'll prepare a return buffer based on the response's content length
header, and incrementally write chunks of data into it as they arrive.

// FREEBIE

* Switch to self-signed server endpoint

* Log more error info on failed requests

With the node-based xhr, relevant error info are stored in statusText and
responseText when a request fails.

// FREEBIE

* Add node-based websocket w/ support for custom CA

// FREEBIE

* Support handling array buffers instead of blobs

Our node-based websocket calls onmessage with an arraybuffer instead of a blob.
For robustness (on the off chance we switch or update the socket implementation
agian) I've kept the machinery for converting blobs to array buffers.

// FREEBIE

* Destroy all wacky server ports

// FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
7a2c8e815c
Import: Wait until db writes resolve before saying we're done (#1401)
FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
5099ca0ccd
Merge locale-provided strings into english for failover support
FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
e8c7e31363
Multi-error, multi-language, and cross-platform spell-check
FREEBIE
2017-09-14 17:03:17 -07:00
lilia
ff1bad674e
Fix exception in install view
These lines throw TypeErrors for previously registered clients.

// FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
ac237b9e31
AppView: Store initialLoadComplete value for late openInbox
FREEBIE
2017-09-14 17:03:17 -07:00
Scott Nonnenberg
90cc0949b6
InstallView: Refactor step numbers into enum
FREEBIE
2017-09-14 17:03:16 -07:00
Scott Nonnenberg
7f8ade7747
Remove migration-related functionality, leaving export stuff
FREEBIE
2017-09-14 17:03:14 -07:00
Scott Nonnenberg
413fba80af
Separate dir selection from import, better import button text
This allows us to show the 'import in progress' screen only when the
user has successfully selected a directory.

FREEBIE
2017-09-14 17:02:46 -07:00
Scott Nonnenberg
0fbe43c2dc
Protobufs: More logging on failure to load protobufs, fix tests
FREEBIE
2017-09-14 17:02:45 -07:00
Scott Nonnenberg
ff1cb3598d
Remove step 1 of previous setup flow, replaced by choice screen
FREEBIE
2017-09-14 17:02:45 -07:00
Scott Nonnenberg
ba347744ff
Import: choice on first startup, workflow, ported to Node.js fs API
FREEBIE
2017-09-14 17:02:43 -07:00
Scott Nonnenberg
9c8fe1a9d8
Reschedule all timers on time travel, set interval back to 1000ms
FREEBIE
2017-09-14 16:53:53 -07:00
Scott Nonnenberg
bc437095f6
Calm time travel checks, don't continually reschedule key rotation
FREEBIE
2017-09-14 16:53:53 -07:00
Scott Nonnenberg
f37af04818
AppView.createInbox() - set this.inboxView immediately to be ready
If the 'empty' event is fired between the updateInbox() call and the
new InboxView() call afterwards, then the loading screen will never go
away. We fix that by immediately creating the InboxView but only adding
it to the DOM when the backing data is ready.

FREEBIE
2017-09-14 16:53:53 -07:00
Scott Nonnenberg
eaf31705cc
A number of fixes for loading screen, recent rebase
FREEBIE
2017-09-14 16:53:52 -07:00
lilia
854374dc7c
Remove the old debug log menu item 2017-09-14 16:53:52 -07:00
lilia
11633d7d87
Make debug log available from the installer
Move debug log from inbox view to app view so it can be opened regardless of
whether we are showing the inbox view or the installer.

// FREEBIE
2017-09-14 16:53:52 -07:00
lilia
04e40043d2
Add View -> Debug Log to menu bar
Just send an event from the main process to the renderer,
The latter routes it the appropriate view method.

For now it's a no-op unless the main window exists and it is showing the inbox,
which will be addressed in a future commit.

// FREEBIE
2017-09-14 16:53:52 -07:00
Scott Nonnenberg
bd3b8ae9f8
Note how many debug logs we have after we load them from DB
FREEBIE
2017-09-14 16:53:52 -07:00
Scott Nonnenberg
87a1fcc406
Fix trimming of debug log: remove first, use proper iteration var
FREEBIE
2017-09-14 16:53:52 -07:00
Scott Nonnenberg
e4ceb21002
Use two interations instead of while loop for trimming log
FREEBIE
2017-09-14 16:53:51 -07:00
lilia
02df917f3a
Fix $name$ in confirmation dialogs
Our i18n shim supports multiple substitutions if you give it an array of strings
to use as replacements.

// FREEBIE
2017-09-14 16:53:51 -07:00
Scott Nonnenberg
8f0b0b121a
Add missing comma in ConversationView event list
FREEBIE
2017-09-14 16:53:49 -07:00
Scott Nonnenberg
3a3aa3efb6
Remove test/protos symlink, use window.PROTO_ROOT for config 2017-09-14 16:53:48 -07:00
Scott Nonnenberg
4402a91976
Use correct locale, fall back to en if we don't have translations
FREEBIE
2017-09-14 16:53:47 -07:00
lilia
a2b2bd4bf3
Fix relative paths
// FREEBIE
2017-09-14 16:53:46 -07:00
lilia
26cece71c6
Prepopulate phone number on standalone page 2017-09-14 16:53:46 -07:00
lilia
4c5835e0af
Remove remaining call to extension.notification.update 2017-09-14 16:53:45 -07:00
lilia
7c6da5a157
Make 'Restart Signal' actually restart Signal
Previously it would just reload the page.

// FREEBIE
2017-09-14 16:53:45 -07:00
lilia
d85ccbad4f
Remove extension.notification 2017-09-14 16:53:45 -07:00
lilia
bd7f4febaa
Remove dead code
These are all unused, obsolete, or no-op functions at this point.

// FREEBIE
2017-09-14 16:53:45 -07:00
lilia
c4ccf7c8e3
Inline setUnreadCount
// FREEBIE
2017-09-14 16:53:44 -07:00
lilia
29b07950a3
Fix scroll reset after clicking on a notification 2017-09-14 16:53:43 -07:00
lilia
2528acc717
Remove platform-specific links from install flow
Mostly to satisfy the mac app store.

// FREEBIE
2017-09-14 16:53:43 -07:00
lilia
e65007e297
Tweak default notification content
Change the placeholder content for when notifications are configured for
count-only or sender-only. Remove some options that are no longer
supported.

// FREEBIE
2017-09-14 16:53:43 -07:00
lilia
79872be9f5
Unfurl notifications
Since we no longer have support for list-style notifications, stop
coalescing notifications into batches and just show contents of the last
message received. Also open the window when clicking on a notification
if it has previously been closed.

// FREEBIE
2017-09-14 16:53:43 -07:00
lilia
4d981c439a
Remove number validation from install view
Allows our special cased test numbers to link desktop clients.

// FREEBIE
2017-09-14 16:53:42 -07:00
lilia
76cd650577
Restore missing contactsync listeners
Fix installer getting stuck on "Generating Keys"

// FREEBIE
2017-09-14 16:53:42 -07:00
lilia
d2179b2c3f
Conversation view handles drag n drop events
By forwarding them to its file input.

// FREEBIE
2017-09-14 16:53:41 -07:00
Scott Nonnenberg
601081c1b8
More refactoring to reduce global event dependencies
All Whisper.events listeners are now defined and bound in background.js,
and we no longer need global methods for opening the inbox and
conversation views, as those are handled by AppView or internally by
InboxView.

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
8d32a3bebd
Remove dead code
This view doesn't contain any elements with class openInbox.

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
4b96722d52
Hide initially empty error in standalone view
// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
008e978b8a
Make standalone registration more accessible
Add buttons for switching between the linking flow and the standalone
registration flow. The button and standalone registration are only
availble in a development environment.

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
a2e0fa59c1
Collect references to Whisper.events
Fixup

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
f7c7e2251d
Remove unused method
This is now handled in AppView

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
0c9cca08ba
Draw attention to the window on new messages
// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
ea930d53ae
Set badge count
This is displayed on the launcher icon on linux/mac

// FREEBIE
2017-09-14 16:53:41 -07:00
lilia
d025b57656
Remove unused method 2017-09-14 16:53:41 -07:00
lilia
6b70aecf29
Fix opening a conversation from notification 2017-09-14 16:53:40 -07:00
lilia
b6e5439860
Fix saving attachments
// FREEBIE
2017-09-14 16:53:39 -07:00
lilia
878b15c288
Add node version to debug log
The chrome, electron, and signal versions are already included in the
user agent string.

// FREEBIE
2017-09-14 16:53:39 -07:00
lilia
112f5a00ca
Delete unused files
// FREEBIE
2017-09-14 16:53:39 -07:00
lilia
de3816b094
Get standalone registration working in development
Whisper.events.trigger('openStandalone') to open the standalone
registration view.

// FREEBIE
2017-09-14 16:53:39 -07:00
lilia
3a9f4f0df3
Flatten database migrations
We can compress or toss out most of these one-off data migrations since
everyone starts from scratch with electron.

// FREEBIE
2017-09-14 16:53:39 -07:00
lilia
a55c61a3ba
Use local var environment rather than NODE_ENV
Traditionally, NODE_ENV refers to an environment variable. For clarity,
let's keep it that way and don't reuse it in the renderer. Also, add a
note about explicitly overriding env vars for node-config.

// FREEBIE
2017-09-14 16:53:38 -07:00
lilia
e7e030a5e2
Build expiration date
Add the buildExpiration config and add it to the renderer's config
object. Use grunt to write the build expiration to
config/local-production.json which will override the default value (no
expiration) in production. Finally, run this grunt task as part of the
build process.

// FREEBIE
2017-09-14 16:53:38 -07:00
lilia
c83dbc1bf0
Rename window.env to window.config
Also normalize to camelCase for configs.

// FREEBIE
2017-09-14 16:53:38 -07:00
lilia
6574958087
Remove check for open windows
We now live in a single-window world.

// FREEBIE
2017-09-14 16:53:38 -07:00
lilia
e4e41140c4
Refactor app view
Introduce a top level view for navigating between the inbox and the
installer, enabling an in-window relink flow. Navigation is driven
through the openInbox and openInstaller global events.

// FREEBIE
2017-09-14 16:53:37 -07:00
lilia
3f5505907f
Fix setUnreadCount 2017-09-14 16:53:37 -07:00
lilia
75dbc27cfa
Fix i18n of timer options
It is important to return something falsey in the case where there is
no translation.

// FREEBIE
2017-09-14 16:53:37 -07:00
lilia
72c3dc286c
Remove onLaunched handler
This is now handled outside the renderer.

// FREEBIE
2017-09-14 16:53:37 -07:00
lilia
83a020cc5e
Move focus listeners to their own file
// FREEBIE
2017-09-14 16:53:37 -07:00
lilia
7e1bee1082
Configure app/build using node config
Add environment-specific configs under `./config` and integrate with the
build system. Also changes package.json `files` from blacklist to
whitelist.

// FREEBIE
2017-09-14 16:53:36 -07:00
lilia
34042415e9
Database logging cancels persistent debug log storage
Database logging is helpful as a debugging tool, but it creates an
infinite loop with the debug log, which wants to write to the database,
which wants to write to the log, which wants to write to the database,
which wants to write to the log, which wants to write to the database,
which wants to write to the log, which wants to write to the database...

// FREEBIE
2017-09-14 16:53:36 -07:00
lilia
a381d9c975
Fix focus detection 2017-09-14 16:53:36 -07:00
lilia
5650748961
Fix pre-populated device name 2017-09-14 16:53:36 -07:00
lilia
25b0fbd949
Fix exceptions on window close
The stopListening function was being passed the close event as an
argument, which caused it to throw.

// FREEBIE
2017-09-14 16:53:36 -07:00
lilia
49cdc98386
Fix lightbox 2017-09-14 16:53:35 -07:00
lilia
acd19fd759
Fix inbox styles 2017-09-14 16:53:35 -07:00
lilia
86d703bc87
Fix debug log 2017-09-14 16:53:35 -07:00
lilia
63657db3be
Quick fix for i18n
Just use the english locale for now. Load locale data from the
filesystem in the main process and pass it to the renderer preload
script via ipc. Note that we need the locale data to be available by the
time view scripts are loaded.

// FREEBIE
2017-09-14 16:53:35 -07:00
lilia
88893079d2
Fix restart 2017-09-14 16:53:35 -07:00
lilia
2bbd0d58c6
Separate development and production environments
Set NODE_ENV at run time or build time to switch the app between dev and
production modes.

At build time, the current NODE_ENV will be included in the packaged
app's package.json file. At runtime we read NODE_ENV from package.json,
but also allow the local environment variable to override. A query
string parsed by a preload script exposes the value to the renderer,
which then determines whether we use the staging or production server.
Additionally, different environments have different user data
directories.

// FREEBIE
2017-09-14 16:53:35 -07:00
lilia
285b5ce062
Get install flow working in main window
// FREEBIE
2017-09-14 16:53:35 -07:00
lilia
6686621b0b
Fix file dialog 2017-09-14 16:53:34 -07:00
lilia
5a6e65d11b
Merge index.html into background.html
Nothing stops us from rendering the inbox in the background page, since
it is no longer a background page at all. TODO: intercept window close
events to hide this window instead of closing it unless the app is quit
explicitly.

// FREEBIE
2017-09-14 16:53:34 -07:00
lilia
859d49b3f4
Use relative paths
// FREEBIE
2017-09-14 16:53:34 -07:00
lilia
95e809636a
Quick fix for undefined references to chrome.* 2017-09-14 16:53:34 -07:00
Scott Nonnenberg
ff6dc786f9 Force full contact/group import on next launch if not first run (#1476)
* Force full contact/group import on next launch (if not first run)

FREEBIE

* Don't update contact sync key in storage on every reconnect

FREEBIE
2017-09-14 12:08:10 -07:00
Scott Nonnenberg
00e1a6a36a Export: Improve usability - timing expectations, install button (#1474)
Because export might take a couple minutes, we now set expectations
that it might take 'several minutes' instead of just 'please wait.'

We also promote 'Install new Signal Desktop' from a text link in the
instructions to a button. This is important on the 'Completed' screen
because it is bigger and to the left of the 'Export Again' button, which
previously drew primary focus on that screen.

Lastly, we also remove the title-specific element of the support link,
so we're resilient to title changes in the future.

FREEBIE
2017-09-13 13:33:40 -07:00
Scott Nonnenberg
1e694fe8d7 Log entry max to 2k, remove logging in hot codepaths (#1459)
On a recent trip through a CPU profile taken while Signal Desktop
churned through a large backlog of messages, it was clear that
console.log was a major source of time spent, primarily the sort
operation required after every new entry is added to the Backbone
collection. So, three different techniques to combat this:

1) Reduce the maximum number of entries in the collection from 5k to 2k
2) No more logging of add/update/remove queue in MessageReceiver
3) No more log entries in Message.handleDataMessage main codepath

FREEBIE
2017-09-12 09:34:49 -07:00
Scott Nonnenberg
69af8d2651 Don't show notification for verified state change with yourself (#1454)
* Don't show notifications for verified state change with yourself

It's confusing to users, and it really doesn't mean anything anyway.

FREEBIE

* Add log statement that we've suppressed a verified notification

FREEBIE
2017-09-08 11:14:01 -07:00
Scott Nonnenberg
e3bada1f4a
MessageView.updateColor: Call getAvatar on convo, not message
FREEBIE
2017-09-07 10:38:00 -07:00
Scott Nonnenberg
cc6dcf67b7 Export: Limit attachment filename length, + convo date, + tests (#1439)
* Export: limit attachment names to 30 chars, tests for helper fns

Also, reintroduce last contact date in conversation dir name

FREEBIE

* MessageView tests: Fix failures during blanket coverage run

FREEBIE
2017-09-06 18:20:42 -07:00
Scott Nonnenberg
4009a0119e MessageView: Handle change of color to null, call getColor() (#1438)
When we relied on the actual value of the color property to be supplied
to the updateColor change event listener, sometimes it would be null.
Then the conversation bubbles would have no color at all, making the
text hard to read.

FREEBIE
2017-09-06 18:19:11 -07:00
Scott Nonnenberg
4cba16cb61 Fetch all conversations on startup of app, not on inbox load (#1437)
* Fetch all conversations on startup of app, not on inbox load

A recent change to fetch conversations less didn't take into account all
that can happen in the app without the inbox loaded. That only happens
when the window is shown, and messages can come in with the app in the
background. In that case, the conversation wouldn't have been loaded
from the database, but would be saved to the database anyway, losing
data.

This change fetches all conversations as soon as the the data store is
ready for a fetch. It also introduces failsafe throws to ensure that
synchronous ConversationController accesses don't happen until the
initial fetch is complete. A new getUnsafe() method was required to
account for some of the model setup that happens during that initial
conversation fetch.

Fixes #1428

FREEBIE

* Fix tests: ConversationController.load() required before get()

FREEBIE
2017-09-06 18:18:46 -07:00
Scott Nonnenberg
d8ce198f55 Fetch conversations once, clean up ConversationController API (#1420)
* Fetch conversations once, clean up ConversationController API

Race conditions around re-fetching have caused some problems recently,
so this removes the need to re-fetch conversations. They are fetched
once or saved once, and that is it. All interaction goes through the
ConversationController, which is the central source of truth.

We have two rules for Conversations:

1. If a conversation is in the ConversationController it doesn't need
   to be fetched, but its initial fetch/save might be in progress. You
   can wait for that fetch/save with conversation.initialPromise.
2. If a conversation is not already in the ConversationController, it's
   not yet in the database. It needs to be added to the
   ConversationController and saved to the database.

FREEBIE

* Remove Conversation.fetch() call in Message.handleDataMessage()

FREEBIE

* ConversationController.API cleanup: Fix two missing spots

FREEBIE
2017-09-01 09:10:41 -07:00
Lilia
51cd28bb4a Fix race handling contact sync with verified info (#1419)
When processing a contact sync with embedded identity key verification info, we
were running overlapping async fetch/save operations on the same conversation
model, causing a race that tends to clobber updates to the contact info.

In this change we extend the application-level contact info handler to block on
a subsequent call to the verification handler, which effectively serializes the
fetch/save calls, and relieves the need for the message receiver to trigger a
seperate event concerning the verification info on contact sync messages.

Fixes #1408

// FREEBIE
2017-09-01 07:42:41 -07:00
Scott Nonnenberg
07abe2639f Export: Properly generate directory names for nameless groups (#1421)
FREEBIE
2017-09-01 07:33:30 -07:00
Scott Nonnenberg
94b63c39fd
Export: Remove " as one of the allowed characters in filenames
Turns out that it's not allowed on windows.

FREEBIE
2017-08-31 23:25:49 -07:00
Scott Nonnenberg
36e8b82b5f Remove unknown group messages from cache - no need to retry! (#1414)
FREEBIE
2017-08-30 14:40:08 -07:00
Scott Nonnenberg
46b64e306f createTaskWithTimeout: Don't log expiration if task threw (#1412)
FREEBIE
2017-08-30 13:33:55 -07:00
Scott Nonnenberg
3f7fbd93d5 Export: Better disambiguate conversation directory names (#1409)
FREEBIE
2017-08-30 13:23:07 -07:00
Scott Nonnenberg
4011e26b50 Fix handling of sync message with blocked numbers (#1411)
FREEBIE
2017-08-30 11:55:17 -07:00
Scott Nonnenberg
b14667ae40 Additional error handling/logging during contact sync (#1395)
FREEBIE
2017-08-30 09:35:04 -07:00
Scott Nonnenberg
548586b934 Chrome export fixes: too-long names, redact group ids (#1402)
* On export, don't print out entire group id, just last three chars

FREEBIE

* Export: Limit conversation dirs to 30 characters of original name

FREEBIE

* Redact groups ids on import as well

FREEBIE

* InboxView: Protect against nonexistent loading screen

FREEBIE
2017-08-30 09:30:21 -07:00
Scott Nonnenberg
3d8aa3b8a2
Export: Handle synchronous 'shutdown-complete' event (already offline)
FREEBIE
2017-08-28 14:01:51 -07:00
Scott Nonnenberg
d31d1712b1
Bullet-proofing export scenarios: null attachments, no msgreceiver
FREEBIE
2017-08-28 13:20:53 -07:00
Scott Nonnenberg
c0cd733139 Full export, migration banner, and full migration workflow - behind flag (#1342)
* Add support for backup and restore

This first pass works for all stores except messages, pending some scaling
improvements.

// FREEBIE

* Import of messages and attachments

Properly sanitize filenames. Logging information that will help with
debugging but won't threaten privacy (no contact or group names),
where the on-disk directories have this information to make things
human-readable

FREEBIE

* First fully operational single-action export and import!

FREEBIE

* Add migration export flow

A banner alert leads to a blocking ui for the migration. We close the socket and
wait for incoming messages to drain before starting the export.

FREEBIE

* A number of updates for the export flow

1. We don't immediately pop the directory selection dialog box, instead
  showing an explicit 'choose directory' button after explaining what is
  about to happen
2. We show a 'submit debug log' button on most steps of the process
3. We handle export errors and encourage the user to double-check their
  filesystem then submit their log
4. We are resilient to restarts during the process
5. We handle the user cancelling out of the directory selection dialog
  differently from other errors.
6. The export process is now serialized: non-messages, then messages.
7. After successful export, show where the data is on disk

FREEBUE

* Put migration behind a flag

FREEBIE

* Shut down websocket before proceeding with export

FREEBIE

* Add MigrationView to test/index.html to fix test

FREEBIE

* Remove 'Submit Debug Log' button when the export process is complete

FREEBIE

* Create a 'Signal Export' directory below user-chosen dir

This cleans things up a bit so we don't litter the user's target
directory with lots of stuff.

FREEBIE

* Clarify MessageReceiver.drain() method comments

FREEBIE

* A couple updates for clarity - event names, else handling

Also the removal of wait(), which wasn't used anywhere.

FREEBIE

* A number of wording updates for the export flow

FREEBIE

* Export complete: put dir on its own line, make text selectable

FREEBIE
2017-08-28 13:06:10 -07:00
Scott Nonnenberg
76a69f7511
Move clear/drawAttention logging up a level to reduce verbosity
FREEBIE
2017-08-28 12:59:08 -07:00
Scott Nonnenberg
bbb12979b3
Fix a few errant jshint problems
FREEBIE
2017-08-25 14:28:05 -07:00
Scott Nonnenberg
9fb079253c Remove errors from the cache when they are shown to the user (#1392)
There's really no reason to retry encryption errors again if they've
already been made user-visible in a conversation.

Also, refactor e->error in background.js onError(), since both e and ev
in this method made it too easy to make a mistake.
2017-08-25 14:24:16 -07:00
Scott Nonnenberg
84fd605ad3 MessageReceiver cache: Don't convert to string for save
Because IndexedDB supports ArrayBuffer natively.

FREEBIE
2017-08-25 13:53:47 -07:00
beernutz
07ec2707ac Update to work around flashing icon issue (#1384)
Repeatedly clearAttention to prevent flashing icon
2017-08-24 16:22:01 -07:00
Scott Nonnenberg
f14ac69f2a Additional logging when we get delivery receipt for unknown msg
FREEBIE
2017-08-23 13:39:29 -07:00
Scott Nonnenberg
4ef36cc95c Add logging to help track down problems with Sync
Seems like we're running into errors sending the message to kick off the
sync, so positive logging as well as error logging is included.

FREEBIE
2017-08-17 17:33:22 -07:00
Scott Nonnenberg
675d41843e Re-enable message box if enter pressed with no text/files
Previously the message would stay disabled until the user clicked with
the mouse.

FREEBIE
2017-08-17 08:54:38 -07:00
Scott Nonnenberg
680f7d8b57 Additional logging for perf analysis and cross-device debuging
- How long it takes to get a message through the pre-send checks
- How long it takes to open a conversation for the first time
- The timestamp of any message we send to corellate with other logs
- Add conversation ID to 'decrypt old identity key errors' start/end

FREEBIE
2017-08-17 08:54:38 -07:00
Scott Nonnenberg
241e26dc17 Don't revoke convo avatar URL on unload - we will need it again
FREEBIE
2017-08-15 14:08:14 -07:00
Scott Nonnenberg
9c7db537d0
libtextsecure.js catch-up
FREEBIE
2017-08-14 12:20:13 -07:00
Scott Nonnenberg
7e9ed1481b Set receivedAt after decrypt, sort by received then sent
FREEBIE
2017-08-14 12:12:36 -07:00
Scott Nonnenberg
620b71a649 Maintain original received time when processing queued/error msgs
FREEBIE
2017-08-12 13:17:53 -07:00
Scott Nonnenberg
8700112f6d Decrypt any IncomingIdentityKeyError still sticking around
FREEBIE
2017-08-12 13:17:53 -07:00
Scott Nonnenberg
67cb9bdf54 Disable message box between send request and final send begin
Because we do a number of async checks before allowing the real send to
begin, on a slow matchine or when doing a lot of work (like receiving a
lot of messages) there can be a noticeable delay between hitting Enter
and the clearing of the text in the message box. In fact, newly-typed
text can be added to the previous message if the delay is long enough.

This prevents any interaction with the message box until the send has
either been prevented or has started.

FREEBIE
2017-08-11 18:55:16 -07:00
Scott Nonnenberg
e7450fa0d7 Add a max setTimout for expiring messages (over max == immediate)
Discovered a user log where expiring message checks were happening
constantly. This ensures that a very large timeout doesn't roll over
into immediate callbacks.

FREEBIE
2017-08-10 12:04:13 -07:00
Scott Nonnenberg
e57f155403 Handle rejections from protocol layer (due to missing records)
isVerified and isUntrusted both went to the protocol layer, but were not
prepared for rejected promises resulting from missing records. This
prevented send in large groups where there has never been a message
exchanged with one of the members.

FREEBIE
2017-08-10 11:21:15 -07:00
Scott Nonnenberg
cf5f50cfab Give initIncomingMessage envelope in background.js error handling
FREEBIE
2017-08-08 14:08:29 -07:00
Scott Nonnenberg
b33c5c4c07 MessageReceiver: Wait for all code paths in handleSyncMessage
Without this, the recent changes to wait for read receipts and delivery
receipts don't have much of an effect.

FREEBIE
2017-08-08 11:22:41 -07:00
Scott Nonnenberg
96b00b3e2d Throttle expiring messages data query and deletion
I believe this to be the reason behind some of the high resource usage
on startup. If a lot of read receipts come in for disappearing messages,
this method can be called many, many times very quickly.

FREEBIE
2017-08-08 11:22:41 -07:00
Scott Nonnenberg
6caf88c404 Key verification error popup: Remove cancel, empty resolve()
FREEBIE
2017-08-07 16:14:49 -07:00
Scott Nonnenberg
2130795708 Fix 'retry message' scenario: they are now content messages
FREEBIE
2017-08-07 16:14:49 -07:00
Scott Nonnenberg
e0c1f0d27a MessageReceiver: Process cached before dismissing loading screen
FREEBIE
2017-08-07 16:14:49 -07:00
Scott Nonnenberg
fa00f08c95 MessageReceiver: Fix envelope id logging and make it consistent
FREEBIE
2017-08-07 16:14:49 -07:00
Scott Nonnenberg
82b2a611e3 MessageView: Always remove errors on re-render to prevent doubles
FREEBIE
2017-08-07 16:14:49 -07:00
Scott Nonnenberg
78c02f1154 Restore 'cancel' button on delete message confirmation dialog
FREEBIE
2017-08-07 16:14:49 -07:00
Scott Nonnenberg
559619eb49
Fix sync'd disappearing messages; prevent double-save
FREEBIE
2017-08-04 18:19:26 -07:00
Scott Nonnenberg
7e8f3ab5e7
Fix for "Can't find record for undefined.1"
Also, we didn't need to recalculate the number here anyway!

FREEBIE
2017-08-04 15:23:54 -07:00
Scott Nonnenberg
e223db56d9 Set messageKeysLimit to unlimited if communicating with our devices (#1348)
Set messageKeysLimit to unlimited if communicating with our devices

FREEBIE
2017-08-04 12:25:30 -07:00
Scott Nonnenberg
7e0bd82bd3 handleDataMessage: Remove if(confirm) checks, add try/catch
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
832b343031 Expiring messages: Add clarifying comment about destroy() ordering
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
7d4ae63501 MessageReceiver: Log empty event, flow promise properly
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
32e12f7d3c Conversation.notify(): introduce a promise to track completion
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
d3fb0e5b46 Expiring messages: destroy only after we've notified conversation
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
7faf83bc01 Read/Delivery Receipts: Wait for resolution in main queue
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
92ba295d52 Better logging for sync sent messages, and new (disappeared) msgs
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
ad8cb870d9 libtextsecure.js catch-up
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
ec70170829 ConversationView.unload: Add ability to provide reason for logging
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
c0f8812f9b ConversationView: when windows are closed, call unload()
Anyway, unload() is a more comprehensive method for doing what the close
handler was trying to do before.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
6f1a2a9b3e Conversation.markRead() - wait for all database saves are complete
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
b4f6721846 Fix manfest.css, libtextsecure.js catch-up
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
65283d2794 Unload conversations and old messages every half-hour
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
4ea457a01c Fix second fetchConversation call if unread > 0
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
8c231d9830 MessageReceiver: Flow promises back properly in decrypt error case
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
31d7e652fe Dismiss the app loading screen if we failed to connect to socket
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
af2ce56c8d Reset MessageReciever queue whenever possible
(like we do with the conversation queue already)

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
305bd6b3b8 App loading screen: show messages processed so far
Also, show the same loading screen on index.js before we've bootstrapped
the app.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
e36aa524c9 background.js: Flow promises properly in error case
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
39795170c1 Handle the 'extension loaded, reopen window' scenario
Not sure exactly how to think about Chrome app lifetimes, so we're
being conservative. We only show the full-application loading screen
once, on first display of the inbox.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
53f2bfbb57 Animated loading screens on startup and first conversation load
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
3e8b34f3d0 findOrCreateById instead of private-specific method
Anyway, findOrCreateById with no type didn't succeed, because the
conversation didn't validate.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
ef3431af1b isUntrusted: Return false if firstUse is true
Because users will see this upon first trying to communicate with a new
contact if they're quick about it.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
f38d715250 Read receipts: Log sender and timestamp when related msg not found
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
c6bc167975 Increase log length to 5000, since we're logging so much now
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
82c0b4aaa6 Add return to onContractReceived for consistency
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
9dc406dc8d Apply reliable trigger to Backbone.Collection as well
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
3e0fa995dd When finding all groups involving a number, load from DB not memory
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
0adc398a6f Fetch conversation before saving in all sync handlers
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
9db0a58260 Whenever adding something to a queue, include a timeout
No more wedged queues!

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
cc2c3edaa6 Override Backbone's trigger with one that catches exceptions
Model operations are vulnerable to exceptions thrown by event handlers.
Because this can interrupt really important data operations, it's better
to let the operation continue and log the error. In all likelihood it's
a view-related problem, and that shouldn't cause any data operation to
fail.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
700272cf85 Add a pure copy from backbone into reliable_trigger.js for diff
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
b985228160 Last seen indicator/scroll down button - defensive removal
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
4f90cefd4f More bullet-proofing - reject surrounding promise if save() fails
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
1eb450ca35 Conversation: Start w/DEFAULT verified state, avoid null timestamp
Fix too-aggressive verification notifications on startup by starting a
conversation with the right initial verified state, and then making sure
to fetch() before setting a new verified state.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
bd0050b6c6 Cache messages on receipt, remove from cache when processed
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
e6859a3684 Ensure that promises always resolve, or that rejections are okay 2017-08-04 12:03:25 -07:00
Scott Nonnenberg
4da1722ee8 Bullet-proof _setVerified and handleDataMessage against rejections
And the weird behavior we get from $.Deferred.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
5da324103a Throttle calls to getProfile when opening conversation
We don't want to throttle other calls to getProfile, so we localize this
to the fetch we do when we first open a conversation.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
aa80cdd74d ConfirmationDialogView: Make showCancel an explicit option
Also, don't call resolve/reject callbacks if they weren't provided.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
14765599f3 Delete individual message
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
80a2a01e37 Remove jitter on verifying/unverifying safety number
On every click, even when sub-panes were open, we were calling
markRead(), which would save the conversation model with the new
unreadCount. The KeyVerificationPanelView was wired up to the change
event on conversation, so it would render with the results of that
update, then finally the user's intended update.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
12b2674bde Show size of files even if size not precomputed for attachment
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
9ba5aaa54d Verification sync logging: include whether it was from contact sync
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
4124d5cb9b Show 'Message not sent' only if 'Some recipients failed' not showing
Also switch up the visual style for 'Some recipients failed' text to
match the more-visible 'Message not sent' text and the 'Resend' link.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
25243ad9de Send warning: Show single problematic group member, not group name
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
697079cf9b Add else handlers with logging in toggleVerified catch handler
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
8112cd220a Show warning when we discover key change on verify
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
91f50c028f Unify processVerifiedMessage with Java implementation
This removes our support for the New Key/DEFAULT case, which iOS will
sync to us. Why? Because it ensures that in out of date scenarios, we
don't lose the higher-security state we were in previously.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
5bba6d3f17 setTrusted() -> setApproved() to dismiss the five-second warning
This change makes sense, since there was already a reference in the code
to the then-nonexistent setApproved()!

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
23a806a6b1 removeAllSessions: properly reject in failure cases
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
7ab20f09cc Fix focus issues with identity key send view
Tabbing right after entering the view would cause everythign to go crazy
as focus went back to the pane you were just on. This change both sets
the proper focus on load of that view (on the cancel button) and hides
other panes when they aren't active, only making them visible again when
they are once again the 'top' pane.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
ff4fde651c Make it clear in conversation just some recipients failed
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
12914307f1 Improve experience when discovering identity key error on send
New experience in the Message Detail view when outgoing identity key
errors happen, matching the Android View.

'View' button is only shown on outgoing key errors right now.

When a contact with an outgoing identity key error is clicked, they are
taken to a view like the popup that comes up on Android: an explanation
of what happened and three options: 'Show Safety Number', 'Send Anyway',
and 'Cancel'

Contacts are now sorted alphabetically, with the set of contacts with
errors coming before the rest.

FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
b6cca41a0c Update verification-related strings to better match mobile app
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
f654532fa8 Handle UNVERIFIED sync verification messages (via contact sync)
FREEBIE
2017-08-04 12:03:25 -07:00
Scott Nonnenberg
20451cc827 Show verified/keychange notifications when actually relevant
FREEBIE
2017-08-04 12:03:25 -07:00