improvement: set default push rules on register

This commit is contained in:
timokoesters 2020-05-02 09:24:09 +02:00
parent 3cd0f89729
commit 4b191a9311
No known key found for this signature in database
GPG key ID: 356E705610F626D5
2 changed files with 34 additions and 1 deletions

View file

@ -168,6 +168,39 @@ pub fn register_route(
let token = utils::random_string(TOKEN_LENGTH);
data.token_replace(&user_id, &device_id, token.clone());
// Initial data
data.room_userdata_update(
None,
&user_id,
EduEvent::PushRules(ruma_events::push_rules::PushRulesEvent {
content: ruma_events::push_rules::PushRulesEventContent {
global: ruma_events::push_rules::Ruleset {
content: vec![],
override_rules: vec![],
room: vec![],
sender: vec![],
underride: vec![ruma_events::push_rules::ConditionalPushRule {
actions: vec![
ruma_events::push_rules::Action::Notify,
ruma_events::push_rules::Action::SetTweak(
ruma_events::push_rules::Tweak::Highlight { value: false },
),
],
default: true,
enabled: true,
rule_id: ".m.rule.message".to_owned(),
conditions: vec![ruma_events::push_rules::PushCondition::EventMatch(
ruma_events::push_rules::EventMatchCondition {
key: "type".to_owned(),
pattern: "m.room.message".to_owned(),
},
)],
}],
},
},
}),
);
MatrixResult(Ok(register::Response {
access_token: Some(token),
user_id,

View file

@ -92,7 +92,7 @@ impl<'a, T: Endpoint> FromData<'a> for Ruma<T> {
}),
Err(e) => {
warn!("{:?}", e);
Failure((Status::InternalServerError, ()))
Failure((Status::BadRequest, ()))
}
}
})