Merge pull request #8006 from vector-im/feature/mna/push-rules-api-order

[Push rules] Call /actions api before /enabled api (PSG-1099)
This commit is contained in:
Maxime NATUREL 2023-01-26 16:46:07 +01:00 committed by GitHub
commit 00c90c19d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

1
changelog.d/8005.sdk Normal file
View File

@ -0,0 +1 @@
[Push rules] Call /actions api before /enabled api

View File

@ -34,10 +34,16 @@ internal interface UpdatePushRuleActionsTask : Task<UpdatePushRuleActionsTask.Pa
internal class DefaultUpdatePushRuleActionsTask @Inject constructor(
private val pushRulesApi: PushRulesApi,
private val globalErrorReceiver: GlobalErrorReceiver
private val globalErrorReceiver: GlobalErrorReceiver,
) : UpdatePushRuleActionsTask {
override suspend fun execute(params: UpdatePushRuleActionsTask.Params) {
if (params.actions != null) {
val body = mapOf("actions" to params.actions.toJson())
executeRequest(globalErrorReceiver) {
pushRulesApi.updateRuleActions(params.kind.value, params.ruleId, body)
}
}
executeRequest(globalErrorReceiver) {
pushRulesApi.updateEnableRuleStatus(
params.kind.value,
@ -45,11 +51,5 @@ internal class DefaultUpdatePushRuleActionsTask @Inject constructor(
EnabledBody(params.enable)
)
}
if (params.actions != null) {
val body = mapOf("actions" to params.actions.toJson())
executeRequest(globalErrorReceiver) {
pushRulesApi.updateRuleActions(params.kind.value, params.ruleId, body)
}
}
}
}