[pve-devel] [PATCH proxmox 01/21] notify: include 'hostname' metadata field for forwarded mails
Lukas Wagner
l.wagner at proxmox.com
Mon Dec 11 13:49:35 CET 2023
Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
proxmox-notify/src/lib.rs | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/proxmox-notify/src/lib.rs b/proxmox-notify/src/lib.rs
index 1fb9623..f3ee3ad 100644
--- a/proxmox-notify/src/lib.rs
+++ b/proxmox-notify/src/lib.rs
@@ -231,6 +231,9 @@ impl Notification {
let title = message.subject().unwrap_or_default().into();
let body = message.body_text(0).unwrap_or_default().into();
+ let mut additional_fields = HashMap::new();
+ additional_fields.insert("hostname".into(), proxmox_sys::nodename().into());
+
Ok(Self {
// Unfortunately we cannot reasonably infer the severity from the
// mail contents, so just set it to the highest for now so that
@@ -243,7 +246,7 @@ impl Notification {
},
metadata: Metadata {
severity: Severity::Unknown,
- additional_fields: Default::default(),
+ additional_fields,
timestamp: proxmox_time::epoch_i64(),
},
})
@@ -278,14 +281,21 @@ impl Config {
if let Some(obj) = value.as_object_mut() {
obj.insert("origin".to_string(), Value::String("builtin".into()));
} else {
- log::error!("section config entry is not an object. This should not happen");
+ log::error!(
+ "section config entry is not an object. This should not happen"
+ );
}
} else {
// Entry is built-in, but it has been modified by the user.
if let Some(obj) = value.as_object_mut() {
- obj.insert("origin".to_string(), Value::String("modified-builtin".into()));
+ obj.insert(
+ "origin".to_string(),
+ Value::String("modified-builtin".into()),
+ );
} else {
- log::error!("section config entry is not an object. This should not happen");
+ log::error!(
+ "section config entry is not an object. This should not happen"
+ );
}
}
} else {
--
2.39.2
More information about the pve-devel
mailing list