Skip to content

Commit

Permalink
Merge pull request #16 from NethServer/sdl-6895-retention
Browse files Browse the repository at this point in the history
Update retention days in piler.conf template NethServer/dev#6895
  • Loading branch information
stephdl authored May 14, 2024
2 parents f6b34b4 + ba019bb commit b148237
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 7 deletions.
2 changes: 2 additions & 0 deletions imageroot/actions/configure-module/10configure
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ providers = agent.list_service_providers(rdb, 'imap', 'tcp', {
if providers:
# Set the PROVIDER_IP (IPV4) environment variable to the host of the first provider
agent.set_env("PROVIDER_IP", providers[0]["host"])

agent.set_env("RETENTION_DAYS", data["retention_days"])
12 changes: 10 additions & 2 deletions imageroot/actions/configure-module/validate-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
{
"host": "piler.nethserver.org",
"http2https": true,
"lets_encrypt": true
"lets_encrypt": true,
"retention_days": 365
}
],
"type": "object",
"required": [
"host",
"http2https",
"lets_encrypt",
"mail_server"
"mail_server",
"retention_days"
],
"properties": {
"host": {
Expand All @@ -39,6 +41,12 @@
"description": "Mail server UUID",
"type": "string",
"title": "Mail server UUID"
},
"retention_days": {
"description": "Number of days to keep the emails",
"type": "integer",
"minimum": 1,
"title": "Retention days"
}
}
}
2 changes: 1 addition & 1 deletion imageroot/actions/get-configuration/20read
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ config["host"] = os.environ.get("TRAEFIK_HOST",'')
config["http2https"] = os.environ.get("TRAEFIK_HTTP2HTTPS","False") == "True"
config["lets_encrypt"] = os.environ.get("TRAEFIK_LETS_ENCRYPT","False") == "True"
config["mail_server"] = os.getenv("MAIL_SERVER", "")

config['retention_days'] = int(os.getenv("RETENTION_DAYS", 2557))
rdb = agent.redis_connect() # full read-only access on every key
modules=[]
# we query about all mail server to use it inside the user interface
Expand Down
11 changes: 9 additions & 2 deletions imageroot/actions/get-configuration/validate-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lets_encrypt": true,
"mail_server": "xxxxxxxxxxxxxxxxxxxxxxxxx",
"is_default_password_admin": false,
"is_default_password_auditor": false
"is_default_password_auditor": false,
"retention_days": 365
}
],
"type": "object",
Expand All @@ -20,7 +21,8 @@
"lets_encrypt",
"mail_server",
"is_default_password_admin",
"is_default_password_auditor"
"is_default_password_auditor",
"retention_days"
],
"properties": {
"host": {
Expand Down Expand Up @@ -52,6 +54,11 @@
"type": "boolean",
"title": "Default password",
"description": "True if the password is the default one"
},
"retention_days": {
"type": "integer",
"title": "Retention days",
"description": "Number of days to keep the emails"
}
}
}
1 change: 1 addition & 0 deletions imageroot/bin/expand-configuration
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if os.environ.get("MAIL_SERVER", ''):
properties = {
"host": os.environ["TRAEFIK_HOST"],
"provider_ip": os.environ["PROVIDER_IP"],
"retention_days": os.environ.get("RETENTION_DAYS", 2557),
}

json_properties = json.dumps(properties)
Expand Down
2 changes: 1 addition & 1 deletion imageroot/templates/piler.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ backlog=20
check_for_client_timeout_interval=20
cipher_list=ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
clamd_socket=/tmp/clamd
default_retention_days=2557
default_retention_days={{retention_days}}
enable_chunking=0
enable_cjk=0
enable_folders=0
Expand Down
6 changes: 5 additions & 1 deletion ui/public/i18n/language.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@
"import_old_emails_to_piler_description": "Import old emails to Piler, this process may take a long time",
"always_bcc_is_already_set": "Always BCC is already set in the server, you need to manually remove it (POSTFIX_ALWAYS_BCC)",
"always_bcc_not_set_warning": "Always BCC is not set",
"always_bcc_not_set_description": "Always BCC is not set in the mail server, you could try to configure again piler"
"always_bcc_not_set_description": "Always BCC is not set in the mail server, you could try to configure again piler",
"retention_days": "Retention days",
"retention_days_error": "Enter a number greater than 0",
"placeholder_retention_days": "Type the number of days",
"retention_days_tooltip": "The number of days to keep the emails in the archive"
},
"about": {
"title": "About"
Expand Down
27 changes: 27 additions & 0 deletions ui/src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@
{{ $t("settings.choose_the_mail_server_to_use") }}
</template>
</NsComboBox>
<NsTextInput
:label="$t('settings.retention_days')"
:placeholder="$t('settings.placeholder_retention_days')"
v-model.trim="retention_days"
:invalid-message="$t(error.retention_days)"
:disabled="loading.getConfiguration || loading.configureModule"
ref="retention_days"
type="number"
tooltipAlignment="start"
tooltipDirection="right"
>
<template slot="tooltip">
{{ $t('settings.retention_days_tooltip')}}
</template>
</NsTextInput>
<cv-row v-if="error.configureModule">
<cv-column>
<NsInlineNotification
Expand Down Expand Up @@ -187,6 +202,7 @@ export default {
is_default_password_auditor: false,
isLetsEncryptEnabled: false,
isHttpToHttpsEnabled: false,
retention_days: "2557",
loading: {
getConfiguration: false,
configureModule: false,
Expand All @@ -198,6 +214,7 @@ export default {
lets_encrypt: "",
http2https: "",
mail_server: "",
retention_days: "",
},
};
},
Expand Down Expand Up @@ -277,6 +294,7 @@ export default {
this.is_default_password_auditor = config.is_default_password_auditor;
this.piler_is_running = config.piler_is_running;
this.always_bcc_correctly_set = config.always_bcc_correctly_set;
this.retention_days = config.retention_days.toString();
this.loading.getConfiguration = false;
this.focusElement("host");
},
Expand All @@ -301,6 +319,14 @@ export default {
}
isValidationOk = false;
}
if (this.retention_days < 1) {
this.error.retention_days = "settings.retention_days_error";

if (isValidationOk) {
this.focusElement("retention_days");
}
isValidationOk = false;
}
return isValidationOk;
},
configureModuleValidationFailed(validationErrors) {
Expand Down Expand Up @@ -354,6 +380,7 @@ export default {
mail_server: this.mail_server,
lets_encrypt: this.isLetsEncryptEnabled,
http2https: this.isHttpToHttpsEnabled,
retention_days: parseInt(this.retention_days),
},
extra: {
title: this.$t("settings.instance_configuration", {
Expand Down

0 comments on commit b148237

Please sign in to comment.