Commit Graph

424 Commits

Author SHA1 Message Date
Matthew Chen
8aa213d25b Deduplication message decryption to avoid spurious errors when NSE and main app message processing race. 2021-09-22 12:05:28 -07:00
Matthew Chen
9271f83624 Remove databaseChangesWillUpdate. 2021-09-08 21:41:13 -03:00
Matthew Chen
c1a8005a74 Never emit invalid e164 in storage service contact records; be robust to invalid e164 incoming protos. 2021-09-01 16:33:16 -03:00
Michelle Linington
c7fb7b2032 Fix broken test 2021-09-01 11:42:34 -07:00
Michelle Linington
4eeb4e34be Tests should be runnable in Profiling scheme 2021-08-26 20:57:06 -07:00
Michelle Linington
8bcf7d39ff Timestamp mismatch between envelope inside and outside
On a resend response, when fetching the proto payload from the MSL, some
incorrect float math led to an off-by-one timestamp for some timestamps.

One example is the timestamp 1629210680140. When converting to a date:
1629210680140 / 1000.0 = 1629210680.1399999

Then when converting back to milliseconds:
Int(1629210680.1399999 * 1000.0) = 1629210680139

To fix this, the MSL now only operates with UInt64 millisecond
timestamps.
2021-08-19 17:01:05 -07:00
Michelle Linington
6417494bc3 Fix tests 2021-08-19 16:54:29 -07:00
Matthew Chen
4b77df38fa Refine names. 2021-08-18 15:01:04 -03:00
Matthew Chen
b28131de13 Refine error localizedDescription. 2021-08-18 15:01:03 -03:00
Matthew Chen
fb549a95ea Refine error localizedDescription. 2021-08-18 15:01:03 -03:00
Matthew Chen
e13657952b Respond to CR; fix broken tests. 2021-08-18 14:26:20 -03:00
Matthew Chen
05bf2b86b9 Clean up ahead of PR. 2021-08-18 14:25:40 -03:00
Matthew Chen
fcdca12cf5 Deprecate REST, Part 1
* Port socket manager to Swift.
* Clean up HTTP request success/failure state & errors.
* Rework network manager.
* Rework HTTP errors.
* Rework errors "properties": isRetryable, etc.
* Fix test breakage.
2021-08-18 14:25:36 -03:00
Nora Trapp
1cbe9c3ee7 PR Feedback 2021-08-16 13:28:08 -07:00
Michelle Linington
8ced863098 Fix a bug with date comparison. Added tests 2021-08-16 13:14:19 -07:00
Michelle Linington
c1f80c143d Lint 2021-08-16 13:14:19 -07:00
Michelle Linington
93d584b239 IOS-1718: Foreign constraint failure on MessageSendLog
Fixes a bug where a incoming delivery receipt can race with an
in-progress send.

- When a message is preparing to be sent, a payload is inserted
- As sends are successful, recipient entries are added to indicate that
  we're awaiting delivery acknowledgement.
- Once all recipient entries have been cleared (every recipient has
  acked), we delete the payload.

If a message is being sent to A and B: A succeeds, but B is delayed, and
A acks before B can be sent, the payload entry will be cleared.

This change adds a "sendComplete" bit to the MSL table to indicate
whether or not the entry should be preserved even if all recipients have
acked.
2021-08-16 13:14:19 -07:00
Michelle Linington
1788e4a4fb Fixes a crash in OWSReceiptManager
Dictionary(uniqueKeysWithValues:) will assert that the provided keys are
unique and crash if a violation occurs. The existing code in
OWSReceiptManager falsely assumes that the addresses being built are
unique.

The keys in the key value store *are* unique, but as they're mapped into
addresses, we may have learned of a high trust e164/UUID mapping since
they were inserted. As the identifiers are mapped into
SignalServiceAddresses, the e164 and UUID are mapped to the same
SignalServiceAddress.

