Skip to content
Snippets Groups Projects
Unverified Commit 88c6bf75 authored by Kévin Commaille's avatar Kévin Commaille
Browse files

Always return an error if a push rule is not found

parent 4635644e
No related branches found
No related tags found
No related merge requests found
...@@ -187,11 +187,13 @@ pub async fn get_pushrule_actions_route( ...@@ -187,11 +187,13 @@ pub async fn get_pushrule_actions_route(
let global = account_data.global; let global = account_data.global;
let actions = global let actions = global
.get(body.kind.clone(), &body.rule_id) .get(body.kind.clone(), &body.rule_id)
.map(|rule| rule.actions().to_owned()); .map(|rule| rule.actions().to_owned())
.ok_or(Error::BadRequest(
ErrorKind::NotFound,
"Push rule not found.",
))?;
Ok(get_pushrule_actions::v3::Response { Ok(get_pushrule_actions::v3::Response { actions })
actions: actions.unwrap_or_default(),
})
} }
/// # `PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions` /// # `PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions`
...@@ -280,7 +282,10 @@ pub async fn get_pushrule_enabled_route( ...@@ -280,7 +282,10 @@ pub async fn get_pushrule_enabled_route(
let enabled = global let enabled = global
.get(body.kind.clone(), &body.rule_id) .get(body.kind.clone(), &body.rule_id)
.map(|r| r.enabled()) .map(|r| r.enabled())
.unwrap_or_default(); .ok_or(Error::BadRequest(
ErrorKind::NotFound,
"Push rule not found.",
))?;
Ok(get_pushrule_enabled::v3::Response { enabled }) Ok(get_pushrule_enabled::v3::Response { enabled })
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment