From 63196aa6aa8d429a90b87d4e6b7c5a198b93fcf0 Mon Sep 17 00:00:00 2001 From: Nicolas Mauri Date: Fri, 25 Aug 2023 17:11:49 +0200 Subject: [PATCH] fix(sdk): limit the number of retries when updating push rules. (#2461) * fix(sdk): limit the number of retries when updating push rules. * fix Rust format --- .../matrix-sdk/src/notification_settings/mod.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/matrix-sdk/src/notification_settings/mod.rs b/crates/matrix-sdk/src/notification_settings/mod.rs index 1ae939ebc..6c423d29e 100644 --- a/crates/matrix-sdk/src/notification_settings/mod.rs +++ b/crates/matrix-sdk/src/notification_settings/mod.rs @@ -18,7 +18,10 @@ mod command; mod rule_commands; mod rules; -use crate::{error::NotificationSettingsError, event_handler::EventHandlerHandle, Client, Result}; +use crate::{ + config::RequestConfig, error::NotificationSettingsError, event_handler::EventHandlerHandle, + Client, Result, +}; /// Enum representing the push notification modes for a room. #[derive(Debug, Clone, PartialEq)] @@ -324,6 +327,7 @@ impl NotificationSettings { &self, rule_commands: &RuleCommands, ) -> Result<(), NotificationSettingsError> { + let request_config = Some(RequestConfig::short_retry()); for command in &rule_commands.commands { match command { Command::DeletePushRule { scope, kind, rule_id } => { @@ -333,7 +337,7 @@ impl NotificationSettings { rule_id.clone(), ); self.client - .send(request, None) + .send(request, request_config) .await .map_err(|_| NotificationSettingsError::UnableToRemovePushRule)?; } @@ -341,7 +345,7 @@ impl NotificationSettings { let push_rule = command.to_push_rule()?; let request = set_pushrule::v3::Request::new(scope.clone(), push_rule); self.client - .send(request, None) + .send(request, request_config) .await .map_err(|_| NotificationSettingsError::UnableToAddPushRule)?; } @@ -349,7 +353,7 @@ impl NotificationSettings { let push_rule = command.to_push_rule()?; let request = set_pushrule::v3::Request::new(scope.clone(), push_rule); self.client - .send(request, None) + .send(request, request_config) .await .map_err(|_| NotificationSettingsError::UnableToAddPushRule)?; } @@ -361,7 +365,7 @@ impl NotificationSettings { *enabled, ); self.client - .send(request, None) + .send(request, request_config) .await .map_err(|_| NotificationSettingsError::UnableToUpdatePushRule)?; } @@ -373,7 +377,7 @@ impl NotificationSettings { actions.clone(), ); self.client - .send(request, None) + .send(request, request_config) .await .map_err(|_| NotificationSettingsError::UnableToUpdatePushRule)?; }