~bzg/woof

5e690c205c775d96194cda038d4d197e643b2b7a — Bastien 2 months ago 5946e99
Add new environment variables

Add WOOF_SMTP_PORT and WOOF_SMTP_USE_TLS.
3 files changed, 16 insertions(+), 7 deletions(-)

M src/bzg/config.clj
M src/bzg/core.clj
M test/bzg/config_test.clj
M src/bzg/config.clj => src/bzg/config.clj +6 -2
@@ 1,4 1,5 @@
(ns bzg.config)
(ns bzg.config
  (:require [clojure.edn :as edn]))

(def env
  {


@@ 29,7 30,10 @@
   :mail-url-format (System/getenv "WOOF_MAIL_URL_FORMAT")

   ;; Send notification emails
   :smtp-host     (System/getenv "WOOF_SMTP_HOST")
   :smtp-host    (System/getenv "WOOF_SMTP_HOST")
   :smtp-port    (edn/read-string (System/getenv "WOOF_SMTP_PORT"))
   :smtp-use-tls (edn/read-string (System/getenv "WOOF_SMTP_USE_TLS"))

   :smtp-login    (System/getenv "WOOF_SMTP_LOGIN")
   :smtp-password (System/getenv "WOOF_SMTP_PASSWORD")


M src/bzg/core.clj => src/bzg/core.clj +4 -5
@@ 451,9 451,9 @@
   :postal             (merge (postal-appender/postal-appender ;; :min-level :warn
                               ^{:host (:smtp-host config/env)
                                 :user (:smtp-login config/env)
                                 :port 587
                                 :port (:smtp-port config/env)
                                 :pass (:smtp-password config/env)
                                 :tls  true}
                                 :tls  (:smtp-use-tls config/env)}
                               {:from (:smtp-login config/env)
                                :to   (make-to
                                       (:admin-username config/env)


@@ 469,9 469,8 @@
      (when-let
          [res (postal/send-message
                {:host (:smtp-host config/env)
                 :port 587
                 ;; FIXME: Always assume a tls connection (or configure)?
                 :tls  true
                 :port (:smtp-port config/env)
                 :tls  (:smtp-use-tls config/env)
                 :user (:smtp-login config/env)
                 :pass (:smtp-password config/env)}
                (merge

M test/bzg/config_test.clj => test/bzg/config_test.clj +6 -0
@@ 19,6 19,8 @@
(spec/def ::mailing-list-address (spec/nilable string?))
(spec/def ::mail-url-format (spec/nilable string?))
(spec/def ::smtp-host (spec/nilable string?))
(spec/def ::smtp-port integer?)
(spec/def ::smtp-use-tls boolean?)
(spec/def ::smtp-login (spec/nilable string?))
(spec/def ::smtp-password (spec/nilable string?))
(spec/def ::title (spec/nilable string?))


@@ 41,6 43,8 @@
            ::inbox-password
            ::smtp-host
            ::smtp-login
            ::smtp-port
            ::smtp-use-tls
            ::smtp-password
            ::title
            ::project-name


@@ 71,6 75,8 @@
    (is (spec/valid? ::inbox-folder (:inbox-folder config/env)))
    (is (spec/valid? ::smtp-host (:smtp-host config/env)))
    (is (spec/valid? ::smtp-login (:smtp-login config/env)))
    (is (spec/valid? ::smtp-port (:smtp-port config/env)))
    (is (spec/valid? ::smtp-use-tls (:smtp-use-tls config/env)))
    (is (spec/valid? ::smtp-password (:smtp-password config/env)))
    (is (spec/valid? ::title (:title config/env)))
    (is (spec/valid? ::project-name (:project-name config/env)))