From fea0a2b22ce0e520f03e7b610a42e3ae17d8d09a Mon Sep 17 00:00:00 2001 From: Stephane de Labrusse Date: Sat, 27 Apr 2024 07:57:39 +0200 Subject: [PATCH] Update Settings.vue to show warning notification when Always BCC is not set in the mail server --- imageroot/actions/get-configuration/20read | 23 ++++++++++++++++++++++ ui/public/i18n/language.json | 4 +++- ui/src/views/Settings.vue | 14 +++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/imageroot/actions/get-configuration/20read b/imageroot/actions/get-configuration/20read index 9c48fd5..fd21059 100755 --- a/imageroot/actions/get-configuration/20read +++ b/imageroot/actions/get-configuration/20read @@ -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) diff --git a/ui/public/i18n/language.json b/ui/public/i18n/language.json index cdcf624..c28c0d4 100644 --- a/ui/public/i18n/language.json +++ b/ui/public/i18n/language.json @@ -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" diff --git a/ui/src/views/Settings.vue b/ui/src/views/Settings.vue index cb47b9d..4386f97 100644 --- a/ui/src/views/Settings.vue +++ b/ui/src/views/Settings.vue @@ -29,6 +29,16 @@ /> + + + + +