From 62347d40b2bcb22d3344fb34e1bf1676ff290eb9 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Mon, 3 Jul 2023 12:17:44 +0200 Subject: [PATCH] Domain can be deleted - with automatic update of the own domain list. --- src/App/DNSManagerDomainsInterface.purs | 7 ++++++- src/App/Messages/DNSManagerDaemon.purs | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/App/DNSManagerDomainsInterface.purs b/src/App/DNSManagerDomainsInterface.purs index 4122bf8..fe40fc5 100644 --- a/src/App/DNSManagerDomainsInterface.purs +++ b/src/App/DNSManagerDomainsInterface.purs @@ -12,7 +12,7 @@ module App.DNSManagerDomainsInterface where Authentication is automatic with the token. -} -import Prelude (Unit, Void, bind, discard, map, otherwise, show, void, when, ($), (&&), (<$>), (<<<), (<>), (>>=)) +import Prelude (Unit, Void, bind, discard, map, otherwise, show, void, when, ($), (&&), (<$>), (<<<), (<>), (>>=), (/=)) import Bulma as Bulma @@ -378,6 +378,11 @@ handleAction = case _ of (DNSManager.MkInvalidDomainName _) -> do appendMessage $ "[😈] Failed! The domain is not valid!" + (DNSManager.MkDomainDeleted response) -> do + { my_domains } <- H.get + appendMessage $ "[😈] The domain '" <> response.domain <> "' has been deleted!" + handleAction $ UpdateMyDomains $ A.filter ((/=) response.domain) my_domains + (DNSManager.MkSuccess _) -> do appendMessage $ "[😈] Success!" -- WTH?! diff --git a/src/App/Messages/DNSManagerDaemon.purs b/src/App/Messages/DNSManagerDaemon.purs index 26a3759..2e7470a 100644 --- a/src/App/Messages/DNSManagerDaemon.purs +++ b/src/App/Messages/DNSManagerDaemon.purs @@ -129,6 +129,10 @@ type InvalidDomainName = { } codecInvalidDomainName :: CA.JsonCodec InvalidDomainName codecInvalidDomainName = CA.object "InvalidDomainName" (CAR.record { }) +{- 9 -} +type DomainDeleted = { domain :: String } +codecDomainDeleted :: CA.JsonCodec DomainDeleted +codecDomainDeleted = CA.object "DomainDeleted" (CAR.record { domain: CA.string }) {- 10 -} -- For now, Error is just an alias on String. @@ -209,6 +213,7 @@ data AnswerMessage | MkRRNotFound RRNotFound -- 6 | MkUnacceptableDomain UnacceptableDomain -- 7 | MkInvalidDomainName InvalidDomainName -- 8 + | MkDomainDeleted DomainDeleted -- 9 | MkInvalidZone InvalidZone -- 10 | MkDomainChanged DomainChanged -- 11 | MkZone Zone -- 12 @@ -254,6 +259,7 @@ decode number string 6 -> error_management codecRRNotFound MkRRNotFound 7 -> error_management codecUnacceptableDomain MkUnacceptableDomain 8 -> error_management codecInvalidDomainName MkInvalidDomainName + 9 -> error_management codecDomainDeleted MkDomainDeleted 10 -> error_management codecInvalidZone MkInvalidZone 11 -> error_management codecDomainChanged MkDomainChanged 12 -> error_management codecZone MkZone