Properly type stored EDUs

This commit is contained in:
Lambda 2024-08-26 17:10:43 +00:00
parent 26322d5a95
commit cce83beedb
3 changed files with 29 additions and 20 deletions

View file

@ -1,4 +1,4 @@
use ruma::{ServerName, UserId};
use ruma::{serde::Raw, ServerName, UserId};
use crate::{
database::KeyValueDatabase,
@ -69,7 +69,7 @@ impl service::sending::Data for KeyValueDatabase {
);
}
let value = if let SendingEventType::Edu(value) = &event {
&**value
value.json().get().as_bytes()
} else {
&[]
};
@ -100,7 +100,7 @@ impl service::sending::Data for KeyValueDatabase {
) -> Result<()> {
for (e, key) in events {
let value = if let SendingEventType::Edu(value) = &e {
&**value
value.json().get().as_bytes()
} else {
&[]
};
@ -205,7 +205,13 @@ fn parse_servercurrentevent(
if value.is_empty() {
SendingEventType::Pdu(PduId::new(event.to_vec()))
} else {
SendingEventType::Edu(value)
SendingEventType::Edu(
Raw::from_json_string(
String::from_utf8(value)
.expect("EDU content in database should be a string"),
)
.expect("EDU content in database should be valid JSON"),
)
},
))
}