Skip to content

Commit

Permalink
Update Settings.vue to show warning notification when Always BCC is n…
Browse files Browse the repository at this point in the history
…ot set in the mail server
  • Loading branch information
stephdl committed Apr 27, 2024
1 parent 8063865 commit fea0a2b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
23 changes: 23 additions & 0 deletions imageroot/actions/get-configuration/20read
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,28 @@ config['is_default_password'] = True if is_found_admin or is_found_auditor else
import_running = subprocess.run(['systemctl', '--user', 'is-active', "import-email-to-piler.service"], capture_output=True, text=True)
config['import_email_is_running'] = True if import_running.stdout.strip() == 'active' else False

# get the mail server module uuid
providers = agent.list_service_providers(rdb, 'imap', 'tcp', {
'module_uuid': os.getenv("MAIL_SERVER", ""),
})
# function to test get-always-bcc
def get_always_bcc(email):
mail_id = providers[0]["module_id"]
response = agent.tasks.run(f"module/{mail_id}", action='get-always-bcc')
agent.assert_exp(response['exit_code'] == 0)
# check if the always_bcc is set to the email
if response['output']['bcc'] == email:
return True
else:
return False
if providers:
# we need to get bcc address for the mail server to display a warning in the UI if it is not set correctly
config['always_bcc_correctly_set'] = get_always_bcc('archive@'+os.environ['MODULE_ID'])
else:
config['always_bcc_correctly_set'] = False
# check if the piler service is running
piler_running = subprocess.run(['systemctl', '--user', 'is-active', "piler-app.service"], capture_output=True, text=True)
config['piler_is_running'] = True if piler_running.stdout.strip() == 'active' else False

# Dump the configuratio to stdout
json.dump(config, fp=sys.stdout)
4 changes: 3 additions & 1 deletion ui/public/i18n/language.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"import_email_to_piler": "Import emails to Piler",
"advanced": "Advanced",
"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_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"
},
"about": {
"title": "About"
Expand Down
14 changes: 14 additions & 0 deletions ui/src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
/>
</cv-column>
</cv-row>
<cv-row v-if="piler_is_running && ! always_bcc_correctly_set">
<cv-column>
<NsInlineNotification
kind="warning"
:title="$t('settings.always_bcc_not_set_warning')"
:description="$t('settings.always_bcc_not_set_description')"
:showCloseButton="false"
/>
</cv-column>
</cv-row>
<cv-row v-if="import_email_is_running">
<cv-column>
<NsInlineNotification
Expand Down Expand Up @@ -177,6 +187,8 @@ export default {
mail_server: "",
mail_server_URL: [],
import_email_is_running: false,
piler_is_running: false,
always_bcc_correctly_set: false,
is_default_password: false,
isLetsEncryptEnabled: false,
isHttpToHttpsEnabled: false,
Expand Down Expand Up @@ -267,6 +279,8 @@ export default {
this.mail_server_URL = config.mail_server_URL;
this.is_default_password = config.is_default_password;
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.loading.getConfiguration = false;
this.focusElement("host");
},
Expand Down

0 comments on commit fea0a2b

Please sign in to comment.