mirror of
https://github.com/vector-im/riotX-android
synced 2025-10-05 15:52:47 +02:00
Revert old implementation
This commit is contained in:
@@ -79,7 +79,5 @@ data class HttpPusher(
|
|||||||
* true to limit the push content to only id and not message content
|
* true to limit the push content to only id and not message content
|
||||||
* Ref: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour
|
* Ref: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour
|
||||||
*/
|
*/
|
||||||
val withEventIdOnly: Boolean,
|
val withEventIdOnly: Boolean
|
||||||
|
|
||||||
val includeData: Map<String, String>,
|
|
||||||
)
|
)
|
||||||
|
@@ -46,6 +46,5 @@ enum class PusherState {
|
|||||||
|
|
||||||
data class PusherData(
|
data class PusherData(
|
||||||
val url: String? = null,
|
val url: String? = null,
|
||||||
val format: String? = null,
|
val format: String? = null
|
||||||
val remoteWipeNonce: String? = null,
|
|
||||||
)
|
)
|
||||||
|
@@ -68,7 +68,6 @@ import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo048
|
|||||||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo049
|
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo049
|
||||||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo050
|
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo050
|
||||||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo051
|
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo051
|
||||||
import org.matrix.android.sdk.internal.database.migration.MigrateSessionTo052
|
|
||||||
import org.matrix.android.sdk.internal.util.Normalizer
|
import org.matrix.android.sdk.internal.util.Normalizer
|
||||||
import org.matrix.android.sdk.internal.util.database.MatrixRealmMigration
|
import org.matrix.android.sdk.internal.util.database.MatrixRealmMigration
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -77,7 +76,7 @@ internal class RealmSessionStoreMigration @Inject constructor(
|
|||||||
private val normalizer: Normalizer
|
private val normalizer: Normalizer
|
||||||
) : MatrixRealmMigration(
|
) : MatrixRealmMigration(
|
||||||
dbName = "Session",
|
dbName = "Session",
|
||||||
schemaVersion = 52L,
|
schemaVersion = 51L,
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
* Forces all RealmSessionStoreMigration instances to be equal.
|
* Forces all RealmSessionStoreMigration instances to be equal.
|
||||||
@@ -138,6 +137,5 @@ internal class RealmSessionStoreMigration @Inject constructor(
|
|||||||
if (oldVersion < 49) MigrateSessionTo049(realm).perform()
|
if (oldVersion < 49) MigrateSessionTo049(realm).perform()
|
||||||
if (oldVersion < 50) MigrateSessionTo050(realm).perform()
|
if (oldVersion < 50) MigrateSessionTo050(realm).perform()
|
||||||
if (oldVersion < 51) MigrateSessionTo051(realm).perform()
|
if (oldVersion < 51) MigrateSessionTo051(realm).perform()
|
||||||
if (oldVersion < 52) MigrateSessionTo052(realm).perform()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ internal object PushersMapper {
|
|||||||
deviceDisplayName = pushEntity.deviceDisplayName,
|
deviceDisplayName = pushEntity.deviceDisplayName,
|
||||||
profileTag = pushEntity.profileTag,
|
profileTag = pushEntity.profileTag,
|
||||||
lang = pushEntity.lang,
|
lang = pushEntity.lang,
|
||||||
data = PusherData(pushEntity.data?.url, pushEntity.data?.format, pushEntity.data?.remoteWipeNonce),
|
data = PusherData(pushEntity.data?.url, pushEntity.data?.format),
|
||||||
enabled = pushEntity.enabled,
|
enabled = pushEntity.enabled,
|
||||||
deviceId = pushEntity.deviceId,
|
deviceId = pushEntity.deviceId,
|
||||||
state = pushEntity.state,
|
state = pushEntity.state,
|
||||||
@@ -48,11 +48,7 @@ internal object PushersMapper {
|
|||||||
deviceDisplayName = pusher.deviceDisplayName,
|
deviceDisplayName = pusher.deviceDisplayName,
|
||||||
profileTag = pusher.profileTag,
|
profileTag = pusher.profileTag,
|
||||||
lang = pusher.lang,
|
lang = pusher.lang,
|
||||||
data = PusherDataEntity(
|
data = PusherDataEntity(url = pusher.data?.url, format = pusher.data?.format),
|
||||||
url = pusher.data?.url,
|
|
||||||
format = pusher.data?.format,
|
|
||||||
remoteWipeNonce = pusher.data?.remoteWipeNonce
|
|
||||||
),
|
|
||||||
enabled = pusher.enabled,
|
enabled = pusher.enabled,
|
||||||
deviceId = pusher.deviceId,
|
deviceId = pusher.deviceId,
|
||||||
)
|
)
|
||||||
|
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2023 The Matrix.org Foundation C.I.C.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.database.migration
|
|
||||||
|
|
||||||
import io.realm.DynamicRealm
|
|
||||||
import org.matrix.android.sdk.internal.database.model.PusherDataEntityFields
|
|
||||||
import org.matrix.android.sdk.internal.util.database.RealmMigrator
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adding new field to PusherDataEntity.
|
|
||||||
*/
|
|
||||||
internal class MigrateSessionTo052(realm: DynamicRealm) : RealmMigrator(realm, 52) {
|
|
||||||
|
|
||||||
override fun doMigrate(realm: DynamicRealm) {
|
|
||||||
realm.schema.get("PusherDataEntity")
|
|
||||||
?.addField(PusherDataEntityFields.REMOTE_WIPE_NONCE, String::class.java)
|
|
||||||
}
|
|
||||||
}
|
|
@@ -19,8 +19,7 @@ import io.realm.RealmObject
|
|||||||
|
|
||||||
internal open class PusherDataEntity(
|
internal open class PusherDataEntity(
|
||||||
var url: String? = null,
|
var url: String? = null,
|
||||||
var format: String? = null,
|
var format: String? = null
|
||||||
var remoteWipeNonce: String? = null,
|
|
||||||
) : RealmObject() {
|
) : RealmObject() {
|
||||||
companion object
|
companion object
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,6 @@ import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
|
|||||||
import org.matrix.android.sdk.internal.network.RequestExecutor
|
import org.matrix.android.sdk.internal.network.RequestExecutor
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
import org.matrix.android.sdk.internal.task.Task
|
||||||
import org.matrix.android.sdk.internal.util.awaitTransaction
|
import org.matrix.android.sdk.internal.util.awaitTransaction
|
||||||
import timber.log.Timber
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface AddPusherTask : Task<AddPusherTask.Params, Unit> {
|
internal interface AddPusherTask : Task<AddPusherTask.Params, Unit> {
|
||||||
@@ -73,12 +72,10 @@ internal class DefaultAddPusherTask @Inject constructor(
|
|||||||
echo.profileTag = pusher.profileTag
|
echo.profileTag = pusher.profileTag
|
||||||
echo.data?.format = pusher.data?.format
|
echo.data?.format = pusher.data?.format
|
||||||
echo.data?.url = pusher.data?.url
|
echo.data?.url = pusher.data?.url
|
||||||
echo.data?.remoteWipeNonce = pusher.data?.remoteWipeNonce
|
|
||||||
echo.enabled = pusher.enabled
|
echo.enabled = pusher.enabled
|
||||||
echo.deviceId = pusher.deviceId
|
echo.deviceId = pusher.deviceId
|
||||||
echo.state = PusherState.REGISTERED
|
echo.state = PusherState.REGISTERED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Timber.d("## Remote wipe: registered pusher with nonce ${pusher.data?.remoteWipeNonce}")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -78,11 +78,7 @@ internal class DefaultPushersService @Inject constructor(
|
|||||||
lang = lang,
|
lang = lang,
|
||||||
appDisplayName = appDisplayName,
|
appDisplayName = appDisplayName,
|
||||||
deviceDisplayName = deviceDisplayName,
|
deviceDisplayName = deviceDisplayName,
|
||||||
data = JsonPusherData(
|
data = JsonPusherData(url, EVENT_ID_ONLY.takeIf { withEventIdOnly }),
|
||||||
url,
|
|
||||||
EVENT_ID_ONLY.takeIf { withEventIdOnly },
|
|
||||||
remoteWipeNonce = this.includeData["io.element.remote_wipe_nonce"]
|
|
||||||
),
|
|
||||||
append = append,
|
append = append,
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
deviceId = deviceId,
|
deviceId = deviceId,
|
||||||
|
@@ -35,8 +35,5 @@ internal data class JsonPusherData(
|
|||||||
val format: String? = null,
|
val format: String? = null,
|
||||||
|
|
||||||
@Json(name = "brand")
|
@Json(name = "brand")
|
||||||
val brand: String? = null,
|
val brand: String? = null
|
||||||
|
|
||||||
@Json(name = "io.element.remote_wipe_nonce")
|
|
||||||
val remoteWipeNonce: String? = null,
|
|
||||||
)
|
)
|
||||||
|
@@ -35,15 +35,7 @@ class EnsureFcmTokenIsRetrievedUseCase @Inject constructor(
|
|||||||
val currentSession = activeSessionHolder.getActiveSession()
|
val currentSession = activeSessionHolder.getActiveSession()
|
||||||
val currentPushers = currentSession.pushersService().getPushers()
|
val currentPushers = currentSession.pushersService().getPushers()
|
||||||
|
|
||||||
currentPushers.none {
|
currentPushers.none { it.pushKey == unifiedPushHelper.getEndpointOrToken() }
|
||||||
// Check the push key because device ID may not be supported by the home server
|
|
||||||
it.pushKey == unifiedPushHelper.getEndpointOrToken() &&
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// Is the home server guaranteed to store and return the data dictionary?
|
|
||||||
// If not, this check can never succeed.
|
|
||||||
it.data.remoteWipeNonce != null
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,6 @@ import im.vector.app.core.di.ActiveSessionHolder
|
|||||||
import im.vector.app.core.resources.AppNameProvider
|
import im.vector.app.core.resources.AppNameProvider
|
||||||
import im.vector.app.core.resources.LocaleProvider
|
import im.vector.app.core.resources.LocaleProvider
|
||||||
import im.vector.app.core.resources.StringProvider
|
import im.vector.app.core.resources.StringProvider
|
||||||
import im.vector.app.features.remotewipe.GenerateRemoteWipeNonceUseCase
|
|
||||||
import org.matrix.android.sdk.api.session.pushers.HttpPusher
|
import org.matrix.android.sdk.api.session.pushers.HttpPusher
|
||||||
import org.matrix.android.sdk.api.session.pushers.Pusher
|
import org.matrix.android.sdk.api.session.pushers.Pusher
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
@@ -38,7 +37,6 @@ class PushersManager @Inject constructor(
|
|||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
private val appNameProvider: AppNameProvider,
|
private val appNameProvider: AppNameProvider,
|
||||||
private val getDeviceInfoUseCase: GetDeviceInfoUseCase,
|
private val getDeviceInfoUseCase: GetDeviceInfoUseCase,
|
||||||
private val generateRemoteWipeNonceUseCase: GenerateRemoteWipeNonceUseCase,
|
|
||||||
) {
|
) {
|
||||||
suspend fun testPush() {
|
suspend fun testPush() {
|
||||||
val currentSession = activeSessionHolder.getActiveSession()
|
val currentSession = activeSessionHolder.getActiveSession()
|
||||||
@@ -79,9 +77,6 @@ class PushersManager @Inject constructor(
|
|||||||
deviceId = activeSessionHolder.getActiveSession().sessionParams.deviceId ?: "MOBILE",
|
deviceId = activeSessionHolder.getActiveSession().sessionParams.deviceId ?: "MOBILE",
|
||||||
append = false,
|
append = false,
|
||||||
withEventIdOnly = true,
|
withEventIdOnly = true,
|
||||||
includeData = mapOf(
|
|
||||||
"io.element.remote_wipe_nonce" to generateRemoteWipeNonceUseCase.generateNonce()
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun registerEmailForPush(email: String) {
|
suspend fun registerEmailForPush(email: String) {
|
||||||
|
@@ -71,11 +71,7 @@ class VectorUnifiedPushMessagingReceiver : MessagingReceiver() {
|
|||||||
if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) {
|
if (vectorPreferences.areNotificationEnabledForDevice() && activeSessionHolder.hasActiveSession()) {
|
||||||
// If the endpoint has changed
|
// If the endpoint has changed
|
||||||
// or the gateway has changed
|
// or the gateway has changed
|
||||||
// or the remote wipe nonce has not yet been set
|
if (unifiedPushHelper.getEndpointOrToken() != endpoint) {
|
||||||
if (
|
|
||||||
unifiedPushHelper.getEndpointOrToken() != endpoint ||
|
|
||||||
pushersManager.getPusherForCurrentSession()?.data?.remoteWipeNonce == null
|
|
||||||
) {
|
|
||||||
unifiedPushStore.storeUpEndpoint(endpoint)
|
unifiedPushStore.storeUpEndpoint(endpoint)
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
unifiedPushHelper.storeCustomOrDefaultGateway(endpoint) {
|
unifiedPushHelper.storeCustomOrDefaultGateway(endpoint) {
|
||||||
|
@@ -597,17 +597,6 @@ class HomeActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkNewAppLayoutFlagChange()
|
checkNewAppLayoutFlagChange()
|
||||||
|
|
||||||
activeSessionHolder.getActiveSession().also { session ->
|
|
||||||
val devicePusher = session.pushersService().getPushers().firstOrNull {
|
|
||||||
it.pushKey == unifiedPushHelper.getEndpointOrToken()
|
|
||||||
}
|
|
||||||
// TODO: Remove these logs
|
|
||||||
Timber.d("## Remote wipe: nonce is ${devicePusher?.data?.remoteWipeNonce}")
|
|
||||||
if (!unifiedPushHelper.isEmbeddedDistributor()) {
|
|
||||||
Timber.d("## Remote wipe: push key is ${devicePusher?.pushKey}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkNewAppLayoutFlagChange() {
|
private fun checkNewAppLayoutFlagChange() {
|
||||||
|
Reference in New Issue
Block a user