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 313C7937D9 for ; Fri, 7 Apr 2023 15:43:40 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A82D31A794 for ; Fri, 7 Apr 2023 15:43:09 +0200 (CEST) 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 ; Fri, 7 Apr 2023 15:43:07 +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 4A12146460 for ; Fri, 7 Apr 2023 15:43:07 +0200 (CEST) From: Leo Nunner To: pmg-devel@lists.proxmox.com Date: Fri, 7 Apr 2023 15:42:53 +0200 Message-Id: <20230407134258.199691-8-l.nunner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230407134258.199691-1-l.nunner@proxmox.com> References: <20230407134258.199691-1-l.nunner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.122 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 Subject: [pmg-devel] [PATCH pmg-api 7/8] feature: match groups: update API endpoints X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Apr 2023 13:43:40 -0000 Adds the 'and' parameter to all rule API endpoints. The conditional endpoints from the 'negate' setting are still being used again here, since we don't need this property for actions. Signed-off-by: Leo Nunner --- src/PMG/API2/Rules.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/PMG/API2/Rules.pm b/src/PMG/API2/Rules.pm index ad3f6c7..4882c5a 100644 --- a/src/PMG/API2/Rules.pm +++ b/src/PMG/API2/Rules.pm @@ -266,6 +266,11 @@ my $register_rule_group_api = sub { type => 'boolean', optional => 1, }, + 'and' => { + description => "Add to logical AND list.", + type => 'boolean', + optional => 1, + }, }, }, returns => { type => 'null' }, @@ -282,6 +287,10 @@ my $register_rule_group_api = sub { $rdb->rule_set_group_setting_negate($param->{negate}, $param->{id}, $param->{ogroup}, $name); } + if (defined($param->{and})) { + $rdb->rule_set_group_setting_matchgroup($param->{and}, $param->{id}, $param->{ogroup}, $name); + } + PMG::DBTools::reload_ruledb(); return undef; @@ -354,6 +363,10 @@ my $register_rule_group_api = sub { description=> "Negate group.", type => 'boolean', }, + 'and' => { + description=> "In match group.", + type => 'boolean', + } } } }, @@ -366,6 +379,7 @@ my $register_rule_group_api = sub { my $ret = { negate => $settings->{negate}, + 'and' => $settings->{matchgroup}, }; return $ret; @@ -395,6 +409,11 @@ my $register_rule_group_api = sub { type => 'boolean', optional => 1, }, + 'and' => { + description => "Add to logical AND list.", + type => 'boolean', + optional => 1, + }, }, }, returns => { type => 'null' }, @@ -407,6 +426,10 @@ my $register_rule_group_api = sub { $rdb->rule_set_group_setting_negate($param->{negate}, $param->{id}, $param->{ogroup}, $name); } + if(defined($param->{and})) { + $rdb->rule_set_group_setting_matchgroup($param->{and}, $param->{id}, $param->{ogroup}, $name); + } + return; }}); } -- 2.30.2