Refactor libravatar invocation into a separate function + tell it not to try Gravatar
This commit is contained in:
parent
25a1e00cd7
commit
ad6d783dea
1 changed files with 5 additions and 1 deletions
|
@ -9,6 +9,10 @@ import qualified Data.Map as M
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Network.Libravatar as L
|
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 t -> (Key t, t)
|
||||||
entityToTuple (Entity key value) = (key, value)
|
entityToTuple (Entity key value) = (key, value)
|
||||||
|
|
||||||
|
@ -27,7 +31,7 @@ routeFromPgp PgpKey { pgpKeyFingerprint = f, pgpKeyHash = h } =
|
||||||
|
|
||||||
hcard :: Entity User -> Widget
|
hcard :: Entity User -> Widget
|
||||||
hcard (Entity userId user) = do
|
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
|
mcurrentRoute <- getCurrentRoute
|
||||||
userProfiles <- handlerToWidget . runDB $ do
|
userProfiles <- handlerToWidget . runDB $ do
|
||||||
profiles <- map entityVal <$> selectList [ProfileUserId ==. userId] []
|
profiles <- map entityVal <$> selectList [ProfileUserId ==. userId] []
|
||||||
|
|
Loading…
Reference in a new issue