notify: derive Deserialize/Serialize for Notification struct

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Lukas Wagner 2024-04-19 16:17:13 +02:00 committed by Thomas Lamprecht
parent 1a40d34083
commit c55f37b8c4

View File

@ -159,9 +159,11 @@ pub trait Endpoint {
fn disabled(&self) -> bool; fn disabled(&self) -> bool;
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum Content { pub enum Content {
/// Title and body will be rendered as a template /// Title and body will be rendered as a template
#[serde(rename_all = "kebab-case")]
Template { Template {
/// Name of the used template /// Name of the used template
template_name: String, template_name: String,
@ -169,6 +171,7 @@ pub enum Content {
data: Value, data: Value,
}, },
#[cfg(feature = "mail-forwarder")] #[cfg(feature = "mail-forwarder")]
#[serde(rename_all = "kebab-case")]
ForwardedMail { ForwardedMail {
/// Raw mail contents /// Raw mail contents
raw: Vec<u8>, raw: Vec<u8>,
@ -182,7 +185,8 @@ pub enum Content {
}, },
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Metadata { pub struct Metadata {
/// Notification severity /// Notification severity
severity: Severity, severity: Severity,
@ -192,7 +196,8 @@ pub struct Metadata {
additional_fields: HashMap<String, String>, additional_fields: HashMap<String, String>,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
/// Notification which can be sent /// Notification which can be sent
pub struct Notification { pub struct Notification {
/// Notification content /// Notification content