Cleanup
This commit is contained in:
parent
f4e4be7479
commit
245c46c8b8
6 changed files with 10 additions and 25 deletions
|
|
@ -55,9 +55,8 @@ dependencies {
|
||||||
exclude(group = "com.android.support", module = "support-annotations")
|
exclude(group = "com.android.support", module = "support-annotations")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Remove
|
// TODO Temporary use the deprecated LocalBroadcastManager, to be changed later.
|
||||||
implementation(platform(libs.google.firebase.bom))
|
implementation("androidx.localbroadcastmanager:localbroadcastmanager:1.1.0")
|
||||||
implementation("com.google.firebase:firebase-messaging-ktx")
|
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testImplementation(libs.test.junit)
|
||||||
testImplementation(libs.test.mockk)
|
testImplementation(libs.test.mockk)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class DefaultPushService @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current push provider, compare with provided one, then unregister and register if different, and store change
|
* Get current push provider, compare with provided one, then unregister and register if different, and store change.
|
||||||
*/
|
*/
|
||||||
override suspend fun registerWith(matrixClient: MatrixClient, pushProvider: PushProvider, distributor: Distributor) {
|
override suspend fun registerWith(matrixClient: MatrixClient, pushProvider: PushProvider, distributor: Distributor) {
|
||||||
val userPushStore = userPushStoreFactory.create(matrixClient.sessionId)
|
val userPushStore = userPushStoreFactory.create(matrixClient.sessionId)
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,15 @@ import com.squareup.anvil.annotations.ContributesBinding
|
||||||
import io.element.android.libraries.core.log.logger.LoggerTag
|
import io.element.android.libraries.core.log.logger.LoggerTag
|
||||||
import io.element.android.libraries.di.AppScope
|
import io.element.android.libraries.di.AppScope
|
||||||
import io.element.android.libraries.matrix.api.MatrixClient
|
import io.element.android.libraries.matrix.api.MatrixClient
|
||||||
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
|
|
||||||
import io.element.android.libraries.matrix.api.core.EventId
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
import io.element.android.libraries.matrix.api.core.SessionId
|
import io.element.android.libraries.matrix.api.core.SessionId
|
||||||
import io.element.android.libraries.matrix.api.pusher.SetHttpPusherData
|
import io.element.android.libraries.matrix.api.pusher.SetHttpPusherData
|
||||||
import io.element.android.libraries.pushstore.api.clientsecret.PushClientSecret
|
|
||||||
import io.element.android.libraries.push.impl.config.PushConfig
|
import io.element.android.libraries.push.impl.config.PushConfig
|
||||||
import io.element.android.libraries.push.impl.log.pushLoggerTag
|
import io.element.android.libraries.push.impl.log.pushLoggerTag
|
||||||
import io.element.android.libraries.push.impl.pushgateway.PushGatewayNotifyRequest
|
import io.element.android.libraries.push.impl.pushgateway.PushGatewayNotifyRequest
|
||||||
import io.element.android.libraries.push.providers.api.PusherSubscriber
|
import io.element.android.libraries.push.providers.api.PusherSubscriber
|
||||||
import io.element.android.libraries.pushstore.api.UserPushStoreFactory
|
import io.element.android.libraries.pushstore.api.UserPushStoreFactory
|
||||||
import io.element.android.libraries.sessionstorage.api.SessionStore
|
import io.element.android.libraries.pushstore.api.clientsecret.PushClientSecret
|
||||||
import io.element.android.services.toolbox.api.appname.AppNameProvider
|
import io.element.android.services.toolbox.api.appname.AppNameProvider
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
@ -41,16 +39,13 @@ private val loggerTag = LoggerTag("PushersManager", pushLoggerTag)
|
||||||
|
|
||||||
@ContributesBinding(AppScope::class)
|
@ContributesBinding(AppScope::class)
|
||||||
class PushersManager @Inject constructor(
|
class PushersManager @Inject constructor(
|
||||||
// private val unifiedPushHelper: UnifiedPushHelper,
|
|
||||||
// private val localeProvider: LocaleProvider,
|
// private val localeProvider: LocaleProvider,
|
||||||
private val appNameProvider: AppNameProvider,
|
private val appNameProvider: AppNameProvider,
|
||||||
// private val getDeviceInfoUseCase: GetDeviceInfoUseCase,
|
// private val getDeviceInfoUseCase: GetDeviceInfoUseCase,
|
||||||
private val pushGatewayNotifyRequest: PushGatewayNotifyRequest,
|
private val pushGatewayNotifyRequest: PushGatewayNotifyRequest,
|
||||||
private val pushClientSecret: PushClientSecret,
|
private val pushClientSecret: PushClientSecret,
|
||||||
private val sessionStore: SessionStore,
|
|
||||||
private val matrixAuthenticationService: MatrixAuthenticationService,
|
|
||||||
private val userPushStoreFactory: UserPushStoreFactory,
|
private val userPushStoreFactory: UserPushStoreFactory,
|
||||||
): PusherSubscriber {
|
) : PusherSubscriber {
|
||||||
// TODO Move this to the PushProvider API
|
// TODO Move this to the PushProvider API
|
||||||
suspend fun testPush() {
|
suspend fun testPush() {
|
||||||
pushGatewayNotifyRequest.execute(
|
pushGatewayNotifyRequest.execute(
|
||||||
|
|
@ -63,18 +58,6 @@ class PushersManager @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun enqueueRegisterPusherWithFcmKey(pushKey: String) {
|
|
||||||
// return onNewFirebaseToken(pushKey, PushConfig.pusher_http_url)
|
|
||||||
TODO()
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun onNewUnifiedPushEndpoint(
|
|
||||||
pushKey: String,
|
|
||||||
gateway: String
|
|
||||||
) {
|
|
||||||
TODO()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a pusher to the server if not done yet.
|
* Register a pusher to the server if not done yet.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ package io.element.android.libraries.push.providers.api
|
||||||
import io.element.android.libraries.matrix.api.MatrixClient
|
import io.element.android.libraries.matrix.api.MatrixClient
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main API for this module
|
* This is the main API for this module.
|
||||||
*/
|
*/
|
||||||
interface PushProvider {
|
interface PushProvider {
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("io.element.android-library")
|
id("io.element.android-library")
|
||||||
alias(libs.plugins.anvil)
|
alias(libs.plugins.anvil)
|
||||||
// kotlin("plugin.serialization") version "1.8.10"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ class UnifiedPushStore @Inject constructor(
|
||||||
/**
|
/**
|
||||||
* Retrieves the UnifiedPush Endpoint.
|
* Retrieves the UnifiedPush Endpoint.
|
||||||
*
|
*
|
||||||
|
* @param clientSecret the client secret, to identify the session
|
||||||
* @return the UnifiedPush Endpoint or null if not received
|
* @return the UnifiedPush Endpoint or null if not received
|
||||||
*/
|
*/
|
||||||
fun getEndpoint(clientSecret: String): String? {
|
fun getEndpoint(clientSecret: String): String? {
|
||||||
|
|
@ -40,6 +41,7 @@ class UnifiedPushStore @Inject constructor(
|
||||||
* Store UnifiedPush Endpoint to the SharedPrefs.
|
* Store UnifiedPush Endpoint to the SharedPrefs.
|
||||||
*
|
*
|
||||||
* @param endpoint the endpoint to store
|
* @param endpoint the endpoint to store
|
||||||
|
* @param clientSecret the client secret, to identify the session
|
||||||
*/
|
*/
|
||||||
fun storeUpEndpoint(endpoint: String?, clientSecret: String) {
|
fun storeUpEndpoint(endpoint: String?, clientSecret: String) {
|
||||||
defaultPrefs.edit {
|
defaultPrefs.edit {
|
||||||
|
|
@ -50,6 +52,7 @@ class UnifiedPushStore @Inject constructor(
|
||||||
/**
|
/**
|
||||||
* Retrieves the Push Gateway.
|
* Retrieves the Push Gateway.
|
||||||
*
|
*
|
||||||
|
* @param clientSecret the client secret, to identify the session
|
||||||
* @return the Push Gateway or null if not defined
|
* @return the Push Gateway or null if not defined
|
||||||
*/
|
*/
|
||||||
fun getPushGateway(clientSecret: String): String? {
|
fun getPushGateway(clientSecret: String): String? {
|
||||||
|
|
@ -60,6 +63,7 @@ class UnifiedPushStore @Inject constructor(
|
||||||
* Store Push Gateway to the SharedPrefs.
|
* Store Push Gateway to the SharedPrefs.
|
||||||
*
|
*
|
||||||
* @param gateway the push gateway to store
|
* @param gateway the push gateway to store
|
||||||
|
* @param clientSecret the client secret, to identify the session
|
||||||
*/
|
*/
|
||||||
fun storePushGateway(gateway: String?, clientSecret: String) {
|
fun storePushGateway(gateway: String?, clientSecret: String) {
|
||||||
defaultPrefs.edit {
|
defaultPrefs.edit {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue