mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 16:21:24 +01:00
use event content in account_data service api instead of full events
This eliminates the possibility of passing an event that has a mismatching type, reducing the space of possible invalid states.
This commit is contained in:
parent
66210bc32d
commit
b82458a460
15 changed files with 277 additions and 240 deletions
|
|
@ -5,7 +5,7 @@ use regex::Regex;
|
|||
use ruma::{
|
||||
api::appservice::Registration,
|
||||
events::{
|
||||
push_rules::{PushRulesEvent, PushRulesEventContent},
|
||||
push_rules::PushRulesEventContent,
|
||||
room::{
|
||||
canonical_alias::RoomCanonicalAliasEventContent,
|
||||
create::RoomCreateEventContent,
|
||||
|
|
@ -20,7 +20,7 @@ use ruma::{
|
|||
power_levels::RoomPowerLevelsEventContent,
|
||||
topic::RoomTopicEventContent,
|
||||
},
|
||||
AnyGlobalAccountDataEvent, TimelineEventType,
|
||||
TimelineEventType,
|
||||
},
|
||||
serde::Raw,
|
||||
signatures::verify_json,
|
||||
|
|
@ -774,15 +774,15 @@ impl Service {
|
|||
services().account_data.update_global(
|
||||
&user_id,
|
||||
&ruma::events::GlobalAccountDataEventType::PushRules,
|
||||
&Raw::new(&PushRulesEvent {
|
||||
content: PushRulesEventContent {
|
||||
&Raw::new(
|
||||
&PushRulesEventContent {
|
||||
global: ruma::push::Ruleset::server_default(
|
||||
&user_id,
|
||||
),
|
||||
},
|
||||
})
|
||||
.expect("json serialization should always succeed")
|
||||
.cast::<AnyGlobalAccountDataEvent>(),
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
.expect("json serialization should always succeed"),
|
||||
)?;
|
||||
|
||||
// we dont add a device since we're not the user, just the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue