Skip to content

Commit

Permalink
ui: status: Display reject-origin-domains config
Browse files Browse the repository at this point in the history
For #380

Signed-off-by: James Hillyerd <james@hillyerd.com>
  • Loading branch information
jhillyerd committed Nov 9, 2023
1 parent 1d102a6 commit 6b89d16
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
3 changes: 3 additions & 0 deletions ui/src/Data/ServerConfig.elm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type alias SmtpConfig =
, defaultStore : Bool
, storeDomains : Maybe (List String)
, discardDomains : Maybe (List String)
, rejectOriginDomains : Maybe (List String)
}


Expand Down Expand Up @@ -70,6 +71,7 @@ smtpConfigDecoder =
|> P.required "default-store" D.bool
|> P.required "store-domains" (D.nullable (D.list D.string))
|> P.required "discard-domains" (D.nullable (D.list D.string))
|> P.required "reject-origin-domains" (D.nullable (D.list D.string))


encodeSmtpConfig : SmtpConfig -> E.Value
Expand All @@ -82,6 +84,7 @@ encodeSmtpConfig r =
, ( "default-store", E.bool r.defaultStore )
, ( "store-domains", maybe (E.list E.string) r.storeDomains )
, ( "discard-domains", maybe (E.list E.string) r.discardDomains )
, ( "reject-origin-domains", maybe (E.list E.string) r.rejectOriginDomains )
]


Expand Down
30 changes: 23 additions & 7 deletions ui/src/Page/Status.elm
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ configPanel maybeConfig =
, textEntry "SMTP Listener" config.smtpConfig.addr
, textEntry "POP3 Listener" config.pop3Listener
, textEntry "HTTP Listener" config.webListener
, textEntry "Accept Policy" (acceptPolicy config)
, textEntry "Origin Policy" (originPolicy config)
, textEntry "Destination Policy" (acceptPolicy config)
, textEntry "Store Policy" (storePolicy config)
, textEntry "Store Type" config.storageConfig.storeType
, textEntry "Message Cap" (mailboxCap config)
Expand All @@ -286,7 +287,7 @@ configPanel maybeConfig =
acceptPolicy : ServerConfig -> String
acceptPolicy config =
if config.smtpConfig.defaultAccept then
"All domains"
"Allow all domains"
++ (case config.smtpConfig.rejectDomains of
Nothing ->
""
Expand All @@ -299,7 +300,7 @@ acceptPolicy config =
)

else
"No domains"
"Reject all domains"
++ (case config.smtpConfig.acceptDomains of
Nothing ->
""
Expand All @@ -308,14 +309,29 @@ acceptPolicy config =
""

Just domains ->
", except: " ++ String.join ", " domains
", except to: " ++ String.join ", " domains
)


originPolicy : ServerConfig -> String
originPolicy config =
"Allow all domains"
++ (case config.smtpConfig.rejectOriginDomains of
Nothing ->
""

Just [] ->
""

Just domains ->
", except from: " ++ String.join ", " domains
)


storePolicy : ServerConfig -> String
storePolicy config =
if config.smtpConfig.defaultStore then
"All domains"
"All destination domains"
++ (case config.smtpConfig.discardDomains of
Nothing ->
""
Expand All @@ -324,11 +340,11 @@ storePolicy config =
""

Just domains ->
", except: " ++ String.join ", " domains
", except to: " ++ String.join ", " domains
)

else
"No domains"
"No destination domains"
++ (case config.smtpConfig.storeDomains of
Nothing ->
""
Expand Down

0 comments on commit 6b89d16

Please sign in to comment.