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.
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.
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.
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
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.
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.
There are a lot of events that get dispatched onto the main queue
(often /from/ the main queue), and processing them during the setup
for the subsequent test can cause problems. In particular, the
notification for setting up a local number in -[OWSMessageManagerTest
test_GroupUpdate] was occasionally being processed in the subsequent
-test_GroupUpdateWithAvatar, depending on how long GRDB took to set up
in the second test.