mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 08:11:24 +01:00
Properly type stored EDUs
This commit is contained in:
parent
26322d5a95
commit
cce83beedb
3 changed files with 29 additions and 20 deletions
|
|
@ -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"),
|
||||
)
|
||||
},
|
||||
))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue