Pretty JSON display for getActorKey1/2 and getOutboxItemR
This commit is contained in:
parent
499479b662
commit
ade24bb534
1 changed files with 13 additions and 17 deletions
|
@ -92,6 +92,7 @@ import qualified Network.HTTP.Signature as S (Algorithm (..))
|
|||
import Database.Persist.JSON
|
||||
import Network.FedURI
|
||||
import Web.ActivityPub
|
||||
import Yesod.ActivityPub
|
||||
import Yesod.Auth.Unverified
|
||||
import Yesod.FedURI
|
||||
import Yesod.Hashids
|
||||
|
@ -426,18 +427,14 @@ getOutboxR shr = do
|
|||
getOutboxItemR :: ShrIdent -> KeyHashid OutboxItem -> Handler TypedContent
|
||||
getOutboxItemR shr obikhid = do
|
||||
obiid <- decodeKeyHashid404 obikhid
|
||||
doc <- runDB $ do
|
||||
Doc h act <- runDB $ do
|
||||
sid <- getKeyBy404 $ UniqueSharer shr
|
||||
p <- getValBy404 $ UniquePersonIdent sid
|
||||
obi <- get404 obiid
|
||||
unless (outboxItemOutbox obi == personOutbox p) notFound
|
||||
return $ persistJSONValue $ outboxItemActivity obi
|
||||
selectRep $ do
|
||||
provideAP $ pure doc
|
||||
provideRep $ defaultLayout $
|
||||
[whamlet|
|
||||
<div><pre>#{AEP.encodePrettyToLazyText doc}
|
||||
|]
|
||||
let here = OutboxItemR shr obikhid
|
||||
provideHtmlAndAP' h act $ redirect (here, [("prettyjson", "true")])
|
||||
|
||||
postOutboxR :: ShrIdent -> Handler Html
|
||||
postOutboxR shrAuthor = do
|
||||
|
@ -491,19 +488,18 @@ postOutboxR shrAuthor = do
|
|||
defaultLayout $ activityWidget shrAuthor widget enctype
|
||||
|
||||
getActorKey :: ((ActorKey, ActorKey, Bool) -> ActorKey) -> Route App -> Handler TypedContent
|
||||
getActorKey choose route = selectRep $ provideAP $ do
|
||||
getActorKey choose route = do
|
||||
actorKey <-
|
||||
liftIO . fmap (actorKeyPublicBin . choose) . readTVarIO =<<
|
||||
getsYesod appActorKeys
|
||||
route2uri <- getEncodeRouteHome
|
||||
let (host, id_) = f2l $ route2uri route
|
||||
return $ Doc host PublicKey
|
||||
{ publicKeyId = id_
|
||||
, publicKeyExpires = Nothing
|
||||
, publicKeyOwner = OwnerInstance
|
||||
, publicKeyMaterial = actorKey
|
||||
--, publicKeyAlgo = Just AlgorithmEd25519
|
||||
}
|
||||
encodeRouteLocal <- getEncodeRouteLocal
|
||||
let key = PublicKey
|
||||
{ publicKeyId = encodeRouteLocal route
|
||||
, publicKeyExpires = Nothing
|
||||
, publicKeyOwner = OwnerInstance
|
||||
, publicKeyMaterial = actorKey
|
||||
}
|
||||
provideHtmlAndAP key $ redirect (route, [("prettyjson", "true")])
|
||||
|
||||
getActorKey1R :: Handler TypedContent
|
||||
getActorKey1R = getActorKey (\ (k1, _, _) -> k1) ActorKey1R
|
||||
|
|
Loading…
Reference in a new issue