summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKévin Commaille <zecakeh@tedomum.fr>2023-02-26 17:49:42 +0100
committerKévin Commaille <zecakeh@tedomum.fr>2023-03-18 15:03:57 +0100
commit88c6bf75954ead182fffc900585b418b018e98e0 (patch)
tree413bfc986caaceb99941019bb5763ada5f250b2f /src
parent4635644e21cfdefd076d011d4f747b37d10da5b2 (diff)
downloadconduit-88c6bf75954ead182fffc900585b418b018e98e0.zip
Always return an error if a push rule is not found
Diffstat (limited to 'src')
-rw-r--r--src/api/client_server/push.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/api/client_server/push.rs b/src/api/client_server/push.rs
index ab7c686..7276866 100644
--- a/src/api/client_server/push.rs
+++ b/src/api/client_server/push.rs
@@ -187,11 +187,13 @@ pub async fn get_pushrule_actions_route(
let global = account_data.global;
let actions = global
.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 {
- actions: actions.unwrap_or_default(),
- })
+ Ok(get_pushrule_actions::v3::Response { actions })
}
/// # `PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions`
@@ -280,7 +282,10 @@ pub async fn get_pushrule_enabled_route(
let enabled = global
.get(body.kind.clone(), &body.rule_id)
.map(|r| r.enabled())
- .unwrap_or_default();
+ .ok_or(Error::BadRequest(
+ ErrorKind::NotFound,
+ "Push rule not found.",
+ ))?;
Ok(get_pushrule_enabled::v3::Response { enabled })
}