PreKeyDataSource

internal class PreKeyDataSource(preKeyApi: PreKeyApi, proteusClientProvider: ProteusClientProvider, provideCurrentClientId: CurrentClientIdProvider, prekeyDAO: PrekeyDAO, clientDAO: ClientDAO, metadataDAO: MetadataDAO, preKeyListMapper: PreKeyListMapper = MapperProvider.preKeyListMapper(), preKeyMapper: PreKeyMapper = MapperProvider.preyKeyMapper()) : PreKeyRepository, CryptoSessionMapper

Constructors

Link copied to clipboard
constructor(preKeyApi: PreKeyApi, proteusClientProvider: ProteusClientProvider, provideCurrentClientId: CurrentClientIdProvider, prekeyDAO: PrekeyDAO, clientDAO: ClientDAO, metadataDAO: MetadataDAO, preKeyListMapper: PreKeyListMapper = MapperProvider.preKeyListMapper(), preKeyMapper: PreKeyMapper = MapperProvider.preyKeyMapper())

Functions

Link copied to clipboard
open suspend override fun establishSessions(proteusContext: ProteusCoreCryptoContext, missingContactClients: Map<UserId, List<ClientId>>): Either<CoreFailure, UsersWithoutSessions>
Link copied to clipboard
open suspend override fun fetchRemotelyAvailablePrekeys(): Either<CoreFailure, List<Int>>

Fetches the IDs of the prekeys currently available on the backend.

Link copied to clipboard
open suspend override fun forceInsertMostRecentPreKeyId(newId: Int): Either<StorageFailure, Unit>

Forces the insert of the ID of the most recent "rolling" prekey that was generated. Useful

Link copied to clipboard
open suspend override fun generateNewLastResortKey(): Either<ProteusFailure, PreKeyCrypto>

Also known as "last prekey", it's the prekey that the backend will share with other clients when it runs out of prekeys for this client. For "rolling" prekeys, see generateNewPreKeysAuto.

Link copied to clipboard
open suspend override fun generateNewPreKeysAuto(keysCount: Int): Either<ProteusFailure, List<PreKeyCrypto>>

Generates rolling prekeys, with Core Crypto automatically selecting the next available prekey ID. The generated prekeys can be uploaded to the backend and shared with other clients in order to initialise a new conversation with this client.

open override fun getMapOfSessionIdsToPreKeysAndMarkNullClientsAsInvalid(preKeyInfoMap: Map<String, Map<String, Map<String, PreKeyDTO?>>>): FilteredRecipient
Link copied to clipboard
open override fun lastPreKeyRefillCheckInstantFlow(): Flow<Instant?>

Observes the last pre-key check instant.

Link copied to clipboard
open suspend override fun mostRecentPreKeyId(): Either<StorageFailure, Int>

Returns the ID of the most recent "rolling" prekey that was generated.

Link copied to clipboard
internal suspend fun preKeysOfClientsByQualifiedUsers(qualifiedIdsMap: Map<UserId, List<ClientId>>): Either<NetworkFailure, ListPrekeysResponse>
Link copied to clipboard
open suspend override fun setLastPreKeyRefillCheckInstant(instant: Instant): Either<StorageFailure, Unit>

Sets the last prekey refill check date.

Link copied to clipboard
open suspend override fun updateMostRecentPreKeyId(newId: Int): Either<StorageFailure, Unit>

Updates the ID of the most recent "rolling" prekey that was generated.

Link copied to clipboard
open suspend override fun uploadNewPrekeyBatch(batch: List<PreKeyCrypto>): Either<CoreFailure, Unit>

Uploads a batch of prekeys to the backend, so they become available for other clients to start sessions with this client.