diff --git a/src/Vervis/Handler/Inbox.hs b/src/Vervis/Handler/Inbox.hs index be84f5d..259b14b 100644 --- a/src/Vervis/Handler/Inbox.hs +++ b/src/Vervis/Handler/Inbox.hs @@ -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| -
#{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