diff --git a/proxmox-notify/src/api/common.rs b/proxmox-notify/src/api/common.rs index bc7029f5..d17f4db0 100644 --- a/proxmox-notify/src/api/common.rs +++ b/proxmox-notify/src/api/common.rs @@ -1,8 +1,8 @@ +use proxmox_http_error::HttpError; + use super::http_err; use crate::{Bus, Config, Notification}; -use proxmox_http_error::HttpError; - /// Send a notification to a given target. /// /// The caller is responsible for any needed permission checks. diff --git a/proxmox-notify/src/api/filter.rs b/proxmox-notify/src/api/filter.rs index be0c25bf..b8682f44 100644 --- a/proxmox-notify/src/api/filter.rs +++ b/proxmox-notify/src/api/filter.rs @@ -1,7 +1,8 @@ +use proxmox_http_error::HttpError; + use crate::api::http_err; use crate::filter::{DeleteableFilterProperty, FilterConfig, FilterConfigUpdater, FILTER_TYPENAME}; use crate::Config; -use proxmox_http_error::HttpError; /// Get a list of all filters /// diff --git a/proxmox-notify/src/api/mod.rs b/proxmox-notify/src/api/mod.rs index cb0e085b..8dc9b4ee 100644 --- a/proxmox-notify/src/api/mod.rs +++ b/proxmox-notify/src/api/mod.rs @@ -1,7 +1,9 @@ -use crate::Config; -use proxmox_http_error::HttpError; use std::collections::HashSet; +use proxmox_http_error::HttpError; + +use crate::Config; + pub mod common; pub mod filter; #[cfg(feature = "gotify")] diff --git a/proxmox-notify/src/config.rs b/proxmox-notify/src/config.rs index a5964007..cdbf42a0 100644 --- a/proxmox-notify/src/config.rs +++ b/proxmox-notify/src/config.rs @@ -1,4 +1,5 @@ use lazy_static::lazy_static; + use proxmox_schema::{ApiType, ObjectSchema}; use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin}; diff --git a/proxmox-notify/src/context.rs b/proxmox-notify/src/context.rs index b7b6a580..370c7ee3 100644 --- a/proxmox-notify/src/context.rs +++ b/proxmox-notify/src/context.rs @@ -1,6 +1,7 @@ -use once_cell::sync::OnceCell; use std::fmt::Debug; +use once_cell::sync::OnceCell; + pub trait Context: Send + Sync + Debug { fn lookup_email_for_user(&self, user: &str) -> Option; fn default_sendmail_author(&self) -> String; diff --git a/proxmox-notify/src/endpoints/gotify.rs b/proxmox-notify/src/endpoints/gotify.rs index c1f122dc..83df41f7 100644 --- a/proxmox-notify/src/endpoints/gotify.rs +++ b/proxmox-notify/src/endpoints/gotify.rs @@ -1,18 +1,18 @@ use std::collections::HashMap; -use crate::renderer::TemplateRenderer; -use crate::schema::ENTITY_NAME_SCHEMA; -use crate::{renderer, Endpoint, Error, Notification, Severity}; - -use proxmox_schema::api_types::COMMENT_SCHEMA; use serde::{Deserialize, Serialize}; use serde_json::json; -use crate::context::context; use proxmox_http::client::sync::Client; use proxmox_http::{HttpClient, HttpOptions, ProxyConfig}; +use proxmox_schema::api_types::COMMENT_SCHEMA; use proxmox_schema::{api, Updater}; +use crate::context::context; +use crate::renderer::TemplateRenderer; +use crate::schema::ENTITY_NAME_SCHEMA; +use crate::{renderer, Endpoint, Error, Notification, Severity}; + fn severity_to_priority(level: Severity) -> u32 { match level { Severity::Info => 1, diff --git a/proxmox-notify/src/endpoints/sendmail.rs b/proxmox-notify/src/endpoints/sendmail.rs index aba7150c..26e2a175 100644 --- a/proxmox-notify/src/endpoints/sendmail.rs +++ b/proxmox-notify/src/endpoints/sendmail.rs @@ -1,12 +1,14 @@ +use std::collections::HashSet; + +use serde::{Deserialize, Serialize}; + +use proxmox_schema::api_types::COMMENT_SCHEMA; +use proxmox_schema::{api, Updater}; + use crate::context::context; use crate::renderer::TemplateRenderer; use crate::schema::{EMAIL_SCHEMA, ENTITY_NAME_SCHEMA, USER_SCHEMA}; use crate::{renderer, Endpoint, Error, Notification}; -use std::collections::HashSet; - -use proxmox_schema::api_types::COMMENT_SCHEMA; -use proxmox_schema::{api, Updater}; -use serde::{Deserialize, Serialize}; pub(crate) const SENDMAIL_TYPENAME: &str = "sendmail"; diff --git a/proxmox-notify/src/filter.rs b/proxmox-notify/src/filter.rs index 5967deae..748ec4e8 100644 --- a/proxmox-notify/src/filter.rs +++ b/proxmox-notify/src/filter.rs @@ -1,6 +1,7 @@ -use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; +use serde::{Deserialize, Serialize}; + use proxmox_schema::api_types::COMMENT_SCHEMA; use proxmox_schema::{api, Updater}; diff --git a/proxmox-notify/src/group.rs b/proxmox-notify/src/group.rs index 726b7120..713e52ea 100644 --- a/proxmox-notify/src/group.rs +++ b/proxmox-notify/src/group.rs @@ -1,7 +1,9 @@ -use crate::schema::ENTITY_NAME_SCHEMA; +use serde::{Deserialize, Serialize}; + use proxmox_schema::api_types::COMMENT_SCHEMA; use proxmox_schema::{api, Updater}; -use serde::{Deserialize, Serialize}; + +use crate::schema::ENTITY_NAME_SCHEMA; pub(crate) const GROUP_TYPENAME: &str = "group"; diff --git a/proxmox-notify/src/lib.rs b/proxmox-notify/src/lib.rs index e8cd6b08..75007781 100644 --- a/proxmox-notify/src/lib.rs +++ b/proxmox-notify/src/lib.rs @@ -1,25 +1,28 @@ use std::collections::HashMap; +use std::error::Error as StdError; use std::fmt::Display; -use filter::{FilterConfig, FilterMatcher, FILTER_TYPENAME}; -use group::{GroupConfig, GROUP_TYPENAME}; -use proxmox_schema::api; -use proxmox_section_config::SectionConfigData; use serde::{Deserialize, Serialize}; use serde_json::json; use serde_json::Value; -use std::error::Error as StdError; +use proxmox_schema::api; +use proxmox_section_config::SectionConfigData; + +pub mod filter; +use filter::{FilterConfig, FilterMatcher, FILTER_TYPENAME}; + +pub mod group; +use group::{GroupConfig, GROUP_TYPENAME}; pub mod api; -mod config; pub mod context; pub mod endpoints; -pub mod filter; -pub mod group; pub mod renderer; pub mod schema; +mod config; + #[derive(Debug)] pub enum Error { ConfigSerialization(Box), diff --git a/proxmox-notify/src/renderer/html.rs b/proxmox-notify/src/renderer/html.rs index 7a41e873..e9ff2b45 100644 --- a/proxmox-notify/src/renderer/html.rs +++ b/proxmox-notify/src/renderer/html.rs @@ -1,5 +1,3 @@ -use crate::define_helper_with_prefix_and_postfix; -use crate::renderer::BlockRenderFunctions; use handlebars::{ Context, Handlebars, Helper, HelperResult, Output, RenderContext, RenderError as HandlebarsRenderError, @@ -7,6 +5,8 @@ use handlebars::{ use serde_json::Value; use super::{table::Table, value_to_string}; +use crate::define_helper_with_prefix_and_postfix; +use crate::renderer::BlockRenderFunctions; fn render_html_table( h: &Helper, diff --git a/proxmox-notify/src/renderer/mod.rs b/proxmox-notify/src/renderer/mod.rs index 2cf64a9f..f37e672e 100644 --- a/proxmox-notify/src/renderer/mod.rs +++ b/proxmox-notify/src/renderer/mod.rs @@ -1,18 +1,19 @@ //! Module for rendering notification templates. +use std::time::Duration; + use handlebars::{ Context, Handlebars, Helper, HelperDef, HelperResult, Output, RenderContext, RenderError as HandlebarsRenderError, }; -use std::time::Duration; - use serde::{Deserialize, Serialize}; use serde_json::Value; -use crate::Error; use proxmox_human_byte::HumanByte; use proxmox_time::TimeSpan; +use crate::Error; + mod html; mod plaintext; mod table; diff --git a/proxmox-notify/src/renderer/plaintext.rs b/proxmox-notify/src/renderer/plaintext.rs index 58c51599..c8079d7f 100644 --- a/proxmox-notify/src/renderer/plaintext.rs +++ b/proxmox-notify/src/renderer/plaintext.rs @@ -1,13 +1,14 @@ -use crate::define_helper_with_prefix_and_postfix; -use crate::renderer::BlockRenderFunctions; +use std::collections::HashMap; + use handlebars::{ Context, Handlebars, Helper, HelperResult, Output, RenderContext, RenderError as HandlebarsRenderError, }; use serde_json::Value; -use std::collections::HashMap; use super::{table::Table, value_to_string}; +use crate::define_helper_with_prefix_and_postfix; +use crate::renderer::BlockRenderFunctions; fn optimal_column_widths(table: &Table) -> HashMap<&str, usize> { let mut widths = HashMap::new();