Commit Graph

501 Commits

Author SHA1 Message Date
Michelle Linington
2e7671b3f5 More project cleanup 2022-04-20 16:26:54 -07:00
Evan Hahn
0cf8a30bf9 Test Subscription struct
This test-only change adds tests for [`Subscription`][0].

I did this because I'll be adding additional behavior to this struct and
want to be ready to test that logic. I think this is a useful change on
its own, however, so I split it out into its own change.

[0]: 2693c55232/SignalMessaging/Subscriptions/SubscriptionManager.swift (L70-L104)
2022-04-20 12:47:50 -05:00
Max Radermacher
bc53916301 Convert all(Testable)?Flags to functions 2022-04-18 16:28:01 -07:00
Max Radermacher
05b0112c88 Rename buildFlagMap()allFlags
This matches the naming scheme used for `allFeatureFlags`.
2022-04-18 14:52:26 -07:00
Max Radermacher
91512d745c Don’t pass class or value lookup block
The class can be computed from `self`, and the lookup block is always
the same (essentially `self.value(forKey:)`), so there’s no need to
provide separate implementations for each subclass. The superclass can
provide a single implementation for all subclasses to share.
2022-04-18 14:52:26 -07:00
Max Radermacher
450b8035f3 Add unit tests for BaseFlags’ reflection APIs 2022-04-18 14:52:26 -07:00
Jordan Rose
9132234a54 Fix for non-messages being filtered out of interaction results
Messages always have an isGroupStoryReply of true or false (1 or 0),
but non-messages don't have this field, and GRDB treats that as NULL
rather than falling back to the table default.
2022-04-15 15:42:33 -07:00
Michelle Linington
41f78c5d12 Merge branch 'release/5.35.1' 2022-04-14 18:16:01 -07:00
Jordan Rose
a2edd320bb OWSMessageDecrypter should use destinationUuid to choose local stores
Note that on its own this doesn't change behavior of the app;
OWSMessageProcessor still drops non-ACI messages even attempting to
decrypt them.
2022-04-14 16:47:46 -07:00
Michelle Linington
e22bfcdc9b Add some version comparison tests 2022-04-14 16:44:16 -07:00
Michelle Linington
d54d654cfc PR Feedback: Remove notImplemented altogether 2022-04-13 20:21:47 -07:00
Michelle Linington
6b2f8d31d6 Lint 2022-04-13 20:21:46 -07:00
Michelle Linington
cca09295e6 Adopt notImplemented() where it's unadopted
notImplemented() ends up forwarding to fatalError() anyway, but before
it does so it flushes our logs. That's probably good to have. I think
most of these come from the default implementations Xcode provides for
you with a fix-it.
2022-04-13 20:21:46 -07:00
Igor Solomennikov
bd653bee3b Lint. 2022-04-12 17:38:21 -07:00
Igor Solomennikov
25810e0887 Add OWSFormatTest. 2022-04-12 17:38:21 -07:00
Michelle Linington
84be44880e PR Feedback 2022-04-08 19:36:27 -07:00
Michelle Linington
a36671c4c2 Lint 2022-04-08 19:01:43 -07:00
Michelle Linington
78e00e310e Adds a bunch of tests 2022-04-08 19:01:43 -07:00
Jordan Rose
f50412f26f Move pre-key culling logic from TSPreKeyManager to the stores 2022-04-07 10:23:39 -07:00
Jordan Rose
039dcc1d48 -[SSKPreKeyStore storePreKeyRecords:] should take a transaction
...so it can use an existing one when there is one, which in practice
there always is because we never refresh one-time pre-keys without
rotating our signed pre-key too.
2022-04-04 15:19:10 -07:00
Chris Eager
978445edf2 Fix failing testGroupEncryptDecrypt_Failure 2022-03-28 14:55:47 -07:00
Nora Trapp
05313c3725 Update to LibSignalClient v0.15.0 2022-03-24 11:55:45 -07:00
Evan Hahn
de105468a4 Assume everyone is GV2-capable 2022-03-22 17:11:57 -05:00
Jordan Rose
30adb219d6 Recognize destinationUuid on envelopes, and filter out non-ACI
We're very close to being able to decrypt messages sent to our PNI,
but *until* that point it's best to just drop any such messages. This
should make testing easier.
2022-03-18 14:15:00 -07:00
Jordan Rose
1c252fd6f6 Add PNI-related fields to the ProvisioningMessage proto
This allows linked devices to receive the PNI identity key as part of
provisioning.
2022-03-18 13:03:55 -07:00
Dimitris Apostolou
62724cf0be Fix typos 2022-03-18 11:31:06 -07:00
George Nachman
22c1cb8a22 Fetch phone numbers in a batch.
This is the first meaty part of optimizing
fetching display names.

Some contacts fall back to phone numbers as their
display names. This PR fetches them in a single
SQL query via
`OWSContactsManager.phoneNumbers(for:, transaction)`.

To achieve this, this PR introduces
`GRDBSignalAccountFinder.signalAccounts(for:,transaction:)`
to fetch many accounts at once.

In order to fetch many accounts at once, we need
to be able to fetch many values from a
ModelReadCache at once. So this PR introduces
`ModelReadCache.readValues(for:,transaction:)` and
`ModelReadCache.getValues(for:,transaction:,returnNilOnCacheMiss:)`.

Existing methods that operate on a single value
were refactored to use the batch methods.

This PR adds tests for this functionality, which
necessitated changing the visibility of various
private symbols and also improving the fake
profile manager to make it more configurable.

There's also a tiny optimization for Refinery to
avoid calling a closure that has no work to do.
This helps elide do-nothing SQL queries that would
otherwise have been introduced.
2022-03-17 12:46:33 -07:00
Jordan Rose
0d302834c8 SSK: Port OWSDeviceProvisioner (and OWSProvisioningMessage) to Swift
While here, clean up some overzealous uses of 'try!' in
OWSProvisioningCipher---this data comes from another device and
therefore can't be trusted.
2022-03-17 12:25:39 -07:00
Nora Trapp
626f1e2d23 Add StoryMessage protos 2022-03-16 17:50:01 -07:00
Jordan Rose
7448b377fb Parameterize the 1:1 stores by identity (ACI or PNI)
This allows two stores to coexist in the database. Note that
everything *using* the stores will still always use the ACI stores at
this point.
2022-03-16 14:31:06 -07:00
Jordan Rose
2e39dab9b2 Support two SignalProtocolStores in SSKEnvironment
'sessionStore', 'preKeyStore', and 'signedPreKeyStore' are no longer
directly accessible; you have to go through
'signalProtocolStore(for:)' instead. This commit mechanically changes
all use sites to use `signalProtocolStore(for: .aci)`, with the
understanding that they will need cleanup in the future.

This is not enough to actually support multiple stores; they still
store in the database under the same keys. That's coming in the next
commit.
2022-03-16 14:31:06 -07:00
Jordan Rose
49d4684013 Teach OWSIdentityManager about PNI identity keys
And make all callers explicitly say which one they want (which for now
is always the ACI identity key).
2022-03-16 13:29:20 -07:00
Jordan Rose
8e52adbf74 -[OWSIdentityManager generateNewIdentityKey] should return the new key
A micro-optimization to avoid an extra database query.
2022-03-16 13:29:20 -07:00
George Nachman
36119e4367 Introduce Refinery to help batch DB queries.
This PR is the first in a series that will
optimize looking up full names of group members.

The biggest source of slowness when opening a
group chat is looking up the full names of group
members in the search for duplicates. It is slow
because it requires multiple db queries for each
member.

The characterstic feature of this algorithm is the
iterative process of assigning names to signal
addresses. For example, some contacts' names may
be cached. For others, their profiles must be
fetched. For those without profiles, their phone
numbers must be formatted (which requires fetching
SignalAccounts). For those without phone numbers,
their user names must be formatted.

This PR creates a class called Refinery. Its job
is to make it easy to assign values to keys
through multiple passes, where each pass may
succeed only for a subset of keys.

This is useful because we will eventually issue a
single DB query for some of these passes.
2022-03-04 10:44:07 -08:00
Michelle Linington
e322921b10 Fix broken tests
If a test inserts a recipient, we need to have a registered local
address to perform some of our FTS index checks
2022-03-03 14:23:51 -08:00
George Nachman
d305bc66a3 Optimize searching for verification status, redux.
Commit 451fa08c22
had some bugs and was reverted by commit
12883e5db5.

This commit brings it back along with fixes.

Specific bug fixes:

* Verification status for a group was inverted.
* The local address should not be considered for
  deciding if a group is verified.
2022-03-01 14:15:11 -08:00
Jordan Rose
310638ad78 Fix MessageProcessingIntegrationTest database expectations
These tests fulfill an expectation when a write to the database causes
the desired state to be reached. However, there may still be writes to
the database in flight, and the *next* write will *also* probably be
in the desired state, resulting in the expectation being fulfilled
again. Because this happened *after* the test finished, an exception
was thrown, the test environment terminated, and the *next* test (or
possibly a later one) was being blamed for the failure.

Fix this issue in both places where it happens by allowing multiple
fulfills, and re-enable the test that was previously getting blamed
for this.
2022-02-03 09:44:11 -08:00
Michelle Linington
e6e09c83e7 Disable broken test 2022-02-01 10:23:40 -08:00
Michelle Linington
2559fa8bb4 Disable broken test 2022-02-01 10:14:51 -08:00
Jordan Rose
a31100f0f5 Fix copyrights 2022-01-26 09:50:56 -08:00
Jordan Rose
31e87ae986 Eliminate SMKAddress in favor of SignalServiceAddress 2022-01-26 09:50:56 -08:00
Jordan Rose
d7a05f54d2 Remove custom sender certificate validation
Generate valid sender certificates in tests, removing the need to
customize validation or build certificate data by hand.

While here, remove "throwswrapped" from some APIs that no longer wrap
ObjC-throwing methods.
2022-01-26 09:50:56 -08:00
Jordan Rose
01518551eb Import SignalMetadataKit wholesale into SignalServiceKit
The only modifications are those necessary to build as part of SSK.
The follow-up commits will clean that up a bit.
2022-01-26 09:50:55 -08:00
Jordan Rose
54de16338c SSK: Remove unused OWSSignalAddress 2022-01-11 10:03:48 -08:00
Matthew Chen
fae75abb39 Fix address hash continuity. 2021-12-01 10:45:10 -08:00
Matthew Chen
ff497ead1b Fix broken test. 2021-12-01 15:38:01 -03:00
Matthew Chen
23a98d724c Fix edge case in uuid<->phone number mapping changes. 2021-12-01 15:34:07 -03:00
Matthew Chen
512c403f11 Elaborate tests around address hash continuity. 2021-11-19 14:28:25 -03:00
Matthew Chen
07dc666382 Elaborate tests around address hash continuity. 2021-11-19 14:28:25 -03:00
Matthew Chen
5aa572fa50 Elaborate tests around address hash continuity. 2021-11-19 14:28:24 -03:00