notify: use file based notification templates

Instead of passing literal template strings to the notification
system, we now only pass an identifier. This identifier will be used
load the template files from a product-specific directory.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
This commit is contained in:
Lukas Wagner 2024-05-21 15:31:41 +02:00 committed by Wolfgang Bumiller
parent d0633ac98e
commit 627a95bf89

View File

@ -94,16 +94,14 @@ mod export {
fn send( fn send(
#[try_from_ref] this: &NotificationConfig, #[try_from_ref] this: &NotificationConfig,
severity: Severity, severity: Severity,
title: String, template_name: String,
body: String,
template_data: Option<JSONValue>, template_data: Option<JSONValue>,
fields: Option<HashMap<String, String>>, fields: Option<HashMap<String, String>>,
) -> Result<(), HttpError> { ) -> Result<(), HttpError> {
let config = this.config.lock().unwrap(); let config = this.config.lock().unwrap();
let notification = Notification::new_templated( let notification = Notification::from_template(
severity, severity,
title, template_name,
body,
template_data.unwrap_or_default(), template_data.unwrap_or_default(),
fields.unwrap_or_default(), fields.unwrap_or_default(),
); );