]> git.proxmox.com Git - proxmox.git/commit
notify: api: allow resetting built-in targets if used by a matcher
authorLukas Wagner <l.wagner@proxmox.com>
Wed, 10 Jan 2024 09:31:21 +0000 (10:31 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 10 Jan 2024 11:29:26 +0000 (12:29 +0100)
commit50fa98e241c1704db2156efd74a051c397d16f5b
treea7c74d063268292fcab2fb4e26533bd105130634
parentefa607f1b5b4cfed71c20abaeabe62ad70085b52
notify: api: allow resetting built-in targets if used by a matcher

In the 'delete'-handler targets, we check if a
target is still referenced by a matcher - if it is, we return an
error. For built-in targets, this is actually not necessary, since
'deleting' a built-in only resets it to its default settings - it will
continue to exist after that.
The user could easily trigger this if 'mail-to-root', which is
referenced by 'default-matcher' is modified and then reset to its
defaults: An error is shown, the built-in target is not reset.

This commit disables this check if it is a built-in target.

Renamed the helper 'ensure_unused' to 'ensure_safe_to_delete' in the
process.

Also fixed the tests in api::test - they were never executed due to a
faulty #[cfg] directive.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
proxmox-notify/src/api/gotify.rs
proxmox-notify/src/api/mod.rs
proxmox-notify/src/api/sendmail.rs
proxmox-notify/src/api/smtp.rs