Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update retention days in piler.conf template #16

Merged
merged 8 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"])
11 changes: 9 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,11 @@
"description": "Mail server UUID",
"type": "string",
"title": "Mail server UUID"
},
"retention_days": {
"description": "Number of days to keep the emails",
"type": "integer",
stephdl marked this conversation as resolved.
Show resolved Hide resolved
"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 @@ -11,7 +11,8 @@
"mail_server": "xxxxxxxxxxxxxxxxxxxxxxxxx",
"is_default_password_admin": false,
"is_default_password_auditor": false,
"import_email_is_running": false
"import_email_is_running": false,
"retention_days": 365
}
],
"type": "object",
Expand All @@ -22,7 +23,8 @@
"mail_server",
"is_default_password_admin",
"is_default_password_auditor",
"import_email_is_running"
"import_email_is_running",
"retention_days"
],
"properties": {
"host": {
Expand Down Expand Up @@ -59,6 +61,11 @@
"type": "boolean",
"title": "Import email is running",
"description": "True if the import email is running"
},
"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 @@ -52,7 +52,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": "Retention days must be a number superior to 0",
stephdl marked this conversation as resolved.
Show resolved Hide resolved
"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
38 changes: 38 additions & 0 deletions ui/src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,29 @@
/>
</cv-column>
</cv-row>
<!-- advanced options -->
<cv-accordion ref="accordion" class="maxwidth mg-bottom">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the retention should be always visible: it is the main configuration parameter for a mail archive as it says how many days a message is retained. Let's remove the accordion /cc @andre8244

Copy link

@andre8244 andre8244 May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, no problem for me

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

<cv-accordion-item :open="toggleAccordion[0]">
<template slot="title">{{ $t("settings.advanced") }}</template>
<template slot="content">
<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>
</template>
</cv-accordion-item>
</cv-accordion>
<cv-row v-if="error.configureModule">
<cv-column>
<NsInlineNotification
Expand Down Expand Up @@ -210,6 +233,7 @@ export default {
is_default_password_auditor: false,
isLetsEncryptEnabled: false,
isHttpToHttpsEnabled: false,
retention_days: "2557",
loading: {
getConfiguration: false,
configureModule: false,
Expand All @@ -223,6 +247,7 @@ export default {
lets_encrypt: "",
http2https: "",
mail_server: "",
retention_days: "",
},
};
},
Expand Down Expand Up @@ -303,6 +328,7 @@ export default {
this.import_email_is_running = config.import_email_is_running;
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 @@ -327,6 +353,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 @@ -380,6 +414,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 Expand Up @@ -418,4 +453,7 @@ export default {
.mg-bottom {
margin-bottom: $spacing-06;
}
.maxwidth {
max-width: 38rem;
}
</style>
Loading