mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 20:06:51 +03:00
Ensure FCM always have the good gateway
This commit is contained in:
parent
3267cbbf78
commit
48498020a0
5 changed files with 11 additions and 9 deletions
|
@ -29,7 +29,6 @@ import kotlin.math.abs
|
|||
private const val DEFAULT_PUSHER_FILE_TAG = "mobile"
|
||||
|
||||
class PushersManager @Inject constructor(
|
||||
private val unifiedPushStore: UnifiedPushStore,
|
||||
private val unifiedPushHelper: UnifiedPushHelper,
|
||||
private val activeSessionHolder: ActiveSessionHolder,
|
||||
private val localeProvider: LocaleProvider,
|
||||
|
@ -40,7 +39,7 @@ class PushersManager @Inject constructor(
|
|||
val currentSession = activeSessionHolder.getActiveSession()
|
||||
|
||||
currentSession.pushersService().testPush(
|
||||
unifiedPushStore.getPushGateway(),
|
||||
unifiedPushHelper.getPushGateway() ?: return,
|
||||
stringProvider.getString(R.string.pusher_app_id),
|
||||
unifiedPushHelper.getEndpointOrToken().orEmpty(),
|
||||
TEST_EVENT_ID
|
||||
|
|
|
@ -266,4 +266,9 @@ class UnifiedPushHelper @Inject constructor(
|
|||
return if (isEmbeddedDistributor()) fcmHelper.getFcmToken()
|
||||
else unifiedPushStore.getEndpoint()
|
||||
}
|
||||
|
||||
fun getPushGateway(): String? {
|
||||
return if (isEmbeddedDistributor()) context.getString(R.string.pusher_http_url)
|
||||
else unifiedPushStore.getPushGateway()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package im.vector.app.core.pushers
|
|||
|
||||
import android.content.Context
|
||||
import androidx.core.content.edit
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.DefaultSharedPreferences
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -53,9 +52,8 @@ class UnifiedPushStore @Inject constructor(
|
|||
*
|
||||
* @return the Push Gateway or null if not defined
|
||||
*/
|
||||
fun getPushGateway(): String {
|
||||
fun getPushGateway(): String? {
|
||||
return defaultPrefs.getString(PREFS_PUSH_GATEWAY, null)
|
||||
?: context.getString(R.string.pusher_http_url)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,7 +69,7 @@ class VectorMessagingReceiver : MessagingReceiver() {
|
|||
unifiedPushStore.storeUpEndpoint(endpoint)
|
||||
coroutineScope.launch {
|
||||
unifiedPushHelper.storeCustomOrDefaultGateway(endpoint) {
|
||||
unifiedPushStore.getPushGateway().let {
|
||||
unifiedPushHelper.getPushGateway()?.let {
|
||||
pushersManager.enqueueRegisterPusher(endpoint, it)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,19 +19,19 @@ package im.vector.app.features.settings.troubleshoot
|
|||
import android.content.Intent
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.pushers.UnifiedPushStore
|
||||
import im.vector.app.core.pushers.UnifiedPushHelper
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import javax.inject.Inject
|
||||
|
||||
class TestUnifiedPushGateway @Inject constructor(
|
||||
private val unifiedPushStore: UnifiedPushStore,
|
||||
private val unifiedPushHelper: UnifiedPushHelper,
|
||||
private val stringProvider: StringProvider
|
||||
) : TroubleshootTest(R.string.settings_troubleshoot_test_current_gateway_title) {
|
||||
|
||||
override fun perform(activityResultLauncher: ActivityResultLauncher<Intent>) {
|
||||
description = stringProvider.getString(
|
||||
R.string.settings_troubleshoot_test_current_gateway,
|
||||
unifiedPushStore.getPushGateway()
|
||||
unifiedPushHelper.getPushGateway()
|
||||
)
|
||||
status = TestStatus.SUCCESS
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue