Reset the SPF form when necessary.

This commit is contained in:
Philippe PITTOLI 2024-04-11 12:52:32 +02:00
parent 40c8f71346
commit 41098eed8b

View File

@ -148,6 +148,9 @@ data Action
-- | Add a new resource record to the zone. -- | Add a new resource record to the zone.
| AddRR AcceptedRRTypes ResourceRecord | AddRR AcceptedRRTypes ResourceRecord
-- | Reset the different values of SPF modal (mechanisms, modifiers, etc.).
| ResetSPF
-- | Save the changes done in an already existing resource record. -- | Save the changes done in an already existing resource record.
| SaveRR ResourceRecord | SaveRR ResourceRecord
@ -517,6 +520,7 @@ handleAction = case _ of
CancelModal -> do CancelModal -> do
H.modify_ _ { rr_modal = NoModal } H.modify_ _ { rr_modal = NoModal }
H.modify_ _ { _currentRR_errors = [] } H.modify_ _ { _currentRR_errors = [] }
handleAction $ ResetSPF
-- | Create the RR modal. -- | Create the RR modal.
DeleteRRModal rr_id -> do DeleteRRModal rr_id -> do
@ -646,6 +650,14 @@ handleAction = case _ of
H.modify_ _ { _currentRR_errors = [] } H.modify_ _ { _currentRR_errors = [] }
handleAction $ SaveRR rr handleAction $ SaveRR rr
ResetSPF -> do
H.modify_ _ { spf_mechanism_q = "pass"
, spf_mechanism_t = "a"
, spf_mechanism_v = ""
, spf_modifier_t = "redirect"
, spf_modifier_v = ""
}
SaveRR rr -> do SaveRR rr -> do
state <- H.get state <- H.get
H.raise $ Log $ SystemLog $ "Updating RR " <> show rr.rrid H.raise $ Log $ SystemLog $ "Updating RR " <> show rr.rrid
@ -654,6 +666,7 @@ handleAction = case _ of
$ DNSManager.serialize $ DNSManager.serialize
$ DNSManager.MkUpdateRR { domain: state._domain, rr: rr } $ DNSManager.MkUpdateRR { domain: state._domain, rr: rr }
H.raise $ MessageToSend message H.raise $ MessageToSend message
handleAction $ ResetSPF
RemoveRR rr_id -> do RemoveRR rr_id -> do
{ _domain } <- H.get { _domain } <- H.get
@ -714,6 +727,7 @@ handleAction = case _ of
[] -> Nothing [] -> Nothing
v -> Just v v -> Just v
H.modify_ _ { _currentRR { mechanisms = new_value }} H.modify_ _ { _currentRR { mechanisms = new_value }}
handleAction $ ResetSPF
SPF_Modifier_Add -> do SPF_Modifier_Add -> do
state <- H.get state <- H.get
@ -725,6 +739,7 @@ handleAction = case _ of
[] -> Nothing [] -> Nothing
v -> Just v v -> Just v
H.modify_ _ { _currentRR { modifiers = new_value }} H.modify_ _ { _currentRR { modifiers = new_value }}
handleAction $ ResetSPF
DKIM_hash_algo v -> H.modify_ _ { dkim { h = DKIM.hash_algos A.!! v } } DKIM_hash_algo v -> H.modify_ _ { dkim { h = DKIM.hash_algos A.!! v } }
DKIM_sign_algo v -> H.modify_ _ { dkim { k = DKIM.sign_algos A.!! v } } DKIM_sign_algo v -> H.modify_ _ { dkim { k = DKIM.sign_algos A.!! v } }