diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/pushers/PushersService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/pushers/PushersService.kt index 530bda9979..5f192c02f6 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/pushers/PushersService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/pushers/PushersService.kt @@ -33,13 +33,12 @@ interface PushersService { * @param pushkey This is a unique identifier for this pusher. The value you should use for * this is the routing or destination address information for the notification, * for example, the APNS token for APNS or the Registration ID for GCM. If your - * notification client has no such concept, use any unique identifier. Max length, 512 bytes. + * notification client has no such concept, use any unique identifier. Max length, 512 chars. * If the kind is "email", this is the email address to send notifications to. * @param appId the application id * This is a reverse-DNS style identifier for the application. It is recommended * that this end with the platform, such that different platform versions get * different app identifiers. Max length, 64 chars. - * If the kind is "email", this is "m.email". * @param profileTag This string determines which set of device specific rules this pusher executes. * @param lang The preferred language for receiving notifications (e.g. "en" or "en-US"). * @param appDisplayName A human readable string that will allow the user to identify what application owns this pusher. @@ -52,6 +51,7 @@ interface PushersService { * Ref: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour * * @return A work request uuid. Can be used to listen to the status + * @throws [InvalidParameterException] if a parameter is not correct * (LiveData status = workManager.getWorkInfoByIdLiveData()) */ fun addHttpPusher(pushkey: String, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/pushers/DefaultPusherService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/pushers/DefaultPusherService.kt index 8b4cce5eb0..f7e154e18b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/pushers/DefaultPusherService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/pushers/DefaultPusherService.kt @@ -29,6 +29,7 @@ import im.vector.matrix.android.internal.di.WorkManagerProvider import im.vector.matrix.android.internal.task.TaskExecutor import im.vector.matrix.android.internal.task.configureWith import im.vector.matrix.android.internal.worker.WorkerParamsFactory +import java.security.InvalidParameterException import java.util.UUID import java.util.concurrent.TimeUnit import javax.inject.Inject @@ -58,6 +59,11 @@ internal class DefaultPusherService @Inject constructor( append: Boolean, withEventIdOnly: Boolean) : UUID { + // Do some parameter checks. It's ok to throw Exception, to inform developer of the problem + if (pushkey.length > 512) throw InvalidParameterException("pushkey should not exceed 512 chars") + if (appId.length > 64) throw InvalidParameterException("appId should not exceed 64 chars") + if ("/_matrix/push/v1/notify" !in url) throw InvalidParameterException("url should contain '/_matrix/push/v1/notify'") + val pusher = JsonPusher( pushKey = pushkey, kind = "http", diff --git a/vector/src/main/java/im/vector/riotx/core/pushers/PushersManager.kt b/vector/src/main/java/im/vector/riotx/core/pushers/PushersManager.kt index e2c08a1fe8..aa1fbaca54 100644 --- a/vector/src/main/java/im/vector/riotx/core/pushers/PushersManager.kt +++ b/vector/src/main/java/im/vector/riotx/core/pushers/PushersManager.kt @@ -47,8 +47,8 @@ class PushersManager @Inject constructor( appNameProvider.getAppName(), currentSession.sessionParams.credentials.deviceId ?: "MOBILE", stringProvider.getString(R.string.pusher_http_url), - false, - true + append = false, + withEventIdOnly = true ) } diff --git a/vector/src/main/res/values/config.xml b/vector/src/main/res/values/config.xml index 9d653b67dd..764dea6786 100755 --- a/vector/src/main/res/values/config.xml +++ b/vector/src/main/res/values/config.xml @@ -13,7 +13,9 @@ https://matrix.org/docs/spec/client_server/r0.4.0#id128 --> + https://matrix.org/_matrix/push/v1/notify + im.vector.app.android