mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-11-17 13:10:50 +01:00
fix: don't send nulls as unsigned content
This commit is contained in:
parent
2aa0a2474b
commit
2a16a5e967
1 changed files with 24 additions and 9 deletions
|
@ -111,9 +111,11 @@ impl PduEvent {
|
||||||
"event_id": self.event_id,
|
"event_id": self.event_id,
|
||||||
"sender": self.sender,
|
"sender": self.sender,
|
||||||
"origin_server_ts": self.origin_server_ts,
|
"origin_server_ts": self.origin_server_ts,
|
||||||
"unsigned": self.unsigned,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if let Some(unsigned) = &self.unsigned {
|
||||||
|
json["unsigned"] = json!(unsigned);
|
||||||
|
}
|
||||||
if let Some(state_key) = &self.state_key {
|
if let Some(state_key) = &self.state_key {
|
||||||
json["state_key"] = json!(state_key);
|
json["state_key"] = json!(state_key);
|
||||||
}
|
}
|
||||||
|
@ -133,10 +135,12 @@ impl PduEvent {
|
||||||
"event_id": self.event_id,
|
"event_id": self.event_id,
|
||||||
"sender": self.sender,
|
"sender": self.sender,
|
||||||
"origin_server_ts": self.origin_server_ts,
|
"origin_server_ts": self.origin_server_ts,
|
||||||
"unsigned": self.unsigned,
|
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if let Some(unsigned) = &self.unsigned {
|
||||||
|
json["unsigned"] = json!(unsigned);
|
||||||
|
}
|
||||||
if let Some(state_key) = &self.state_key {
|
if let Some(state_key) = &self.state_key {
|
||||||
json["state_key"] = json!(state_key);
|
json["state_key"] = json!(state_key);
|
||||||
}
|
}
|
||||||
|
@ -155,10 +159,12 @@ impl PduEvent {
|
||||||
"event_id": self.event_id,
|
"event_id": self.event_id,
|
||||||
"sender": self.sender,
|
"sender": self.sender,
|
||||||
"origin_server_ts": self.origin_server_ts,
|
"origin_server_ts": self.origin_server_ts,
|
||||||
"unsigned": self.unsigned,
|
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if let Some(unsigned) = &self.unsigned {
|
||||||
|
json["unsigned"] = json!(unsigned);
|
||||||
|
}
|
||||||
if let Some(state_key) = &self.state_key {
|
if let Some(state_key) = &self.state_key {
|
||||||
json["state_key"] = json!(state_key);
|
json["state_key"] = json!(state_key);
|
||||||
}
|
}
|
||||||
|
@ -171,32 +177,38 @@ impl PduEvent {
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub fn to_state_event(&self) -> Raw<AnyStateEvent> {
|
pub fn to_state_event(&self) -> Raw<AnyStateEvent> {
|
||||||
let json = json!({
|
let mut json = json!({
|
||||||
"content": self.content,
|
"content": self.content,
|
||||||
"type": self.kind,
|
"type": self.kind,
|
||||||
"event_id": self.event_id,
|
"event_id": self.event_id,
|
||||||
"sender": self.sender,
|
"sender": self.sender,
|
||||||
"origin_server_ts": self.origin_server_ts,
|
"origin_server_ts": self.origin_server_ts,
|
||||||
"unsigned": self.unsigned,
|
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
"state_key": self.state_key,
|
"state_key": self.state_key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if let Some(unsigned) = &self.unsigned {
|
||||||
|
json["unsigned"] = json!(unsigned);
|
||||||
|
}
|
||||||
|
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub fn to_sync_state_event(&self) -> Raw<AnySyncStateEvent> {
|
pub fn to_sync_state_event(&self) -> Raw<AnySyncStateEvent> {
|
||||||
let json = json!({
|
let mut json = json!({
|
||||||
"content": self.content,
|
"content": self.content,
|
||||||
"type": self.kind,
|
"type": self.kind,
|
||||||
"event_id": self.event_id,
|
"event_id": self.event_id,
|
||||||
"sender": self.sender,
|
"sender": self.sender,
|
||||||
"origin_server_ts": self.origin_server_ts,
|
"origin_server_ts": self.origin_server_ts,
|
||||||
"unsigned": self.unsigned,
|
|
||||||
"state_key": self.state_key,
|
"state_key": self.state_key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if let Some(unsigned) = &self.unsigned {
|
||||||
|
json["unsigned"] = json!(unsigned);
|
||||||
|
}
|
||||||
|
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,18 +226,21 @@ impl PduEvent {
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
pub fn to_member_event(&self) -> Raw<StateEvent<RoomMemberEventContent>> {
|
pub fn to_member_event(&self) -> Raw<StateEvent<RoomMemberEventContent>> {
|
||||||
let json = json!({
|
let mut json = json!({
|
||||||
"content": self.content,
|
"content": self.content,
|
||||||
"type": self.kind,
|
"type": self.kind,
|
||||||
"event_id": self.event_id,
|
"event_id": self.event_id,
|
||||||
"sender": self.sender,
|
"sender": self.sender,
|
||||||
"origin_server_ts": self.origin_server_ts,
|
"origin_server_ts": self.origin_server_ts,
|
||||||
"redacts": self.redacts,
|
"redacts": self.redacts,
|
||||||
"unsigned": self.unsigned,
|
|
||||||
"room_id": self.room_id,
|
"room_id": self.room_id,
|
||||||
"state_key": self.state_key,
|
"state_key": self.state_key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if let Some(unsigned) = &self.unsigned {
|
||||||
|
json["unsigned"] = json!(unsigned);
|
||||||
|
}
|
||||||
|
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue