Implements MSC3881 (enabled and device_id fields for Pusher API)
This commit is contained in:
parent
feb33ce32b
commit
75935c824b
@ -58,6 +58,10 @@ data class HttpPusher(
|
|||||||
*/
|
*/
|
||||||
val url: String,
|
val url: String,
|
||||||
|
|
||||||
|
val enabled: Boolean,
|
||||||
|
|
||||||
|
val deviceId: String,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, the homeserver should add another pusher with the given pushkey and App ID in addition
|
* If true, the homeserver should add another pusher with the given pushkey and App ID in addition
|
||||||
* to any others with different user IDs. Otherwise, the homeserver must remove any other pushers
|
* to any others with different user IDs. Otherwise, the homeserver must remove any other pushers
|
||||||
|
@ -24,8 +24,9 @@ data class Pusher(
|
|||||||
val profileTag: String? = null,
|
val profileTag: String? = null,
|
||||||
val lang: String?,
|
val lang: String?,
|
||||||
val data: PusherData,
|
val data: PusherData,
|
||||||
|
val enabled: Boolean,
|
||||||
val state: PusherState
|
val deviceId: String?,
|
||||||
|
val state: PusherState,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
@ -33,7 +33,9 @@ internal object PushersMapper {
|
|||||||
profileTag = pushEntity.profileTag,
|
profileTag = pushEntity.profileTag,
|
||||||
lang = pushEntity.lang,
|
lang = pushEntity.lang,
|
||||||
data = PusherData(pushEntity.data?.url, pushEntity.data?.format),
|
data = PusherData(pushEntity.data?.url, pushEntity.data?.format),
|
||||||
state = pushEntity.state
|
enabled = pushEntity.enabled,
|
||||||
|
deviceId = pushEntity.deviceId,
|
||||||
|
state = pushEntity.state,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +48,9 @@ internal object PushersMapper {
|
|||||||
deviceDisplayName = pusher.deviceDisplayName,
|
deviceDisplayName = pusher.deviceDisplayName,
|
||||||
profileTag = pusher.profileTag,
|
profileTag = pusher.profileTag,
|
||||||
lang = pusher.lang,
|
lang = pusher.lang,
|
||||||
data = PusherDataEntity(pusher.data?.url, pusher.data?.format)
|
data = PusherDataEntity(pusher.data?.url, pusher.data?.format),
|
||||||
|
enabled = pusher.enabled,
|
||||||
|
deviceId = pusher.deviceId,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,15 +18,6 @@ package org.matrix.android.sdk.internal.database.model
|
|||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
import org.matrix.android.sdk.api.session.pushers.PusherState
|
import org.matrix.android.sdk.api.session.pushers.PusherState
|
||||||
|
|
||||||
// TODO
|
|
||||||
// at java.lang.Thread.run(Thread.java:764)
|
|
||||||
// Caused by: java.lang.IllegalArgumentException: 'value' is not a valid managed object.
|
|
||||||
// at io.realm.ProxyState.checkValidObject(ProxyState.java:213)
|
|
||||||
// at io.realm.im_vector_matrix_android_internal_database_model_PusherEntityRealmProxy
|
|
||||||
// .realmSet$data(im_vector_matrix_android_internal_database_model_PusherEntityRealmProxy.java:413)
|
|
||||||
// at org.matrix.android.sdk.internal.database.model.PusherEntity.setData(PusherEntity.kt:16)
|
|
||||||
// at org.matrix.android.sdk.internal.session.pushers.AddHttpPusherWorker$doWork$$inlined$fold$lambda$2.execute(AddHttpPusherWorker.kt:70)
|
|
||||||
// at io.realm.Realm.executeTransaction(Realm.java:1493)
|
|
||||||
internal open class PusherEntity(
|
internal open class PusherEntity(
|
||||||
var pushKey: String = "",
|
var pushKey: String = "",
|
||||||
var kind: String? = null,
|
var kind: String? = null,
|
||||||
@ -35,7 +26,9 @@ internal open class PusherEntity(
|
|||||||
var deviceDisplayName: String? = null,
|
var deviceDisplayName: String? = null,
|
||||||
var profileTag: String? = null,
|
var profileTag: String? = null,
|
||||||
var lang: String? = null,
|
var lang: String? = null,
|
||||||
var data: PusherDataEntity? = null
|
var data: PusherDataEntity? = null,
|
||||||
|
var enabled: Boolean = true,
|
||||||
|
var deviceId: String? = null,
|
||||||
) : RealmObject() {
|
) : RealmObject() {
|
||||||
private var stateStr: String = PusherState.UNREGISTERED.name
|
private var stateStr: String = PusherState.UNREGISTERED.name
|
||||||
|
|
||||||
|
@ -71,6 +71,8 @@ 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.enabled = pusher.enabled
|
||||||
|
echo.deviceId = pusher.deviceId
|
||||||
echo.state = PusherState.REGISTERED
|
echo.state = PusherState.REGISTERED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,9 @@ internal class DefaultPushersService @Inject constructor(
|
|||||||
appDisplayName = appDisplayName,
|
appDisplayName = appDisplayName,
|
||||||
deviceDisplayName = deviceDisplayName,
|
deviceDisplayName = deviceDisplayName,
|
||||||
data = JsonPusherData(url, EVENT_ID_ONLY.takeIf { withEventIdOnly }),
|
data = JsonPusherData(url, EVENT_ID_ONLY.takeIf { withEventIdOnly }),
|
||||||
append = append
|
append = append,
|
||||||
|
enabled = enabled,
|
||||||
|
deviceId = deviceId,
|
||||||
)
|
)
|
||||||
|
|
||||||
override suspend fun addEmailPusher(
|
override suspend fun addEmailPusher(
|
||||||
|
@ -33,6 +33,8 @@ import java.security.InvalidParameterException
|
|||||||
* "device_display_name": "Alice's Phone",
|
* "device_display_name": "Alice's Phone",
|
||||||
* "profile_tag": "xyz",
|
* "profile_tag": "xyz",
|
||||||
* "lang": "en-US",
|
* "lang": "en-US",
|
||||||
|
* "enabled": true,
|
||||||
|
* "device_id": "abc123",
|
||||||
* "data": {
|
* "data": {
|
||||||
* "url": "https://example.com/_matrix/push/v1/notify"
|
* "url": "https://example.com/_matrix/push/v1/notify"
|
||||||
* }
|
* }
|
||||||
@ -112,7 +114,19 @@ internal data class JsonPusher(
|
|||||||
* The default is false.
|
* The default is false.
|
||||||
*/
|
*/
|
||||||
@Json(name = "append")
|
@Json(name = "append")
|
||||||
val append: Boolean? = false
|
val append: Boolean? = false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the pusher should actively create push notifications
|
||||||
|
*/
|
||||||
|
@Json(name = "org.matrix.msc3881.enabled")
|
||||||
|
val enabled: Boolean = false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The device_id of the session that registered the pusher
|
||||||
|
*/
|
||||||
|
@Json(name = "org.matrix.msc3881.device_id")
|
||||||
|
val deviceId: String? = null,
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
// Do some parameter checks. It's ok to throw Exception, to inform developer of the problem
|
// Do some parameter checks. It's ok to throw Exception, to inform developer of the problem
|
||||||
|
@ -70,6 +70,8 @@ class PushersManager @Inject constructor(
|
|||||||
appNameProvider.getAppName(),
|
appNameProvider.getAppName(),
|
||||||
activeSessionHolder.getActiveSession().sessionParams.deviceId ?: "MOBILE",
|
activeSessionHolder.getActiveSession().sessionParams.deviceId ?: "MOBILE",
|
||||||
gateway,
|
gateway,
|
||||||
|
enabled = true,
|
||||||
|
deviceId = activeSessionHolder.getActiveSession().sessionParams.deviceId ?: "MOBILE",
|
||||||
append = false,
|
append = false,
|
||||||
withEventIdOnly = true
|
withEventIdOnly = true
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user