push-gateway-api: Make data field of Device not an Option
All fields of the inner type are optional themselves.
This commit is contained in:
parent
103b9df6c2
commit
ac6ecc3e5e
@ -420,6 +420,19 @@ impl PusherData {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
/// Returns `true` if all fields are `None`.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
#[cfg(not(feature = "unstable-pre-spec"))]
|
||||
{
|
||||
self.url.is_none() && self.format.is_none()
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable-pre-spec")]
|
||||
{
|
||||
self.url.is_none() && self.format.is_none() && self.default_payload.is_none()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A special format that the homeserver should use when sending notifications to a Push Gateway.
|
||||
|
@ -208,8 +208,8 @@ pub struct Device {
|
||||
///
|
||||
/// For 'http' pushers, this is the data dictionary passed in at pusher creation minus the
|
||||
/// `url` key.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub data: Option<PusherData>,
|
||||
#[serde(default, skip_serializing_if = "PusherData::is_empty")]
|
||||
pub data: PusherData,
|
||||
|
||||
/// A dictionary of customisations made to the way this notification is to be presented.
|
||||
///
|
||||
@ -221,7 +221,7 @@ pub struct Device {
|
||||
impl Device {
|
||||
/// Create a new device with the given app id and pushkey
|
||||
pub fn new(app_id: String, pushkey: String) -> Self {
|
||||
Device { app_id, pushkey, pushkey_ts: None, data: None, tweaks: Vec::new() }
|
||||
Device { app_id, pushkey, pushkey_ts: None, data: PusherData::new(), tweaks: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user