Commit graph

1036 commits

Author SHA1 Message Date
lilia
a32780d174 Mark delivered messages as sent
In rare cases, a race between delivery receipts and outgoing message
requests can cause the sent flag to be reversed. Fix by marking messages
sent at the same time they are marked delivered.

// FREEBIE
2015-10-20 18:57:24 -07:00
Deirdre Connolly
861bc416e6 Update attachment size limits to match mobile clients
Per WhisperSystems/TextSecure@8a1428e, bump GIF limit to 5MB, and
audio/video limit to 100MB. Update toast to notify in correct
human-readable units. The only kB size limit is for images, and will
trigger only if after scaling up to 4 times, the rescaled image did not
come in under the size limit without unacceptable quality loss.

Closes #354
2015-10-20 12:29:52 -07:00
lilia
389b9a026d Initial restyle
Added background gradient and restyled conversation elements as floating
panels and cards.

// FREEBIE
2015-10-16 18:14:50 -07:00
lilia
ee393bfa03 Ensure that tokens get updated on initial save
// FREEBIE
2015-10-16 13:01:14 -07:00
lilia
2f8d973366 Restore native window chrome
// FREEBIE
2015-10-16 12:52:10 -07:00
lilia
82ce76265d Remove stray log statement
// FREEBIE
2015-10-16 12:32:06 -07:00
lilia
f70c22f898 Add search field to inbox
Using the search field produces a filtered view of all contacts and
groups containing the input. To make this fast and scalable, add an
index on a 'tokens' array containing words from the conversation name
and different forms of phone number.

Closes #365

// FREEBIE
2015-10-15 13:33:07 -07:00
lilia
81ebc5ffd7 Improve stack traces on HTTPErrors
Save stack even earlier, outside the promise.

// FREEBIE
2015-10-11 12:12:11 -07:00
lilia
c062fe3060 Automatically retry failed http requests
If we failed to reach the server, wait a second and try again up to 3
times.

// FREEBIE
2015-10-10 19:07:00 -07:00
lilia
a93b8cea72 Collapse multiple retry buttons
If you're going to retry one, you might as well retry everyone.

// FREEBIE
2015-10-10 16:59:52 -07:00
lilia
816a206892 Refactor sendMessageToDevices
Split into separate encrypt and transmit functions. Let the encryption
function also handle all wire formatting (ie, jsonification and base64
encoding), which simplifes TextSecureServer.sendMessages, removes a
TODO, and lets us save fewer params to make network errors replayable.

// FREEBIE
2015-10-10 16:36:30 -07:00
lilia
e9bc39bc56 Add parens and line breaks
// FREEBIE
2015-10-10 15:12:06 -07:00
lilia
b1c933ccd4 Don't show myself in the message detail contacts list
// FREEBIE
2015-10-08 06:13:36 -07:00
lilia
87d4f0d5d8 Fix non-disappearing resend button
The resend button should disappear once you've clicked it. This was not
happening because the message detail view held a cached copy of the old
message errors. Fix by re-reading the errors when we re-render.

// FREEBIE
2015-10-05 15:07:55 -07:00
lilia
0ff38e41c2 Let keepalive listen to socket events
Wait until the socket connects before starting the keepalive timer.
Automatically stop the keepalive when the socket is closed.

// FREEBIE
2015-10-05 15:05:24 -07:00
lilia
1345899253 Use reject instead of throw
This ensures that the containing promise is rejected without triggering
the side effects of an uncaught exception, such as causing the debugger
to pause.

// FREEBIE
2015-10-03 23:19:53 -07:00
lilia
a32f3ff1f6 More work on replayable errors
Expose a button that does that retries outgoing messages if possible.

// FREEBIE
2015-10-02 18:31:07 -07:00
lilia
5bf608598c Fix MessageSender prototype
// FREEBIE
2015-10-02 15:02:25 -07:00
lilia
b0da491025 Don't throw on unknown groups
// FREEBIE
2015-10-02 12:54:12 -07:00
lilia
b42626923c Don't double-render key conflict errors
// FREEBIE
2015-10-02 12:35:28 -07:00
lilia
7ec4700431 Handle saving errors when none exist already
// FREEBIE
2015-10-02 12:35:28 -07:00
lilia
4cc7a30107 Remove error class when no more message errors
// FREEBIE
2015-10-02 12:15:25 -07:00
lilia
ae25d62ef2 Fix up post-conflict resolution error processing
// FREEBIE
2015-10-02 12:14:34 -07:00
lilia
d3812869d2 Don't throw errors from background
// FREEBIE
2015-10-02 12:14:10 -07:00
lilia
bbb5b24d6b Fix disappearing conversation bug
Opening two message-detail views in two separate conversations would
disappear one of the conversations. Fixed by better encapsulating the
sub-views of a conversation.

