From cbc22ea207ddbeac5d24761cefd90c7937dcfce0 Mon Sep 17 00:00:00 2001 From: nerf van nerfingen Date: Mon, 14 Nov 2022 12:13:42 +0100 Subject: [PATCH 1/2] made the config file format a bit more sensible --- README.md | 13 +++++++------ app/Config.hs | 14 +++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 419bfdc..e046141 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,13 @@ The config file is a toml file, even though it as of now makes not really use of any toml features. ```toml -mailDomain = "the domain of the smtp server to send messages with" -mailUser = "the username on the smtp server" -mailPassword = "the passwond on the smtp server" -mailTo = "the mail to send to" -mailFrom = "the sender of the mail" -mailErrorTo = "the address to send a mail to in case of error" +[mail] +domain = "the domain of the smtp server to send messages with" +user = "the username on the smtp server" +password = "the passwond on the smtp server" +to = "the mail to send to" +from = "the sender of the mail" +errorTo = "the address to send a mail to in case of error" ``` ## Develop diff --git a/app/Config.hs b/app/Config.hs index 6d87a35..6033e46 100644 --- a/app/Config.hs +++ b/app/Config.hs @@ -16,13 +16,13 @@ data Config = Config { } deriving Show configCodec :: TomlCodec Config -configCodec = Config - <$> Toml.string "mailDomain" .= mailDomain - <*> Toml.string "mailUser" .= mailUsername - <*> Toml.string "mailPassword" .= mailPassword - <*> Toml.text "mailTo" .= mailTo - <*> Toml.text "mailFrom" .= mailFrom - <*> Toml.text "mailErrorTo" .= mailErrorTo +configCodec = table "mail" $ Config + <$> Toml.string "domain" .= mailDomain + <*> Toml.string "user" .= mailUsername + <*> Toml.string "password" .= mailPassword + <*> Toml.text "to" .= mailTo + <*> Toml.text "from" .= mailFrom + <*> Toml.text "errorTo" .= mailErrorTo parseConfigFile :: (MonadIO m, MonadFail m) => String -> m Config parseConfigFile path = do From 85344c08671fe6b7c3f89b5d02713c235abb040a Mon Sep 17 00:00:00 2001 From: nerf van nerfingen Date: Mon, 14 Nov 2022 12:25:00 +0100 Subject: [PATCH 2/2] added stuff to readme --- README.md | 3 ++- app/Config.hs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e046141..c9c040d 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,5 @@ this depends on your local cabal cache. - Add the nix modules to the flake - Better Error handling - Find out which exceptions the SMTP module throws - +- Split config into secrets and non secret config + - make the pad url configurable diff --git a/app/Config.hs b/app/Config.hs index 6033e46..604d5cb 100644 --- a/app/Config.hs +++ b/app/Config.hs @@ -16,7 +16,7 @@ data Config = Config { } deriving Show configCodec :: TomlCodec Config -configCodec = table "mail" $ Config +configCodec = flip Toml.table "mail" $ Config <$> Toml.string "domain" .= mailDomain <*> Toml.string "user" .= mailUsername <*> Toml.string "password" .= mailPassword