Refactor libravatar invocation into a separate function + tell it not to try Gravatar

This commit is contained in:
Danielle McLean 2017-10-04 10:37:37 +11:00
parent 25a1e00cd7
commit ad6d783dea
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5

View file

@ -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] []