feat: add config base free instead of user profile

This commit is contained in:
0x330a
2022-12-16 16:53:12 +11:00
parent bd2a4fcfd6
commit 1b2e734453
5 changed files with 44 additions and 11 deletions

View File

@@ -1,4 +0,0 @@
package org.thoughtcrime.securesms.dependencies;
public interface InjectableType {
}

View File

@@ -0,0 +1,30 @@
package org.thoughtcrime.securesms.dependencies
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityRetainedComponent
import dagger.hilt.android.scopes.ActivityRetainedScoped
import network.loki.messenger.libsession_util.UserProfile
import org.thoughtcrime.securesms.ApplicationContext
import org.thoughtcrime.securesms.crypto.KeyPairUtilities
@Module
@InstallIn(ActivityRetainedComponent::class)
abstract class SessionUtilModule {
private fun maybeUserEdSecretKey(context: ApplicationContext): ByteArray? {
val edKey = KeyPairUtilities.getUserED25519KeyPair(context) ?: return null
return edKey.secretKey.asBytes
}
@Provides
@ActivityRetainedScoped
fun provideUser(context: ApplicationContext): UserProfile {
val key = maybeUserEdSecretKey(context)
return UserProfile.newInstance(key ?: byteArrayOf())
}
}