* [pbs-devel] [PATCH proxmox-backup v2 1/4] config: add email-from to NodeConfig
2022-01-03 9:04 [pbs-devel] [PATCH proxmox-backup v2 0/4] close #3162: add options to configure mail_from address Hannes Laimer
@ 2022-01-03 9:04 ` Hannes Laimer
2022-01-03 9:04 ` [pbs-devel] [PATCH proxmox-backup v2 2/4] api2: make email-from updatable Hannes Laimer
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Hannes Laimer @ 2022-01-03 9:04 UTC (permalink / raw)
To: pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/config/node.rs | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/config/node.rs b/src/config/node.rs
index 1c3ef492..4f2ab029 100644
--- a/src/config/node.rs
+++ b/src/config/node.rs
@@ -7,6 +7,7 @@ use proxmox_schema::{api, ApiStringFormat, ApiType, Updater};
use proxmox_http::ProxyConfig;
+use pbs_api_types::EMAIL_SCHEMA;
use pbs_buildcfg::configdir;
use pbs_config::{open_backup_lockfile, BackupLockGuard};
@@ -86,6 +87,10 @@ pub struct AcmeConfig {
schema: HTTP_PROXY_SCHEMA,
optional: true,
},
+ "email-from": {
+ schema: EMAIL_SCHEMA,
+ optional: true,
+ },
},
)]
#[derive(Deserialize, Serialize, Updater)]
@@ -113,6 +118,9 @@ pub struct NodeConfig {
#[serde(skip_serializing_if = "Option::is_none")]
pub http_proxy: Option<String>,
+
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub email_from: Option<String>,
}
impl NodeConfig {
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pbs-devel] [PATCH proxmox-backup v2 2/4] api2: make email-from updatable
2022-01-03 9:04 [pbs-devel] [PATCH proxmox-backup v2 0/4] close #3162: add options to configure mail_from address Hannes Laimer
2022-01-03 9:04 ` [pbs-devel] [PATCH proxmox-backup v2 1/4] config: add email-from to NodeConfig Hannes Laimer
@ 2022-01-03 9:04 ` Hannes Laimer
2022-01-03 9:04 ` [pbs-devel] [PATCH proxmox-backup v2 3/4] server: use configured email-from for sending mail Hannes Laimer
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Hannes Laimer @ 2022-01-03 9:04 UTC (permalink / raw)
To: pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/api2/node/config.rs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/api2/node/config.rs b/src/api2/node/config.rs
index 0b45f34c..3f060981 100644
--- a/src/api2/node/config.rs
+++ b/src/api2/node/config.rs
@@ -54,6 +54,8 @@ pub enum DeletableProperty {
acmedomain4,
/// Delete the http-proxy property.
http_proxy,
+ /// Delete the email-from property.
+ email_from,
}
#[api(
@@ -110,6 +112,7 @@ pub fn update_node_config(
DeletableProperty::acmedomain3 => { config.acmedomain3 = None; },
DeletableProperty::acmedomain4 => { config.acmedomain4 = None; },
DeletableProperty::http_proxy => { config.http_proxy = None; },
+ DeletableProperty::email_from => { config.email_from = None; },
}
}
}
@@ -121,6 +124,7 @@ pub fn update_node_config(
if update.acmedomain3.is_some() { config.acmedomain3 = update.acmedomain3; }
if update.acmedomain4.is_some() { config.acmedomain4 = update.acmedomain4; }
if update.http_proxy.is_some() { config.http_proxy = update.http_proxy; }
+ if update.email_from.is_some() { config.email_from = update.email_from; }
crate::config::node::save_config(&config)?;
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pbs-devel] [PATCH proxmox-backup v2 3/4] server: use configured email-from for sending mail
2022-01-03 9:04 [pbs-devel] [PATCH proxmox-backup v2 0/4] close #3162: add options to configure mail_from address Hannes Laimer
2022-01-03 9:04 ` [pbs-devel] [PATCH proxmox-backup v2 1/4] config: add email-from to NodeConfig Hannes Laimer
2022-01-03 9:04 ` [pbs-devel] [PATCH proxmox-backup v2 2/4] api2: make email-from updatable Hannes Laimer
@ 2022-01-03 9:04 ` Hannes Laimer
2022-01-03 9:04 ` [pbs-devel] [PATCH proxmox-backup v2 4/4][optional] ui: add new options tab under configuration Hannes Laimer
2022-01-04 7:32 ` [pbs-devel] applied: [PATCH proxmox-backup v2 0/4] close #3162: add options to configure mail_from address Dietmar Maurer
4 siblings, 0 replies; 6+ messages in thread
From: Hannes Laimer @ 2022-01-03 9:04 UTC (permalink / raw)
To: pbs-devel
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/server/email_notifications.rs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs
index 33b106b4..4d734368 100644
--- a/src/server/email_notifications.rs
+++ b/src/server/email_notifications.rs
@@ -235,6 +235,9 @@ fn send_job_status_mail(
text: &str,
) -> Result<(), Error> {
+ let (config, _) = crate::config::node::config()?;
+ let from = config.email_from;
+
// Note: OX has serious problems displaying text mails,
// so we include html as well
let html = format!("<html><body><pre>\n{}\n<pre>", handlebars::html_escape(text));
@@ -248,7 +251,7 @@ fn send_job_status_mail(
subject,
Some(text),
Some(&html),
- None,
+ from.as_deref(),
Some(&author),
)?;
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pbs-devel] [PATCH proxmox-backup v2 4/4][optional] ui: add new options tab under configuration
2022-01-03 9:04 [pbs-devel] [PATCH proxmox-backup v2 0/4] close #3162: add options to configure mail_from address Hannes Laimer
` (2 preceding siblings ...)
2022-01-03 9:04 ` [pbs-devel] [PATCH proxmox-backup v2 3/4] server: use configured email-from for sending mail Hannes Laimer
@ 2022-01-03 9:04 ` Hannes Laimer
2022-01-04 7:32 ` [pbs-devel] applied: [PATCH proxmox-backup v2 0/4] close #3162: add options to configure mail_from address Dietmar Maurer
4 siblings, 0 replies; 6+ messages in thread
From: Hannes Laimer @ 2022-01-03 9:04 UTC (permalink / raw)
To: pbs-devel
... and add from-email + move http-proxy there
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
v2:
Optional because I could not come up with a better structure for the ui
and the email can be updated through the API or the proxman-backup-manager,
so this patch is not necessarily needed.
www/SystemConfiguration.js | 25 +++++++++++++++++++++++--
www/config/NodeOptionView.js | 9 +++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/www/SystemConfiguration.js b/www/SystemConfiguration.js
index 86371193..ac24bff9 100644
--- a/www/SystemConfiguration.js
+++ b/www/SystemConfiguration.js
@@ -63,9 +63,25 @@ Ext.define('PBS.SystemConfiguration', {
title: gettext('Webauthn'),
xtype: 'pbsWebauthnConfigView',
},
+ ],
+ },
+ {
+ title: gettext('Options'),
+ itemId: 'options',
+ xtype: 'panel',
+ layout: {
+ type: 'vbox',
+ align: 'stretch',
+ multi: true,
+ },
+ defaults: {
+ collapsible: true,
+ animCollapse: false,
+ margin: '10 10 0 10',
+ },
+ items: [
{
- // FIXME: this is only a semi-OK place as long as there's only the http-proxy in there
- title: gettext('HTTP proxy'),
+ title: gettext('General'),
xtype: 'pbsNodeOptionView',
},
],
@@ -86,6 +102,11 @@ Ext.define('PBS.SystemConfiguration', {
Ext.Array.forEach(authentication.query(), function(item) {
item.relayEvents(authentication, ['activate', 'deactivate', 'destroy']);
});
+
+ let options = me.getComponent('options');
+ Ext.Array.forEach(options.query(), function(item) {
+ item.relayEvents(options, ['activate', 'deactivate', 'destroy']);
+ });
},
});
diff --git a/www/config/NodeOptionView.js b/www/config/NodeOptionView.js
index 55271a91..64f3d792 100644
--- a/www/config/NodeOptionView.js
+++ b/www/config/NodeOptionView.js
@@ -34,6 +34,15 @@ Ext.define('PBS.NodeOptionView', {
deleteEmpty: true,
onlineHelp: 'node_options_http_proxy',
},
+ {
+ xtype: 'text',
+ name: 'email-from',
+ defaultValue: gettext('root@$hostname'),
+ text: gettext('Email from address'),
+ vtype: 'proxmoxMail',
+ deleteEmpty: true,
+ },
+
],
initComponent: function() {
--
2.30.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [pbs-devel] applied: [PATCH proxmox-backup v2 0/4] close #3162: add options to configure mail_from address
2022-01-03 9:04 [pbs-devel] [PATCH proxmox-backup v2 0/4] close #3162: add options to configure mail_from address Hannes Laimer
` (3 preceding siblings ...)
2022-01-03 9:04 ` [pbs-devel] [PATCH proxmox-backup v2 4/4][optional] ui: add new options tab under configuration Hannes Laimer
@ 2022-01-04 7:32 ` Dietmar Maurer
4 siblings, 0 replies; 6+ messages in thread
From: Dietmar Maurer @ 2022-01-04 7:32 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Hannes Laimer
applied
On 1/3/22 10:04, Hannes Laimer wrote:
> Adds an option to configure the email address that is used as 'from'
> when mails are sent.
>
> v2:
> - don't lock config file for reading
> - marked 4th patch (for ui) as optional, config can be updated through the
> API or using the proxmox-backup-manager
>
> Hannes Laimer (4):
> config: add email-from to NodeConfig
> api2: make email-from updatable
> server: use configured email-from for sending mail
> ui: add new options tab under configuration
>
> src/api2/node/config.rs | 4 ++++
> src/config/node.rs | 8 ++++++++
> src/server/email_notifications.rs | 5 ++++-
> www/SystemConfiguration.js | 25 +++++++++++++++++++++++--
> www/config/NodeOptionView.js | 9 +++++++++
> 5 files changed, 48 insertions(+), 3 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread