From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 514081FF0E0 for ; Thu, 09 Jul 2026 13:59:45 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id C8AE4216CF; Thu, 09 Jul 2026 13:58:09 +0200 (CEST) From: Lukas Wagner To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com Subject: [PATCH proxmox 13/29] notify: api: add `get_matcher_as_expression` Date: Thu, 9 Jul 2026 13:57:00 +0200 Message-ID: <20260709115716.299836-14-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260709115716.299836-1-l.wagner@proxmox.com> References: <20260709115716.299836-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1783598239118 X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: YJQDNO4WOW3PIJMP2URYTKI4MUOWNBSK X-Message-ID-Hash: YJQDNO4WOW3PIJMP2URYTKI4MUOWNBSK X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This one translates an existing matcher into an equivalent expression-based matcher on the fly. It allows us to keep the migration logic entirely in the backend; the GUI simply requests any existing matcher via this new getter and always receives one where the entire logic is encoded in the 'expression' parameter. Signed-off-by: Lukas Wagner --- proxmox-notify/src/api/matcher.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/proxmox-notify/src/api/matcher.rs b/proxmox-notify/src/api/matcher.rs index 3713dfef..be2d9c0e 100644 --- a/proxmox-notify/src/api/matcher.rs +++ b/proxmox-notify/src/api/matcher.rs @@ -29,6 +29,37 @@ pub fn get_matcher(config: &Config, name: &str) -> Result Result { + let mut matcher: MatcherConfig = config + .config + .lookup(MATCHER_TYPENAME, name) + .map_err(|_| http_err!(NOT_FOUND, "matcher '{name}' not found"))?; + + if matcher.expression.is_none() { + let expression = matcher.generate_expression_from_legacy_config(); + let expression_json = serde_json::to_string(&expression).map_err(|err| { + http_err!( + INTERNAL_SERVER_ERROR, + "could not serialize matcher expression: {err}" + ) + })?; + matcher.expression = Some(expression_json); + } + + matcher.match_calendar.clear(); + matcher.match_severity.clear(); + matcher.match_field.clear(); + matcher.mode = None; + matcher.invert_match = None; + + Ok(matcher) +} + /// Add new notification matcher. /// /// The caller is responsible for any needed permission checks. -- 2.47.3