Serve trivial HTML (that just displays the JSON object) in getMessageR

This commit is contained in:
fr33domlover 2019-05-24 16:09:58 +00:00
parent bd99729656
commit 5479c99e1c

View file

@ -42,6 +42,7 @@ import Yesod.Form.Functions (runFormPost)
import Yesod.Form.Types (FormResult (..)) import Yesod.Form.Types (FormResult (..))
import Yesod.Persist.Core (runDB, get404, getBy404) import Yesod.Persist.Core (runDB, get404, getBy404)
import Data.Aeson.Encode.Pretty.ToEncoding
import Network.FedURI import Network.FedURI
import Web.ActivityPub import Web.ActivityPub
import Yesod.Auth.Unverified import Yesod.Auth.Unverified
@ -107,7 +108,8 @@ getNodeL getdid lmid = do
-} -}
getDiscussionMessage :: ShrIdent -> LocalMessageId -> Handler TypedContent getDiscussionMessage :: ShrIdent -> LocalMessageId -> Handler TypedContent
getDiscussionMessage shr lmid = selectRep $ provideAP $ runDB $ do getDiscussionMessage shr lmid = do
doc <- runDB $ do
sid <- getKeyBy404 $ UniqueSharer shr sid <- getKeyBy404 $ UniqueSharer shr
pid <- getKeyBy404 $ UniquePersonIdent sid pid <- getKeyBy404 $ UniquePersonIdent sid
lm <- get404 lmid lm <- get404 lmid
@ -158,6 +160,13 @@ getDiscussionMessage shr lmid = selectRep $ provideAP $ runDB $ do
, notePublished = Just $ messageCreated m , notePublished = Just $ messageCreated m
, noteContent = messageContent m , noteContent = messageContent m
} }
selectRep $ do
provideAP $ pure doc
provideRep $
defaultLayout
[whamlet|
<div><pre>#{encodePrettyToLazyText doc}
|]
getTopReply :: Route App -> Handler Html getTopReply :: Route App -> Handler Html
getTopReply replyP = do getTopReply replyP = do