From 425d797d8c3d238a3182cfd20e0059f40fc5ec75 Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Tue, 12 Dec 2023 19:10:19 -0600 Subject: [PATCH] fix: add delays --- src/Effect.Email.purs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Effect.Email.purs b/src/Effect.Email.purs index 2d10b89..494416d 100644 --- a/src/Effect.Email.purs +++ b/src/Effect.Email.purs @@ -15,13 +15,15 @@ import Data.Email (Email) import Data.Email as Email import Data.Eq.Generic (genericEq) import Data.Generic.Rep (class Generic) +import Data.Int as Int import Data.Maybe (maybe) +import Data.Newtype (wrap) import Data.Nullable (Nullable) import Data.Nullable as Nullable import Data.Show.Generic (genericShow) import Data.Traversable (for_) import Effect (Effect) -import Effect.Aff (Aff) +import Effect.Aff (Aff, delay) import Type.Function (type ($)) foreign import checkEmailImpl :: String -> Effect $ Promise $ QEDResult @@ -96,6 +98,7 @@ deliverable email' = attempt n | n < 10 = do + delay $ wrap $ 10.0 * Int.toNumber n res <- runExceptT $ deliverableOnce email' case res of Left (EmailUnreachable _) -> pure $ Loop $ n + 1 @@ -104,8 +107,17 @@ deliverable email' = | otherwise = pure $ Done $ Left $ EmailUnreachable email' in do - wildcard <- liftEither $ lmap (const $ EmailSyntaxInvalid email') $ Email.parse $ "*@" <> Email.domain email' + wildcard <- liftEither + $ lmap + ( const + $ EmailSyntaxInvalid email' + ) + $ Email.parse + $ "b13f0cb1dd2d4404a91bf874e9fa8f5b@" <> Email.domain email' + res <- lift $ runExceptT $ deliverableOnce wildcard case res of Right _ -> throwError $ EmailWildcardExists email' - _ -> ExceptT $ tailRecM attempt 0 + _ -> do + lift $ delay $ wrap $ 100.0 + ExceptT $ tailRecM attempt 0