// FREEBIE
2015-10-02 11:21:11 -07:00
lilia
8f003ea69d Don't throw if sender is not a group member
This could happen if we simply failed to process an earlier group
update correctly.

// FREEBIE
2015-10-02 10:43:34 -07:00
lilia
4a1d0ebdb9 Pass bytebuffer to axolotlInstance
// FREEBIE
2015-10-02 00:03:49 -07:00
lilia
46c9a7fafb Fix tryMessageAgain
// FREEBIE
2015-10-02 00:02:18 -07:00
lilia
08b864b57c Fix standalone registration
// FREEBIE
2015-10-01 22:04:07 -07:00
lilia
9872b59355 Simplify filter predicate
Untangle a double negative to make this line shorter and easier to read.

// FREEBIE
2015-10-01 21:11:41 -07:00
lilia
0fa1069a93 Don't throw on duplicate members in a group update
Fixes #364

// FREEBIE
2015-10-01 21:11:41 -07:00
lilia
1aee065c2c Fix registration
Previously would fail to register keys by using the wrong username.
The username should be <number>.<deviceid> once we've confirmed our
account and received a deviceId from the server.

// FREEBIE
2015-10-01 20:43:30 -07:00
lilia
978b3d1a98 DRY up tryMessageAgain
// FREEBIE
2015-10-01 18:43:20 -07:00
lilia
fbb65d1988 Add replayable network errors
Support for manual message retry.

// FREEBIE
2015-10-01 18:43:20 -07:00
lilia
bc03bdbfc4 Move tryMessageAgain to MessageReceiver
`tryMessageAgain` is the routine called when re-trying a message that
failed to decrypt due to an IncomingIdentityKeyError. This handling
needs to move to MessageReceiver because it depends on
`processDecrypted` to handle incoming message protos, which depends
on a server instance in order to download attachments.

// FREEBIE
2015-10-01 18:43:19 -07:00
lilia
0fc673f25f Refactor sendmessage for prototypality
// FREEBIE
2015-10-01 18:43:18 -07:00
lilia
868695558d Throw on bad server url
// FREEBIE
2015-10-01 18:43:18 -07:00
lilia
c8a1e090d2 Move handleAttachment and processDecrypted
Make these internal methods on MessageReceiver. Todo: refactor
identity key errors to use a given message receiver.

// FREEBIE
2015-10-01 18:43:07 -07:00
lilia
a8f4bac2f7 Let makeAttachmentPointer resolve falsey arguments
Internalizing this pattern to the makeAttachmentPointer function lets us
DRY it up throughout the file.

// FREEBIE
2015-10-01 18:33:50 -07:00
lilia
e626355e0c Let background page instantiate AccountManagers
Remove the need to expose the server url config as a global.

// FREEBIE
2015-10-01 18:33:49 -07:00
lilia
edd76ec65a AccountManager takes a url 2015-10-01 18:33:49 -07:00
lilia
9de23a967b Fix dropping the first websocket message 2015-10-01 18:33:49 -07:00
lilia
3fcd980c23 Add websocket error and close event handlers 2015-10-01 18:33:49 -07:00
lilia
78956ede2f Disable keepalive if we disconnect the socket 2015-10-01 18:33:48 -07:00
lilia
9e9d767a30 Add MessageSender
textsecure.MessageSender takes server url and credentials and returns
a message sending interface configured for that server.

Used a wrapper function to insert a TextSecureServer instance into
sendmessage.js code at runtime. This will result in function duplication
between different MessageSender objects, pending further refactoring to
use prototypal inheritence.

// FREEBIE
2015-10-01 18:33:48 -07:00
lilia
98aa5156b0 Refactor TextSecureServer for storage
Following the pattern from previous commit, let the server class accept
a url and login credentials from the caller. Then integrate into
MessageReceiver and AccountManager.

// FREEBIE
2015-10-01 18:33:48 -07:00
lilia
09bd6c7824 Lint
// FREEBIE
2015-10-01 18:33:33 -07:00
lilia
19423bf909 Abstract message error handling
// FREEBIE
2015-10-01 18:21:20 -07:00
lilia
e1c9e28b4c Add comment
// FREEBIE
2015-10-01 10:55:04 -07:00
lilia
569d0655fa Fix test failure
// FREEBIE
2015-09-30 19:32:25 -07:00
lilia
1c306df61f Workaround for #363 Multiple open sessions bug
This doesn't solve the problem in the general case, but should at least
unbreak registration.

// FREEBIE
2015-09-30 18:47:42 -07:00
lilia
876e11c19b Fix sync messages not getting displayed on arrival
// FREEBIE
2015-09-30 17:52:13 -07:00
lilia
7d6adc4879 Save outgoing error codes when messages fail
// FREEBIE
2015-09-30 17:13:59 -07:00
lilia
a802322d44 Display a default message for incoming message errors
An exception to the previous commit, for incoming messages we should not
show a mysterious empty bubble. Instead there is some generic
non-technical error message.

// FREEBIE
2015-09-30 15:24:34 -07:00
lilia
929c16090b Move error messages to message detail view
Change how message errors are rendered. Errors associated with a number
will be shown under that number in the detail view rather than piling up
in the message bubble.

// FREEBIE
2015-09-30 14:27:18 -07:00
lilia
9a63703340 Close the socket/keepalive when going offline
// FREEBIE
2015-09-30 14:22:07 -07:00
lilia
c1b9f3235f Save all errors
But clean up objects created by the Error constructor, as they contain
non-serializable properties, like functions.

// FREEBIE
2015-09-30 14:22:07 -07:00
lilia
37ff3cf5a8 Change http logging
Printing method + url again makes it easier to match requests to
responses when scanning logs.

// FREEBIE
2015-09-30 14:21:52 -07:00
lilia
0f8aff12c5 Refactor contact rendering in message detail view
DRY

// FREEBIE
2015-09-30 14:21:52 -07:00
lilia
b8536679b3 Stop keepalive when socket closes
// FREEBIE
2015-09-30 14:21:10 -07:00
lilia
04c5f83485 Un-nest libtextsecure errors
Fix inconsistency in error format, where we sometimes get an unexpected
Error object and sometimes get a wrapper object containing an Error.

Also start saving network errors.

// FREEBIE
2015-09-30 12:44:11 -07:00
lilia
1879e73c76 Allow one more retry if we get a 409
Handle cases where we get a 409 (missing/extra devices), handle it, then
get a 410 (stale devices by registration id).

// FREEBIE
2015-09-28 14:10:50 -07:00
lilia
8453424ebd Fix stuck pending messages state
Refactor outgoing message error handling to use the same success and
error handlers. This creates a somewhat strange pattern, where we call
send and pass in the promise that resolves when sending is complete, but
there's enough variety in the libtextsecure syntax for different message
sending routines that it belongs at the conversation level and only the
post-processing stuff is really shared by all messages.

// FREEBIE
2015-09-28 13:33:26 -07:00
lilia
f9ce27f2c8 Refactor index.js
There is no in-window navigation in the chrome app environment, so nix
the first if-clause here. Also make it programmatically reloadable and
fix indentation.

// FREEBIE
2015-09-25 17:57:23 -07:00
lilia
2bdd0106e7 Add comments
// FREEBIE
2015-09-25 11:10:25 -07:00
lilia
eb1cfe9b70 Move notification listeners to background
Otherwise they will be re-registered by the frontend page.

// FREEBIE
2015-09-25 11:10:14 -07:00
lilia
3bf9e36ead Move function declarations out of storage.onready 2015-09-24 10:39:56 -07:00
lilia
c8e51563a0 Refactor initial sync codepath to application layer
To reduce dependence on the message sending module, AccountManager
should send no sync requests itself.
2015-09-24 10:38:58 -07:00
lilia
6123c419d0 Remove refreshGroup
1. This is nonstandard behavior, not supported by any other clients. It
   may help sometimes but will also cause bugs (see 2)

2. iOS doesn't handle group updates with missing fields. all fields must
   be populated, and libtextsecure doesn't have any knowledge of the group
   name or avatar, so these updates will clobber group state on iOS.

// FREEBIE
2015-09-23 16:45:09 -07:00
lilia
94e1c2d123 Remove check for .humanError property
This property is no longer used by any of our errors.

// FREEBIE
2015-09-23 16:45:09 -07:00
lilia
6547538458 Use foreach instead of a loop
This syntax makes plain that the function is not used anywhere else,
and increases linearity/readability.

// FREEBIE
2015-09-23 16:45:08 -07:00
lilia
acaf7b8de2 Refactor relay consistency check
Check the device list for relay consitency and throw an exception before
attempting to encrypt to any of the mismatched devices.

// FREEBIE
2015-09-23 16:45:08 -07:00
lilia
bafc61600c Refactor sendMessageToDevices
Leverage map and Promise.all for more concise and linear code flow.
2015-09-23 16:45:07 -07:00
lilia
9ff95c7e61 DRY up group update sending
// FREEBIE
2015-09-23 16:45:07 -07:00
lilia
f00d118c93 More logging
// FREEBIE
2015-09-23 16:30:30 -07:00
lilia
f6b35ffbfc Log error stack traces
// FREEBIE
2015-09-23 16:30:30 -07:00
lilia
213dbdefd2 Reorder functions
// FREEBIE
2015-09-23 16:30:30 -07:00
lilia
62c90e3925 Don't save/log websocket error
It's a generic error Event and doesn't actually contain anything useful.

// FREEBIE
2015-09-23 16:30:30 -07:00
lilia
289b82d1dc Expose messageReceiver.close
// FREEBIE
2015-09-23 16:30:29 -07:00
lilia
1d370857fc Remove unused callback arguments
Unused since d0fd3e94 afaict.

// FREEBIE
2015-09-23 16:07:21 -07:00
lilia
2204ef863d Fix event name
We successfully retry after a websocket connection closes, but this typo
prevented us from retrying if the websocket simply never opened.

// FREEBIE
2015-09-23 16:07:20 -07:00
lilia
d1191c509c Log outgoing errors individually
// FREEBIE
2015-09-21 11:48:57 -07:00
lilia
ada3d999e0 Log outgoing errors
// FREEBIE
2015-09-21 11:02:33 -07:00
lilia
ce49d14d85 Fix leave group bug
This one's been around since forever, but only manifests when someone
leaves the group and comes back. In that case we fail to reinit their
numberRegistrationId object, which causes a npe when we try to send
send them group messages.

Affected parties must ask their fickle friends to leave/join again.

// FREEBIE
2015-09-21 11:00:12 -07:00
lilia
4a482243d0 Simplify event arguments
// FREEBIE
2015-09-21 10:32:35 -07:00
lilia
c8a76ab38e Fix websocket event handler name
// FREEBIE
2015-09-21 10:32:35 -07:00
lilia
21667d9181 Log when we start waiting for an online event
// FREEBIE
2015-09-21 10:32:35 -07:00
lilia
823f570955 Add more websocket debug logging
// FREEBIE
2015-09-21 10:32:34 -07:00
lilia
f70e844cef Include url in http response logging
Otherwise it's impossible to tell which is which, especially when
sending group messages.

// FREEBIE
2015-09-21 10:32:34 -07:00
lilia
d8803ee31f Mark leave group messages as sent
// FREEBIE
2015-09-21 10:32:33 -07:00
lilia
b1d3829651 Update minimal window dimensions
Some day we'll probably lower these minimums but first we'd need a more
responsive design.

Fixes #310

// FREEBIE
2015-09-18 13:13:31 -07:00
lilia
960754ef04 Restyle compose button
Move it to a tool bar at the top of the conversation list. This is also
where a search bar will live someday.

Fixes #357

// FREEBIE
2015-09-18 13:08:52 -07:00
lilia
2243c09fea MessageReceiver is an event target
Rather than asking for a global target, the message receiver implements
the EventTarget interface itself. It does not expose the dispatchEvent
method, however. This ensures that events can only be triggered from
within the internal MessageReceiver class, which means we no longer need
to namespace them.

// FREEBIE
2015-09-18 09:30:12 -07:00
lilia
a925027cd2 Refactor MessageReceiver for storage/server independence
Let the libtextsecure consumer pass in their own server url, username,
password, and signaling key, as with libtextsecure-java.

Also brings reconnect logic up into the MessageReceiver class, which
is the only place it should apply.
2015-09-17 16:52:32 -07:00
lilia
e59a5792d5 Don't hardcode the attachment host 2015-09-17 16:02:22 -07:00
lilia
184e37383c Don't auto-populate the relay field
According to server api docs, relay is optional when it is the same as
our own server.

// FREEBIE
2015-09-17 16:02:22 -07:00
lilia
7d9cf0c167 Pass the signaling key into decryptWebSocketMessage
De-couple this file from dependency on storage.
2015-09-17 16:02:22 -07:00
lilia
c167fc964d Revert "Remove global updateInbox method"
This reverts commit 1c70293bba.

This broke tests by blocking the database deletion during test
setup.
2015-09-17 15:42:13 -07:00
lilia
310f40fcad Contact sync should update existing contacts
// FREEBIE
2015-09-17 14:26:25 -07:00
lilia
7f4ef6e9e7 Remove double-check of unread count
This same condition is already enforced in the markRead method.

// FREEBIE
2015-09-17 13:46:58 -07:00