From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id A834699B1A for ; Tue, 14 Nov 2023 14:00:18 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A606B1FE90 for ; Tue, 14 Nov 2023 14:00:16 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 14 Nov 2023 14:00:15 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 187EE429C1 for ; Tue, 14 Nov 2023 14:00:15 +0100 (CET) From: Lukas Wagner To: pve-devel@lists.proxmox.com Date: Tue, 14 Nov 2023 13:59:36 +0100 Message-Id: <20231114130000.565122-29-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231114130000.565122-1-l.wagner@proxmox.com> References: <20231114130000.565122-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.012 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH v2 pve-manager 28/52] api: apt: adapt to matcher-based notifications X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2023 13:00:18 -0000 Signed-off-by: Lukas Wagner --- PVE/API2/APT.pm | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm index a213fc59..da75a4dc 100644 --- a/PVE/API2/APT.pm +++ b/PVE/API2/APT.pm @@ -286,8 +286,6 @@ __PACKAGE__->register_method({ description => "This is used to resynchronize the package index files from their sources (apt-get update).", permissions => { check => ['perm', '/nodes/{node}', [ 'Sys.Modify' ]], - description => "If 'notify: target-package-updates' is set, then the user must have the " - . "'Mapping.Use' permission on '/mapping/notification/'", }, protected => 1, proxyto => 'node', @@ -297,7 +295,7 @@ __PACKAGE__->register_method({ node => get_standard_option('pve-node'), notify => { type => 'boolean', - description => "Send notification mail about new packages (to email address specified for user 'root\@pam').", + description => "Send notification about new packages.", optional => 1, default => 0, }, @@ -317,16 +315,6 @@ __PACKAGE__->register_method({ my $rpcenv = PVE::RPCEnvironment::get(); my $dcconf = PVE::Cluster::cfs_read_file('datacenter.cfg'); - my $target = $dcconf->{notify}->{'target-package-updates'} // - PVE::Notify::default_target(); - - if ($param->{notify} && $target ne PVE::Notify::default_target()) { - # If we notify via anything other than the default target (mail to root), - # then the user must have the proper permissions for the target. - # The mail-to-root target does not require these, as otherwise - # we would break compatibility. - PVE::Notify::check_may_use_target($target, $rpcenv); - } my $authuser = $rpcenv->get_user(); @@ -392,16 +380,23 @@ __PACKAGE__->register_method({ return if !$count; - my $properties = { + my $template_data = { updates => $updates_table, hostname => $hostname, }; + # Additional metadata fields that can be used in notification + # matchers. + my $metadata_fields = { + type => 'package-updates', + hostname => $hostname, + }; + PVE::Notify::info( - $target, $updates_available_subject_template, $updates_available_body_template, - $properties, + $template_data, + $metadata_fields, ); foreach my $pi (@$pkglist) { -- 2.39.2