mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 16:21:24 +01:00
separate account_data service methods for room vs global events
Previously we were mashing everything together as RoomAccountDataEvent, even the global events. This technically worked, because of the hidden custom fields on the ruma event types, but it's confusing and easy to mess up. Separate methods with appropriate types are preferable.
This commit is contained in:
parent
6897f0ba34
commit
66210bc32d
16 changed files with 349 additions and 361 deletions
|
|
@ -20,8 +20,9 @@ use ruma::{
|
|||
power_levels::RoomPowerLevelsEventContent,
|
||||
topic::RoomTopicEventContent,
|
||||
},
|
||||
TimelineEventType,
|
||||
AnyGlobalAccountDataEvent, TimelineEventType,
|
||||
},
|
||||
serde::Raw,
|
||||
signatures::verify_json,
|
||||
EventId, MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomId,
|
||||
OwnedServerName, RoomId, RoomVersionId, ServerName, UserId,
|
||||
|
|
@ -770,20 +771,18 @@ impl Service {
|
|||
.set_displayname(&user_id, Some(displayname))?;
|
||||
|
||||
// Initial account data
|
||||
services().account_data.update(
|
||||
None,
|
||||
services().account_data.update_global(
|
||||
&user_id,
|
||||
ruma::events::GlobalAccountDataEventType::PushRules
|
||||
.to_string()
|
||||
.into(),
|
||||
&serde_json::to_value(PushRulesEvent {
|
||||
&ruma::events::GlobalAccountDataEventType::PushRules,
|
||||
&Raw::new(&PushRulesEvent {
|
||||
content: PushRulesEventContent {
|
||||
global: ruma::push::Ruleset::server_default(
|
||||
&user_id,
|
||||
),
|
||||
},
|
||||
})
|
||||
.expect("to json value always works"),
|
||||
.expect("json serialization should always succeed")
|
||||
.cast::<AnyGlobalAccountDataEvent>(),
|
||||
)?;
|
||||
|
||||
// we dont add a device since we're not the user, just the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue