eidolon/Handler/Profile.hs

21 lines
629 B
Haskell
Raw Normal View History

module Handler.Profile where
import Import
2014-08-15 11:25:33 +00:00
import Data.Maybe
2014-08-14 00:26:21 +00:00
getProfileR :: UserId -> Handler Html
2014-08-18 01:10:33 +00:00
getProfileR ownerId = do
owner <- runDB $ get ownerId
2014-08-15 11:25:33 +00:00
ownerName <- lift $ pure $ userName $ fromJust owner
2014-08-18 01:10:33 +00:00
userAlbs <- runDB $ selectList [AlbumOwner ==. ownerId] [Desc AlbumTitle]
recentMedia <- (runDB $ selectList [MediumOwner ==. ownerId] [Desc MediumTime])
2014-08-15 11:25:33 +00:00
msu <- lookupSession "userId"
2014-08-18 01:10:33 +00:00
presence <- case msu of
2014-08-15 11:25:33 +00:00
Just tempUserId -> do
userId <- lift $ pure $ getUserIdFromText tempUserId
2014-08-18 01:10:33 +00:00
return (userId == ownerId)
2014-08-17 20:58:33 +00:00
Nothing ->
2014-08-18 01:10:33 +00:00
return False
defaultLayout $ do
$(widgetFile "profile")