Commit Graph

223 Commits (5eabfa2559a950558bc45a021d0a7da59df3062a)

Author SHA1 Message Date
lilia 5eabfa2559 Fix libtextsecure tests
// FREEBIE
10 years ago
lilia 5bf608598c Fix MessageSender prototype
// FREEBIE
10 years ago
lilia b0da491025 Don't throw on unknown groups
// FREEBIE
10 years ago
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
10 years ago
lilia 4a1d0ebdb9 Pass bytebuffer to axolotlInstance
// FREEBIE
10 years ago
lilia 46c9a7fafb Fix tryMessageAgain
// FREEBIE
10 years ago
lilia 9872b59355 Simplify filter predicate
Untangle a double negative to make this line shorter and easier to read.

// FREEBIE
10 years ago
lilia 0fa1069a93 Don't throw on duplicate members in a group update
Fixes #364

// FREEBIE
10 years ago
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
10 years ago
lilia 978b3d1a98 DRY up tryMessageAgain
// FREEBIE
10 years ago
lilia fbb65d1988 Add replayable network errors
Support for manual message retry.

// FREEBIE
10 years ago
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
10 years ago
lilia 0fc673f25f Refactor sendmessage for prototypality
// FREEBIE
10 years ago
lilia 868695558d Throw on bad server url
// FREEBIE
10 years ago
lilia c8a1e090d2 Move handleAttachment and processDecrypted
Make these internal methods on MessageReceiver. Todo: refactor
identity key errors to use a given message receiver.

// FREEBIE
10 years ago
lilia a8f4bac2f7 Let makeAttachmentPointer resolve falsey arguments
Internalizing this pattern to the makeAttachmentPointer function lets us
DRY it up throughout the file.

// FREEBIE
10 years ago
lilia 9de23a967b Fix dropping the first websocket message 10 years ago
lilia 3fcd980c23 Add websocket error and close event handlers 10 years ago
lilia 78956ede2f Disable keepalive if we disconnect the socket 10 years ago
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
10 years ago
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
10 years ago
lilia 09bd6c7824 Lint
// FREEBIE
10 years ago
lilia 37ff3cf5a8 Change http logging
Printing method + url again makes it easier to match requests to
responses when scanning logs.

// FREEBIE
10 years ago
lilia b8536679b3 Stop keepalive when socket closes
// FREEBIE
10 years ago
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
10 years ago
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
10 years ago
lilia c8e51563a0 Refactor initial sync codepath to application layer
To reduce dependence on the message sending module, AccountManager
should send no sync requests itself.
10 years ago
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
10 years ago
lilia 94e1c2d123 Remove check for .humanError property
This property is no longer used by any of our errors.

// FREEBIE
10 years ago
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
10 years ago
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
10 years ago
lilia bafc61600c Refactor sendMessageToDevices
Leverage map and Promise.all for more concise and linear code flow.
10 years ago
lilia 62c90e3925 Don't save/log websocket error
It's a generic error Event and doesn't actually contain anything useful.

// FREEBIE
10 years ago
lilia 289b82d1dc Expose messageReceiver.close
// FREEBIE
10 years ago
lilia 1d370857fc Remove unused callback arguments
Unused since d0fd3e94 afaict.

// FREEBIE
10 years ago
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
10 years ago
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
10 years ago
lilia c8a76ab38e Fix websocket event handler name
// FREEBIE
10 years ago
lilia 823f570955 Add more websocket debug logging
// FREEBIE
10 years ago
lilia f70e844cef Include url in http response logging
Otherwise it's impossible to tell which is which, especially when
sending group messages.

// FREEBIE
10 years ago
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
10 years ago
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.
10 years ago
lilia e59a5792d5 Don't hardcode the attachment host 10 years ago
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
10 years ago
lilia 7d9cf0c167 Pass the signaling key into decryptWebSocketMessage
De-couple this file from dependency on storage.
10 years ago
lilia 537f0ceef0 Log all http requests at start and end
// FREEBIE
10 years ago
lilia 04c8796bd3 Disable socket level reconnect
This is now handled at a higher level by the message receiver with the
aid of http requests for diagnosing the disconnect.

// FREEBIE
10 years ago
lilia 6b483195cb Fix reconnect bugs from previous commit
Forgot to bind the socket event handler, and the then() handler should
come before the catch() handler or else it will execute every time the
catch handler executes.

// FREEBIE
10 years ago
lilia 16de5aa3d3 Improve reconnect logic
Always test connectivity with an http request after a websocket closes,
regardless of what code/error it closed with. If that request succeeds,
automatically reconnect the socket.

// FREEBIE
10 years ago
lilia f764445c86 Remove erroneous license file and headers
We only use GPLV3 around here.

// FREEBIE
10 years ago