From ad6d783dea69474875fccccef67c47e70f29f5d2 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Wed, 4 Oct 2017 10:37:37 +1100 Subject: [PATCH] Refactor libravatar invocation into a separate function + tell it not to try Gravatar --- src/Widget/Hcard.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Widget/Hcard.hs b/src/Widget/Hcard.hs index cc907b7..227ca45 100644 --- a/src/Widget/Hcard.hs +++ b/src/Widget/Hcard.hs @@ -9,6 +9,10 @@ import qualified Data.Map as M import qualified Data.Text as T import qualified Network.Libravatar as L +libravatar :: (MonadIO m) => User -> m (Maybe Text) +libravatar = liftIO . flip L.avatarUrl opts . L.Email . userEmail + where opts = def { L.optSecure = True, L.optSize = L.Size 512, L.optTryGravatar = False } + entityToTuple :: Entity t -> (Key t, t) entityToTuple (Entity key value) = (key, value) @@ -27,7 +31,7 @@ routeFromPgp PgpKey { pgpKeyFingerprint = f, pgpKeyHash = h } = hcard :: Entity User -> Widget hcard (Entity userId user) = do - maybeAvatar <- liftIO $ L.avatarUrl (L.Email $ userEmail user) def { L.optSecure = True, L.optSize = L.Size 512 } + maybeAvatar <- libravatar user mcurrentRoute <- getCurrentRoute userProfiles <- handlerToWidget . runDB $ do profiles <- map entityVal <$> selectList [ProfileUserId ==. userId] []