[pve-devel] [PATCH cluster 15/19] notify: use named template instead of passing template strings

Fiona Ebner f.ebner at proxmox.com
Fri Apr 19 11:29:07 CEST 2024


Am 09.04.24 um 15:25 schrieb Lukas Wagner:
> The notification system will now load template files from a defined
> location. The template to use is now passed to proxmox_notify, instead
> of separate template strings for subject/body.
> 
> Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
> Tested-by: Folke Gleumes <f.gleumes at proxmox.com>
> ---
>  src/PVE/Notify.pm | 29 ++++++++++++-----------------
>  1 file changed, 12 insertions(+), 17 deletions(-)
> 
> diff --git a/src/PVE/Notify.pm b/src/PVE/Notify.pm
> index 872eb25..c514111 100644
> --- a/src/PVE/Notify.pm
> +++ b/src/PVE/Notify.pm
> @@ -58,17 +58,16 @@ sub write_config {
>  }
>  
>  my $send_notification = sub {
> -    my ($severity, $title, $message, $template_data, $fields, $config) = @_;
> +    my ($severity, $template_name, $template_data, $fields, $config) = @_;
>      $config = read_config() if !defined($config);
> -    $config->send($severity, $title, $message, $template_data, $fields);
> +    $config->send($severity, $template_name, $template_data, $fields);
>  };
>  
>  sub notify {
> -    my ($severity, $title, $message, $template_data, $fields, $config) = @_;
> +    my ($severity, $template_name, $template_data, $fields, $config) = @_;

And there's another versioned breaks required for packages with the
callers of all these functions here. Old version of package with caller
will be broken with new pve-cluster.

>      $send_notification->(
>          $severity,
> -        $title,
> -        $message,
> +        $template_name,
>          $template_data,
>          $fields,
>          $config
> @@ -76,11 +75,10 @@ sub notify {
>  }
>  
>  sub info {
> -    my ($title, $message, $template_data, $fields, $config) = @_;
> +    my ($template_name, $template_data, $fields, $config) = @_;
>      $send_notification->(
>          'info',
> -        $title,
> -        $message,
> +        $template_name,
>          $template_data,
>          $fields,
>          $config
> @@ -88,11 +86,10 @@ sub info {
>  }
>  
>  sub notice {
> -    my ($title, $message, $template_data, $fields, $config) = @_;
> +    my ($template_name, $template_data, $fields, $config) = @_;
>      $send_notification->(
>          'notice',
> -        $title,
> -        $message,
> +        $template_name,
>          $template_data,
>          $fields,
>          $config
> @@ -100,11 +97,10 @@ sub notice {
>  }
>  
>  sub warning {
> -    my ($title, $message, $template_data, $fields, $config) = @_;
> +    my ($template_name, $template_data, $fields, $config) = @_;
>      $send_notification->(
>          'warning',
> -        $title,
> -        $message,
> +        $template_name,
>          $template_data,
>          $fields,
>          $config
> @@ -112,11 +108,10 @@ sub warning {
>  }
>  
>  sub error {
> -    my ($title, $message, $template_data, $fields, $config) = @_;
> +    my ($template_name, $template_data, $fields, $config) = @_;
>      $send_notification->(
>          'error',
> -        $title,
> -        $message,
> +        $template_name,
>          $template_data,
>          $fields,
>          $config




More information about the pve-devel mailing list