config: allow to configure who receives job notify emails
This commit is contained in:
parent
84006f98b2
commit
6e545d0058
|
@ -68,6 +68,14 @@ pub fn list_datastores(
|
|||
optional: true,
|
||||
schema: SINGLE_LINE_COMMENT_SCHEMA,
|
||||
},
|
||||
"notify-user": {
|
||||
optional: true,
|
||||
type: Userid,
|
||||
},
|
||||
"notify": {
|
||||
optional: true,
|
||||
type: Notify,
|
||||
},
|
||||
"gc-schedule": {
|
||||
optional: true,
|
||||
schema: GC_SCHEDULE_SCHEMA,
|
||||
|
@ -187,6 +195,10 @@ pub enum DeletableProperty {
|
|||
keep_monthly,
|
||||
/// Delete the keep-yearly property
|
||||
keep_yearly,
|
||||
/// Delete the notify-user property
|
||||
notify_user,
|
||||
/// Delete the notify property
|
||||
notify,
|
||||
}
|
||||
|
||||
#[api(
|
||||
|
@ -200,6 +212,14 @@ pub enum DeletableProperty {
|
|||
optional: true,
|
||||
schema: SINGLE_LINE_COMMENT_SCHEMA,
|
||||
},
|
||||
"notify-user": {
|
||||
optional: true,
|
||||
type: Userid,
|
||||
},
|
||||
"notify": {
|
||||
optional: true,
|
||||
type: Notify,
|
||||
},
|
||||
"gc-schedule": {
|
||||
optional: true,
|
||||
schema: GC_SCHEDULE_SCHEMA,
|
||||
|
@ -262,6 +282,8 @@ pub fn update_datastore(
|
|||
keep_weekly: Option<u64>,
|
||||
keep_monthly: Option<u64>,
|
||||
keep_yearly: Option<u64>,
|
||||
notify: Option<Notify>,
|
||||
notify_user: Option<Userid>,
|
||||
delete: Option<Vec<DeletableProperty>>,
|
||||
digest: Option<String>,
|
||||
) -> Result<(), Error> {
|
||||
|
@ -290,6 +312,8 @@ pub fn update_datastore(
|
|||
DeletableProperty::keep_weekly => { data.keep_weekly = None; },
|
||||
DeletableProperty::keep_monthly => { data.keep_monthly = None; },
|
||||
DeletableProperty::keep_yearly => { data.keep_yearly = None; },
|
||||
DeletableProperty::notify => { data.notify = None; },
|
||||
DeletableProperty::notify_user => { data.notify_user = None; },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -322,6 +346,9 @@ pub fn update_datastore(
|
|||
if keep_monthly.is_some() { data.keep_monthly = keep_monthly; }
|
||||
if keep_yearly.is_some() { data.keep_yearly = keep_yearly; }
|
||||
|
||||
if notify.is_some() { data.notify = notify; }
|
||||
if notify_user.is_some() { data.notify_user = notify_user; }
|
||||
|
||||
config.set_data(&name, "datastore", &data)?;
|
||||
|
||||
datastore::save_config(&config)?;
|
||||
|
|
|
@ -1154,3 +1154,16 @@ pub struct APTUpdateInfo {
|
|||
/// URL under which the package's changelog can be retrieved
|
||||
pub change_log_url: String,
|
||||
}
|
||||
|
||||
#[api()]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
/// When do we send notifications
|
||||
pub enum Notify {
|
||||
/// Never send notification
|
||||
Never,
|
||||
/// Send notifications for failed and sucessful jobs
|
||||
Always,
|
||||
/// Send notifications for failed jobs only
|
||||
Error,
|
||||
}
|
||||
|
|
|
@ -32,6 +32,14 @@ pub const DIR_NAME_SCHEMA: Schema = StringSchema::new("Directory name").schema()
|
|||
path: {
|
||||
schema: DIR_NAME_SCHEMA,
|
||||
},
|
||||
"notify-user": {
|
||||
optional: true,
|
||||
type: Userid,
|
||||
},
|
||||
"notify": {
|
||||
optional: true,
|
||||
type: Notify,
|
||||
},
|
||||
comment: {
|
||||
optional: true,
|
||||
schema: SINGLE_LINE_COMMENT_SCHEMA,
|
||||
|
@ -101,6 +109,12 @@ pub struct DataStoreConfig {
|
|||
/// If enabled, all backups will be verified right after completion.
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub verify_new: Option<bool>,
|
||||
/// Send job email notification to this user
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub notify_user: Option<Userid>,
|
||||
/// Send notification only for job errors
|
||||
#[serde(skip_serializing_if="Option::is_none")]
|
||||
pub notify: Option<Notify>,
|
||||
}
|
||||
|
||||
fn init() -> SectionConfig {
|
||||
|
|
Loading…
Reference in New Issue