Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PushRule enabling request is not following the spec #3914

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3911.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PushRule enabling request is not following the spec
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
internal class GetPushersResponse(
internal data class GetPushersResponse(
@Json(name = "pushers")
val pushers: List<JsonPusher>? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal interface PushRulesApi {
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "pushrules/global/{kind}/{ruleId}/enabled")
suspend fun updateEnableRuleStatus(@Path("kind") kind: String,
@Path("ruleId") ruleId: String,
@Body enable: Boolean?)
@Body enabledBody: EnabledBody)

/**
* Update the ruleID action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ internal class DefaultUpdatePushRuleActionsTask @Inject constructor(

override suspend fun execute(params: UpdatePushRuleActionsTask.Params) {
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) {
val body = mapOf("actions" to params.actions.toJson())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ internal class DefaultUpdatePushRuleEnableStatusTask @Inject constructor(

override suspend fun execute(params: UpdatePushRuleEnableStatusTask.Params) {
return executeRequest(globalErrorReceiver) {
pushRulesApi.updateEnableRuleStatus(params.kind.value, params.pushRule.ruleId, params.enabled)
pushRulesApi.updateEnableRuleStatus(
params.kind.value,
params.pushRule.ruleId,
EnabledBody(params.enabled)
)
}
}
}