Merge pull request #3914 from vector-im/feature/bma/enabled_body

PushRule enabling request is not following the spec
This commit is contained in:
Benoit Marty 2021-08-27 16:58:51 +02:00 committed by GitHub
commit 048800684c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 4 deletions

1
changelog.d/3911.bugfix Normal file
View file

@ -0,0 +1 @@
PushRule enabling request is not following the spec

View file

@ -0,0 +1,25 @@
/*
* Copyright 2021 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.session.pushers
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
internal data class EnabledBody(
@Json(name = "enabled")
val enabled: Boolean
)

View file

@ -19,7 +19,7 @@ import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true) @JsonClass(generateAdapter = true)
internal class GetPushersResponse( internal data class GetPushersResponse(
@Json(name = "pushers") @Json(name = "pushers")
val pushers: List<JsonPusher>? = null val pushers: List<JsonPusher>? = null
) )

View file

@ -41,7 +41,7 @@ internal interface PushRulesApi {
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/enabled") @PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/enabled")
suspend fun updateEnableRuleStatus(@Path("kind") kind: String, suspend fun updateEnableRuleStatus(@Path("kind") kind: String,
@Path("ruleId") ruleId: String, @Path("ruleId") ruleId: String,
@Body enable: Boolean?) @Body enabledBody: EnabledBody)
/** /**
* Update the ruleID action * Update the ruleID action

View file

@ -39,7 +39,11 @@ internal class DefaultUpdatePushRuleActionsTask @Inject constructor(
override suspend fun execute(params: UpdatePushRuleActionsTask.Params) { override suspend fun execute(params: UpdatePushRuleActionsTask.Params) {
executeRequest(globalErrorReceiver) { executeRequest(globalErrorReceiver) {
pushRulesApi.updateEnableRuleStatus(params.kind.value, params.ruleId, enable = params.enable) pushRulesApi.updateEnableRuleStatus(
params.kind.value,
params.ruleId,
EnabledBody(params.enable)
)
} }
if (params.actions != null) { if (params.actions != null) {
val body = mapOf("actions" to params.actions.toJson()) val body = mapOf("actions" to params.actions.toJson())

View file

@ -35,7 +35,11 @@ internal class DefaultUpdatePushRuleEnableStatusTask @Inject constructor(
override suspend fun execute(params: UpdatePushRuleEnableStatusTask.Params) { override suspend fun execute(params: UpdatePushRuleEnableStatusTask.Params) {
return executeRequest(globalErrorReceiver) { return executeRequest(globalErrorReceiver) {
pushRulesApi.updateEnableRuleStatus(params.kind.value, params.pushRule.ruleId, params.enabled) pushRulesApi.updateEnableRuleStatus(
params.kind.value,
params.pushRule.ruleId,
EnabledBody(params.enabled)
)
} }
} }
} }