[pve-devel] [PATCH v3 proxmox-perl-rs 31/66] notify: implement context for getting default author/mailfrom

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Jul 19 13:15:57 CEST 2023


On Mon, Jul 17, 2023 at 05:00:16PM +0200, Lukas Wagner wrote:
> Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
> ---
>  pve-rs/src/notify.rs | 33 ++++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/pve-rs/src/notify.rs b/pve-rs/src/notify.rs
> index ea34bfe..04e902c 100644
> --- a/pve-rs/src/notify.rs
> +++ b/pve-rs/src/notify.rs
> @@ -34,6 +34,14 @@ fn lookup_mail_address(content: &str, user: &str) -> Option<String> {
>      }))
>  }
>  
> +fn lookup_datacenter_config_key(content: &str, key: &str) -> Option<String> {
> +    normalize_for_return(
> +        content
> +            .lines()
> +            .find_map(|line| line.strip_prefix(&format!("{key}:"))),

nit: you could format!() first then `move |...|` it into the closure so
it doesn't get recreated on every closure invocation.

> +    )
> +}
> +
>  struct PVEContext;
>  
>  impl Context for PVEContext {





More information about the pve-devel mailing list