Remove redundant code.

This commit is contained in:
Philippe Pittoli 2023-09-30 22:35:17 +02:00
parent 7c6cb46c12
commit 7178b29ae1
2 changed files with 2 additions and 42 deletions

View File

@ -200,7 +200,6 @@ handleAction = case _ of
ZoneInterfaceEvent ev -> case ev of
ZoneInterface.MessageToSend message -> H.tell _ws_dns unit (WS.ToSend message)
ZoneInterface.Log message -> H.tell _log unit (AppLog.Log message)
ZoneInterface.DNSManagerReconnect -> handleAction AuthenticateToDNSManager
DomainListComponentEvent ev -> case ev of
DomainListInterface.MessageToSend message -> H.tell _ws_dns unit (WS.ToSend message)
@ -325,12 +324,10 @@ handleAction = case _ of
handleAction $ Log $ SimpleLog $ "[😈] Invalid resource record: " <> A.intercalate ", " response.errors
(DNSManager.MkSuccess _) -> do
handleAction $ Log $ SimpleLog $ "[🎉] Success!"
handleAction $ Log $ SimpleLog $ "LETS GOOOOOOOOOOOOO!"
pure unit
-- Send a received DNS manager message to a component.
DispatchDNSMessage message -> do
handleAction $ Log $ SimpleLog "should send a DNS message to a component"
{ current_page } <- H.get
case current_page of
DomainList -> H.tell _dli unit (DomainListInterface.MessageReceived message)

View File

@ -56,7 +56,6 @@ import App.Validation as Validation
data Output
= MessageToSend ArrayBuffer
| Log LogMessage
| DNSManagerReconnect
-- | `App.ZoneInterface` can receive messages from `dnsmanagerd`.
-- |
@ -494,45 +493,15 @@ handleQuery = case _ of
MessageReceived message a -> do
case message of
-- The authentication failed.
(DNSManager.MkError errmsg) -> do
H.raise $ Log $ SimpleLog $ "[😈] Failed, reason is: " <> errmsg.reason
(DNSManager.MkErrorUserNotLogged _) -> do
H.raise $ Log $ SimpleLog $ "[😈] Failed! The user isn't connected!"
H.raise $ Log $ SimpleLog $ "[🤖] Trying to authenticate to fix the problem..."
H.raise $ DNSManagerReconnect
(DNSManager.MkErrorInvalidToken _) -> do
H.raise $ Log $ SimpleLog $ "[TODO] Failed connection! Invalid token!"
(DNSManager.MkDomainAlreadyExists _) -> do
H.raise $ Log $ SimpleLog $ "[TODO] Failed! The domain already exists."
(DNSManager.MkUnacceptableDomain _) -> do
H.raise $ Log $ SimpleLog $ "[TODO] Failed! The domain is not acceptable (not in the list of accepted domains)."
(DNSManager.MkAcceptedDomains _) -> do
H.raise $ Log $ SimpleLog $ "[TODO] Received the list of accepted domains!"
(DNSManager.MkLogged _) -> do
H.raise $ Log $ SimpleLog $ "[TODO] Authenticated to dnsmanagerd!"
(DNSManager.MkDomainAdded response) -> do
H.raise $ Log $ SimpleLog $ "[TODO] Domain added: " <> response.domain
(DNSManager.MkRRReadOnly response) -> do
H.raise $ Log $ SimpleLog $ "[😈] Trying to modify a read-only resource! "
<> "domain: " <> response.domain
<> "resource rrid: " <> show response.rr.rrid
(DNSManager.MkRRUpdated response) -> do
H.raise $ Log $ SimpleLog $ "[🎉] Resource updated!"
replace_entry response.rr
(DNSManager.MkRRAdded response) -> do
state <- H.get
let new_rr = response.rr
H.raise $ Log $ SimpleLog $ "[🎉] Resource Record added: " <> new_rr.rrtype
case add_entry state new_rr of
Left error_message -> H.raise $ Log $ SimpleLog $ "Error while adding new entry: " <> error_message
Right new_state -> H.put new_state
(DNSManager.MkInvalidDomainName _) -> do
H.raise $ Log $ SimpleLog $ "[😈] Failed! The domain is not valid!"
(DNSManager.MkDomainDeleted response) -> do
H.raise $ Log $ SimpleLog $ "[TODO] The domain '" <> response.domain <> "' has been deleted!"
(DNSManager.MkRRDeleted response) -> do
H.raise $ Log $ SimpleLog $ "[🎉] RR (rrid: '" <> show response.rrid <> "') has been deleted!"
-- Remove the resource record.
state <- H.get
H.modify_ _ { _srr = A.filter (\rr -> rr.rrid /= response.rrid) state._srr
@ -543,15 +512,9 @@ handleQuery = case _ of
let new_error_hash = Hash.delete response.rrid state._errors
H.modify_ _ { _errors = new_error_hash }
(DNSManager.MkZone response) -> do
H.raise $ Log $ SimpleLog $ "[🎉] Zone received!"
add_entries response.zone.resources
(DNSManager.MkInvalidRR response) -> do
H.raise $ Log $ SimpleLog $ "[😈] Invalid resource record: " <> A.intercalate ", " response.errors
(DNSManager.MkSuccess _) -> do
H.raise $ Log $ SimpleLog $ "[🎉] Success!"
-- WTH?!
_ -> do
H.raise $ Log $ SimpleLog $ "[😈] Failed! dnsmanager daemon didn't send a valid message."
_ -> H.raise $ Log $ SimpleLog $ "[😈] Message not handled in ZoneInterface."
pure (Just a)
ConnectionIsDown a -> do