Skip to content

Commit

Permalink
protocol: accept messages with empty values omitted
Browse files Browse the repository at this point in the history
  • Loading branch information
eras committed Jan 17, 2023
1 parent e7a55fb commit 818f89f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ pub struct ToDeviceWebRtcContent {
// unique id identifying this webrtc handshake
pub id: Uuid,

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, skip_serializing_if = "Option::is_none")]
// device id of the client sending this event; needed only on first contact
pub device_id: Option<OwnedDeviceId>,

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, skip_serializing_if = "Option::is_none")]
// the event holding the OfferContent relevant to this session; needed only on first contact
pub event_id: Option<OwnedEventId>,

Expand All @@ -32,31 +32,33 @@ pub struct File {

pub size: u64,

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub thumbnail_file: Option<EncryptedFile>,

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub thumbnail_info: Option<ThumbnailInfo>,

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub thumbnail_url: Option<String>,

#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub hashes: BTreeMap<String, Base64>,
}

#[derive(Debug, Serialize, Deserialize, EventContent, Default, Clone)]
#[ruma_event(type = "fi.variaattori.mxrxtx.offer", kind = MessageLike)]
pub struct OfferContent {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,

pub files: Vec<File>,

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub thumbnail_info: Option<ThumbnailInfo>,

#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub thumbnail_url: Option<String>,
}

0 comments on commit 818f89f

Please sign in to comment.