Commit Graph

107 Commits

Author SHA1 Message Date
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
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
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
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
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
Matthew Chen
5d780d1589 Apply script to normalize includes and imports. 2021-10-21 09:21:10 -03:00
Matthew Chen
9271f83624 Remove databaseChangesWillUpdate. 2021-09-08 21:41:13 -03:00
Matthew Chen
f2b76e60f9 Refine names. 2021-07-02 22:08:53 -03:00
Matthew Chen
f06b72bc2a 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
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
Matthew Chen
86b8eb08b8 Remove YapDatabase.
Apply asset from design.

Fix rebase breakage.
2021-03-25 11:41:16 -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
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
Matthew Chen
4ae673a043 Fix broken test. 2021-01-25 19:40:13 -03:00
Matthew Chen
c017e76aab Rename singleton accessors. 2020-09-17 21:11:09 -03:00
Matthew Chen
ad6bda8a44 Rename singleton accessors. 2020-09-17 21:11:07 -03:00
Matthew Chen
4c432b1ac3 Fix broken tests. 2020-09-17 17:31:23 -03:00
Nora Trapp
18e19088a5 Fix broken tests 2020-08-28 13:10:47 -07:00
Fumiaki Yoshimatsu
5a899b02b1 Fixes tests by giving a semi-bogus phone number to work around an assertion. 2020-08-28 09:43:54 -07:00
Fumiaki Yoshimatsu
93e5503b87 Fixed two tests related to UIDatabaseSnapshotDelegate. 2020-08-28 09:42:45 -07:00
Matthew Chen
f243889d00 Use protocol contexts in prekey stores. 2020-08-25 21:31:56 -03:00
Nora Trapp
9696671f8a Add trustLevel to SignalServiceAddress 2020-08-05 14:36:43 -07:00
Matthew Chen
154805cf68 Fix broken tests. 2020-06-23 10:04:39 -03:00
Matthew Chen
3cedd3ccdf Overhaul database observation. 2020-06-18 09:28:49 -03:00
Matthew Chen
8f468dce67 Respond to CR. 2020-05-11 10:29:13 -03:00
Matthew Chen
f8b9b209ff Respond to CR. 2020-05-11 10:19:52 -03:00
Matthew Chen
dd42dcca49 Remove YDB from views. 2020-04-07 13:51:02 -03:00
Matthew Chen
529dbf09cd Fix unit tests. 2020-02-28 16:30:54 -03:00
Matthew Chen
72f912dce3 Versioned profile changes, etc. 2020-01-08 13:54:54 -03:00
Michael Kirk
884f09ea5a Windowed conversation loading 2019-12-31 14:29:32 -08:00
Matthew Chen
29150102cb Revert group and profile changes. 2019-12-11 20:41:54 -08:00
Matthew Chen
05c8e674ee Rework new group new creation & group updates. 2019-12-05 12:37:22 -03:00
Matthew Chen
9bdb85b897 Fix test broken by group manager. 2019-11-13 10:29:07 -03:00
Matthew Chen
b38a64cce8 Revert "Revert "Merge branch 'charlesmchen/groupManager2'""
This reverts commit 7530dee591.
2019-11-12 09:02:52 -03:00
Matthew Chen
7530dee591 Revert "Merge branch 'charlesmchen/groupManager2'"
This reverts commit 26fd0d0812, reversing
changes made to c17865b750.
2019-11-11 20:01:45 -03:00
Matthew Chen
0ecee32271 Apply group manager in tests. 2019-11-11 17:31:21 -03:00
Matthew Chen
b5f777d985 Fix more broken tests. 2019-11-07 17:37:48 -03:00
Matthew Chen
70d4b3a2a0 Fix broken tests. 2019-11-07 17:22:08 -03:00
Matthew Chen
6b8708433c Delete old and unused one-time prekeys.
Thanks Mikunj Varsani for the bug report.
2019-11-02 08:16:41 -03:00
Michael Kirk
6d73d01e01 remove some unused columns 2019-10-14 18:23:35 -06:00
Matthew Chen
031eafe8fe Fix broken tests. 2019-10-04 16:31:50 -03:00
Matthew Chen
20683678b5 Store group avatars as data. 2019-09-27 16:25:53 -03:00
Matthew Chen
eb0d934a2c Add Debug UI action to insert one of each kind of model. 2019-09-23 13:49:29 -03:00