Refactor: change signature to always have clientSecret first, since it's acting as a key.
This commit is contained in:
parent
0a2d87f6b1
commit
4e7f5c46b8
6 changed files with 27 additions and 27 deletions
|
|
@ -28,9 +28,9 @@ import javax.inject.Inject
|
|||
|
||||
interface UnifiedPushStore {
|
||||
fun getEndpoint(clientSecret: String): String?
|
||||
fun storeUpEndpoint(endpoint: String?, clientSecret: String)
|
||||
fun storeUpEndpoint(clientSecret: String, endpoint: String?)
|
||||
fun getPushGateway(clientSecret: String): String?
|
||||
fun storePushGateway(gateway: String?, clientSecret: String)
|
||||
fun storePushGateway(clientSecret: String, gateway: String?)
|
||||
fun getDistributorValue(userId: UserId): String?
|
||||
fun setDistributorValue(userId: UserId, value: String)
|
||||
}
|
||||
|
|
@ -53,10 +53,10 @@ class DefaultUnifiedPushStore @Inject constructor(
|
|||
/**
|
||||
* Store UnifiedPush Endpoint to the SharedPrefs.
|
||||
*
|
||||
* @param endpoint the endpoint to store
|
||||
* @param clientSecret the client secret, to identify the session
|
||||
* @param endpoint the endpoint to store
|
||||
*/
|
||||
override fun storeUpEndpoint(endpoint: String?, clientSecret: String) {
|
||||
override fun storeUpEndpoint(clientSecret: String, endpoint: String?) {
|
||||
defaultPrefs.edit {
|
||||
putString(PREFS_ENDPOINT_OR_TOKEN + clientSecret, endpoint)
|
||||
}
|
||||
|
|
@ -75,10 +75,10 @@ class DefaultUnifiedPushStore @Inject constructor(
|
|||
/**
|
||||
* Store Push Gateway to the SharedPrefs.
|
||||
*
|
||||
* @param gateway the push gateway to store
|
||||
* @param clientSecret the client secret, to identify the session
|
||||
* @param gateway the push gateway to store
|
||||
*/
|
||||
override fun storePushGateway(gateway: String?, clientSecret: String) {
|
||||
override fun storePushGateway(clientSecret: String, gateway: String?) {
|
||||
defaultPrefs.edit {
|
||||
putString(PREFS_PUSH_GATEWAY + clientSecret, gateway)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ class DefaultUnregisterUnifiedPushUseCase @Inject constructor(
|
|||
}
|
||||
return pusherSubscriber.unregisterPusher(matrixClient, endpoint, gateway)
|
||||
.onSuccess {
|
||||
unifiedPushStore.storeUpEndpoint(null, clientSecret)
|
||||
unifiedPushStore.storePushGateway(null, clientSecret)
|
||||
unifiedPushStore.storeUpEndpoint(clientSecret, null)
|
||||
unifiedPushStore.storePushGateway(clientSecret, null)
|
||||
UnifiedPush.unregisterApp(context)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,13 +73,13 @@ class VectorUnifiedPushMessagingReceiver : MessagingReceiver() {
|
|||
Timber.tag(loggerTag.value).i("onNewEndpoint: $endpoint")
|
||||
coroutineScope.launch {
|
||||
val gateway = unifiedPushGatewayResolver.getGateway(endpoint)
|
||||
unifiedPushStore.storePushGateway(gateway, instance)
|
||||
unifiedPushStore.storePushGateway(instance, gateway)
|
||||
val result = newGatewayHandler.handle(endpoint, gateway, instance)
|
||||
.onFailure {
|
||||
Timber.tag(loggerTag.value).e(it, "Failed to handle new gateway")
|
||||
}
|
||||
.onSuccess {
|
||||
unifiedPushStore.storeUpEndpoint(endpoint, instance)
|
||||
unifiedPushStore.storeUpEndpoint(instance, endpoint)
|
||||
}
|
||||
endpointRegistrationHandler.registrationDone(
|
||||
RegistrationResult(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue