From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <t.lamprecht@proxmox.com>
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 5133B71107
 for <pve-devel@lists.proxmox.com>; Wed,  7 Apr 2021 10:52:15 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 3A547E2A7
 for <pve-devel@lists.proxmox.com>; Wed,  7 Apr 2021 10:51:45 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (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 id AD21BE29C
 for <pve-devel@lists.proxmox.com>; Wed,  7 Apr 2021 10:51:44 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6E0A0458DD
 for <pve-devel@lists.proxmox.com>; Wed,  7 Apr 2021 10:51:44 +0200 (CEST)
Message-ID: <1f8805e2-27e2-57fb-b49c-cd7767d0c09f@proxmox.com>
Date: Wed, 7 Apr 2021 10:51:43 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101
 Thunderbird/88.0
Content-Language: en-US
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 =?UTF-8?Q?Dominic_J=c3=a4ger?= <d.jaeger@proxmox.com>
References: <20210407083045.62463-1-d.jaeger@proxmox.com>
 <20210407083045.62463-2-d.jaeger@proxmox.com>
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
In-Reply-To: <20210407083045.62463-2-d.jaeger@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.043 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -0.001 Looks like a legit reply (A)
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pve-devel] [PATCH manager 2/2] Close #1295: Make apt
 notifications configurable
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 07 Apr 2021 08:52:15 -0000

On 07.04.21 10:30, Dominic J=C3=A4ger wrote:
> This way all users, including subscription users, can decide if they wa=
nt to
> receive notifications mails from pveupdate or not. Disabling notificati=
ons is
> desirable if available updates are monitored externally, for example.
>=20
> Signed-off-by: Dominic J=C3=A4ger <d.jaeger@proxmox.com>
> ---
>  bin/pveupdate                 | 4 +---
>  www/manager6/dc/OptionView.js | 5 +++++
>  2 files changed, 6 insertions(+), 3 deletions(-)
>=20
> diff --git a/bin/pveupdate b/bin/pveupdate
> index 99b52fe9..37e6e518 100755
> --- a/bin/pveupdate
> +++ b/bin/pveupdate
> @@ -50,9 +50,7 @@ if (my $err =3D $@) {
>  }
> =20
>  my $info =3D PVE::INotify::read_file('subscription');
> -# We assume that users with subscriptions want informations
> -# about new packages.
> -my $notify =3D ($info && $info->{status} eq 'Active') ? 1 : 0;
> +my $notify =3D $dccfg->{notify_updates} // 1;

We may want to keep the default value the same, i.e.:

my $notify =3D $dccfg->{notify_updates} // ($info && $info->{status} eq '=
Active');

or if it's important that the perl "boolean" is stricly 0 or 1 then:

my $notify_default =3D ($info && $info->{status} eq 'Active') ? 1 : 0;
my $notify =3D $dccfg->{notify_updates} // $notify_default;


(the following is actually meant for the pve-cluster patch):
I'd really prefer using a colon for new config property entries, and I ca=
n imagine
that there will be more such switches in the future, so maybe start out w=
ith a format
sting (like migration is there) and have something like:

'notify: package-updates=3D1'

what do you think?


>  eval { PVE::API2::APT->update_database({ node =3D> $nodename, notify =3D=
> $notify, quiet =3D> 1 }); };
>  if (my $err =3D $@) {
>      syslog ('err', "update apt database failed: $err");
> diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView=
=2Ejs
> index 0e783cf4..b36acd07 100644
> --- a/www/manager6/dc/OptionView.js
> +++ b/www/manager6/dc/OptionView.js
> @@ -92,6 +92,11 @@ Ext.define('PVE.dc.OptionView', {
>  	    vtype: 'proxmoxMail',
>  	    defaultValue: 'root@$hostname',
>  	});
> +	me.add_boolean_row(
> +	    'notify_updates',
> +	    gettext('Notify about updates'),
> +	    { defaultValue: 1 },
> +	);
>  	me.add_text_row('mac_prefix', gettext('MAC address prefix'), {
>  	    deleteEmpty: true,
>  	    vtype: 'MacPrefix',
>=20