matrix-sdk: Propagate store error in get_push_rules
parent
c569436ba4
commit
24e96df7ea
|
@ -788,7 +788,7 @@ impl BaseClient {
|
||||||
self.handle_account_data(account_data.events, &mut changes)
|
self.handle_account_data(account_data.events, &mut changes)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let push_rules = self.get_push_rules(&changes).await;
|
let push_rules = self.get_push_rules(&changes).await?;
|
||||||
|
|
||||||
let mut new_rooms = Rooms::default();
|
let mut new_rooms = Rooms::default();
|
||||||
|
|
||||||
|
@ -1387,23 +1387,22 @@ impl BaseClient {
|
||||||
/// Get the push rules.
|
/// Get the push rules.
|
||||||
///
|
///
|
||||||
/// Gets the push rules from `changes` if they have been updated, otherwise get them from the
|
/// Gets the push rules from `changes` if they have been updated, otherwise get them from the
|
||||||
/// store. As a fallback, uses `Ruleset::server_default`.
|
/// store. As a fallback, uses `Ruleset::server_default` if the user is logged in.
|
||||||
pub async fn get_push_rules(&self, changes: &StateChanges) -> Ruleset {
|
pub async fn get_push_rules(&self, changes: &StateChanges) -> Result<Ruleset> {
|
||||||
if let Some(AnyBasicEvent::PushRules(event)) =
|
if let Some(AnyBasicEvent::PushRules(event)) =
|
||||||
changes.account_data.get(&EventType::PushRules.to_string())
|
changes.account_data.get(&EventType::PushRules.to_string())
|
||||||
{
|
{
|
||||||
event.content.global.clone()
|
Ok(event.content.global.clone())
|
||||||
} else if let Some(AnyBasicEvent::PushRules(event)) = self
|
} else if let Some(AnyBasicEvent::PushRules(event)) = self
|
||||||
.store
|
.store
|
||||||
.get_account_data_event(EventType::PushRules)
|
.get_account_data_event(EventType::PushRules)
|
||||||
.await
|
.await?
|
||||||
.unwrap()
|
|
||||||
{
|
{
|
||||||
event.content.global
|
Ok(event.content.global)
|
||||||
|
} else if let Some(session) = self.get_session().await {
|
||||||
|
Ok(Ruleset::server_default(&session.user_id))
|
||||||
} else {
|
} else {
|
||||||
// FIXME don't panic if the user is not logged in?
|
Ok(Ruleset::new())
|
||||||
let session = self.get_session().await.unwrap();
|
|
||||||
Ruleset::server_default(&session.user_id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue