[pve-devel] [PATCH pve-manager v2 3/4] notification: replication: add common properties to template data

Lukas Wagner l.wagner at proxmox.com
Fri Mar 28 11:19:13 CET 2025


The new PVE::Notify::common_template_data helper gives us a hash of
properties which should be available in all notifications (hostname,
fqdn, cluster-name at this moment). This commit makes sure that
replication notifications have these available.

Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
 PVE/API2/Replication.pm                    | 16 +++++++---------
 templates/default/replication-body.txt.hbs |  2 +-
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/PVE/API2/Replication.pm b/PVE/API2/Replication.pm
index e4a7180f..3a2be73a 100644
--- a/PVE/API2/Replication.pm
+++ b/PVE/API2/Replication.pm
@@ -112,15 +112,13 @@ my sub _handle_job_err {
     # The replication job is run every 15 mins if no schedule is set.
     my $schedule = $job->{schedule} // '*/15';
 
-    my $template_data = {
-	"failure-count" => $fail_count,
-	"last-sync"     => $jobstate->{last_sync},
-	"next-sync"     => $next_sync,
-	"job-id"        => $job->{id},
-	"job-target"    => $job->{target},
-	"job-schedule"  => $schedule,
-	"error"         => $err,
-    };
+    my $template_data = PVE::Notify::common_template_data();
+    $template_data->{"failure-count"} = $fail_count;
+    $template_data->{"last-sync"} = $jobstate->{last_sync};
+    $template_data->{"job-id"} = $job->{id};
+    $template_data->{"job-target"} = $job->{target};
+    $template_data->{"job-schedule"} = $schedule;
+    $template_data->{"error"} = $err;
 
     my $metadata_fields = {
 	type => "replication",
diff --git a/templates/default/replication-body.txt.hbs b/templates/default/replication-body.txt.hbs
index a9273fef..b1894ce9 100644
--- a/templates/default/replication-body.txt.hbs
+++ b/templates/default/replication-body.txt.hbs
@@ -9,4 +9,4 @@ Note: The system  will now reduce the frequency of error reports, as the job
 appears to be stuck.
 {{/if}}
 Error:
-{{ error }}
+{{error}}
-- 
2.39.5





More information about the pve-devel mailing list