mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-17 13:50:49 +01:00
Always return an error if a push rule is not found
This commit is contained in:
parent
4635644e21
commit
88c6bf7595
1 changed files with 10 additions and 5 deletions
|
@ -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(
|
||||||
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 })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue