From fb0196ad9d18554e035de27d4f2a906ba050b407 Mon Sep 17 00:00:00 2001 From: Rafael Carvalho Date: Sat, 10 Feb 2024 22:01:01 +0000 Subject: [PATCH] imapnotify: enable STARTTLS if enabled in email account config (#5013) * imapnotify: enable STARTTLS if enabled in email account config Since version 2.3.10 goimapnotify supports starttls. In version 2.3.11 a typo in the settings was fixed, using tlsOptions.starttls to enable it. This commit enables starttls in the goimapnotify config file if it is enabled in the email account's imap settings. * imapnotify: test generated config file Compare the generated service config file with a manually verified sample. --- modules/services/imapnotify.nix | 1 + tests/modules/services/imapnotify/imapnotify-config.json | 1 + tests/modules/services/imapnotify/imapnotify.nix | 5 +++++ 3 files changed, 7 insertions(+) create mode 100644 tests/modules/services/imapnotify/imapnotify-config.json diff --git a/modules/services/imapnotify.nix b/modules/services/imapnotify.nix index a79cba35..63e61e7c 100644 --- a/modules/services/imapnotify.nix +++ b/modules/services/imapnotify.nix @@ -72,6 +72,7 @@ let inherit (account.imap) host; inherit port; tls = account.imap.tls.enable; + tlsOptions.starttls = account.imap.tls.useStartTls; username = account.userName; passwordCmd = lib.concatMapStringsSep " " lib.escapeShellArg account.passwordCommand; diff --git a/tests/modules/services/imapnotify/imapnotify-config.json b/tests/modules/services/imapnotify/imapnotify-config.json new file mode 100644 index 00000000..21276857 --- /dev/null +++ b/tests/modules/services/imapnotify/imapnotify-config.json @@ -0,0 +1 @@ +{"boxes":["Inbox"],"host":"imap.example.com","onNewMail":"@notmuch@/bin/notmuch new\n","passwordCmd":"'password-command'","port":993,"tls":true,"tlsOptions":{"starttls":false},"username":"home.manager"} \ No newline at end of file diff --git a/tests/modules/services/imapnotify/imapnotify.nix b/tests/modules/services/imapnotify/imapnotify.nix index c607c042..5a9e2b00 100644 --- a/tests/modules/services/imapnotify/imapnotify.nix +++ b/tests/modules/services/imapnotify/imapnotify.nix @@ -35,5 +35,10 @@ with lib; serviceFileNormalized="$(normalizeStorePaths "$serviceFile")" assertFileExists $serviceFile assertFileContent $serviceFileNormalized ${./imapnotify.service} + + configFile="home-files/.config/imapnotify/imapnotify-hm-example.com-config.json" + configFileNormalized="$(normalizeStorePaths "$configFile")" + assertFileExists $configFile + assertFileContent $configFileNormalized ${./imapnotify-config.json} ''; }