Move PusherData to ruma-common

This commit is contained in:
Devin Ragotzy 2020-09-01 16:51:41 -04:00 committed by Jonas Platte
parent 55a67fbcf4
commit bedffcd45a
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
2 changed files with 24 additions and 23 deletions

View File

@ -2,6 +2,7 @@
use std::convert::TryFrom;
use ruma_common::push::PusherData;
use serde::{Deserialize, Serialize};
use strum::{Display, EnumString};
@ -90,26 +91,3 @@ pub enum PusherKind {
/// A pusher that emails the user with unread notifications.
Email,
}
/// Information for the pusher implementation itself.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PusherData {
/// Required if the pusher's kind is http. The URL to use to send notifications to.
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
/// The format to use when sending notifications to the Push Gateway.
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<PushFormat>,
}
/// A special format that the homeserver should use when sending notifications to a Push Gateway.
/// Currently, only "event_id_only" is supported as of [Push Gateway API r0.1.1][spec].
///
/// [spec]: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum PushFormat {
/// Require the homeserver to only send a reduced set of fields in the push.
EventIdOnly,
}

View File

@ -212,3 +212,26 @@ impl From<PatternedPushRuleInit> for PatternedPushRule {
Self { actions, default, enabled, rule_id, pattern }
}
}
/// Information for the pusher implementation itself.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PusherData {
/// Required if the pusher's kind is http. The URL to use to send notifications to.
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
/// The format to use when sending notifications to the Push Gateway.
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<PushFormat>,
}
/// A special format that the homeserver should use when sending notifications to a Push Gateway.
/// Currently, only "event_id_only" is supported as of [Push Gateway API r0.1.1][spec].
///
/// [spec]: https://matrix.org/docs/spec/push_gateway/r0.1.1#homeserver-behaviour
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum PushFormat {
/// Require the homeserver to only send a reduced set of fields in the push.
EventIdOnly,
}