The fix is to just wrap our address builder in a Set() so we only have
one copy for each address.
2021-08-09 21:43:06 -03:00
Michelle Linington
4952320106 Fix comment 2021-07-29 20:39:06 -07:00
Michelle Linington
4c3e30ea4b Add tests to exercise the MessageSendLog 2021-07-29 20:37:21 -07:00
Michelle Linington
8636769dfb Trim the MessageSendLog
- Recipients that return a delivery receipt will be removed from the MSL
- The MSL will clear out stale payloads ~24 hours
2021-07-29 15:08:59 -07:00
Matthew Chen
cea3b7ce53 Fix broken test. 2021-07-13 22:16:32 -03:00
Matthew Chen
f2b76e60f9 Refine names. 2021-07-02 22:08:53 -03:00
Matthew Chen
8b73e93be2 Remove uiRead(). 2021-07-02 22:04:58 -03:00
Matthew Chen
f06b72bc2a Remove uiRead(). 2021-07-02 22:04:58 -03:00
Matthew Chen
f65d6e8e2d Remove uiRead(). 2021-07-02 22:04:58 -03:00
Matthew Chen
75de56236b Remove uiRead(). 2021-07-02 22:04:58 -03:00
Matthew Chen
ccd2cedbc8 Apply LRUCache everywhere. 2021-06-30 16:01:08 -03:00
Nora Trapp
3a431c25f4 Disable unnecessary job queues from running in extensions 2021-06-24 12:20:46 -07:00
Matthew Chen
c1a9694a59 Rework user profile writes. 2021-06-18 13:46:39 -03:00
Matthew Chen
718120f725 Fix test imports. 2021-06-07 11:41:43 -04:00
Matthew Chen
37052a302a Fix build warnings around imports. 2021-06-07 11:11:30 -04:00
Michelle Linington
21f0fcb2ff Fixes broken tests related to the GroupMembers table
The TSGroupMember table is updated after every inserted interaction. It
asserts that the sender of the interaction is in the group membership.

Before, our tests would construct groups with mock membership and then
construct outgoing messages with the local address as the sender. This
would fail this new requirement.

The fix is to make sure that the local address is in the test group
membership if we'd like to "send" any messages.
2021-05-06 15:45:42 -07:00
Nora Trapp
a365b45522 Add support for viewed receipts 2021-04-29 18:01:18 -07:00
Nora Trapp
4f629e3a35 Fix sticker tests 2021-04-08 14:16:47 -07:00
Matthew Chen
02fbe33779 Payments: SSK Business Logic 2021-04-06 13:57:06 -03:00
Matthew Chen
86b8eb08b8 Remove YapDatabase.
Apply asset from design.

Fix rebase breakage.
2021-03-25 11:41:16 -03:00
Matthew Chen
211b93581b Rework dependency access. 2021-03-25 09:24:27 -03:00
Matthew Chen
d0cbf8cfd0 Rework dependency access. 2021-03-25 09:24:27 -03:00
Jordan Rose
6ddd3ce184 SSK: Remove SPKProtocolContext
Brought over for convenience in the previous commit, but no longer
needed now that everything's in one framework.
2021-03-22 16:18:29 -07:00
Jordan Rose
68a27a76e2 Move AxolotlKit model classes into SSK and remove the dependency
We still need the AxolotlKit model classes to migrate old sessions,
but we don't need any of the actual protocol support. This also
means we can drop HKDFKit.

Additionally, we do still use some utilities from AxolotlKit:

- AxolotlExceptions.h: NSException names, should eventually be
  replaced by NSErrors everywhere

- NSData+keyVersionByte.h: prepend/remove public key type byte,
  should eventually be replaced by strong types (ECPublicKey)

- SPKProtocolContext.h: defines the SPKProtocol{Read,Write}Context
  marker protocols, should be replaced by direct use of
  SDSAny{Read,Write}Transaction
2021-03-22 16:17:47 -07:00
Jordan Rose
69d94a7719 SSK: Migrate TestProtocolRunner to SignalClient
Previously this manually initialized two sessions through an
AxolotlKit-provided helper. Rather than expose a similar helper for
SignalClient, TestProtocolRunner now sends an empty message in both
directions to initialize the sessions.
2021-03-22 16:10:42 -07:00
Nora Trapp
5f8f048202 Fix tests 2021-02-23 10:45:50 -08:00
Nora Trapp
91d2953843 Begone OWSMessageReceiver 2021-02-23 10:45:50 -08:00
Nora Trapp
3991802fa8 Add appropriate restrictions to when message processing can run. 2021-02-23 10:45:50 -08:00
Nora Trapp
ad6583facb Eliminate usage of decrypt job queue 2021-02-23 10:45:50 -08:00
Matthew Chen
645bd76bd5 Rework app readiness. 2021-02-04 09:55:39 -03:00
Jordan Rose
c7b6ba7010 Make OWSAccountIdFinder's methods into class methods
OWSAccountIdFinder is no longer used for dependency injection in
SignalMetadataKit, so there's no need to allocate empty NSObjects just
to call the methods.

No functionality change.
2021-01-28 12:03:50 -08:00
Jordan Rose
1ea62f2f50 SSK: Update for 'throws' removal in SignalClient 2021-01-28 12:03:50 -08:00
Jordan Rose
aeb78527ea SSK: Update for removal of SMK{Sender,Server}Certificate 2021-01-28 12:03:50 -08:00