From 95a0806ef357a0d444b976f3617f0996e8d1d432 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Sat, 25 May 2019 13:01:15 +0000 Subject: [PATCH] Fix MessageR, setting audience to the one specified in the Create activity --- src/Vervis/Handler/Discussion.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Vervis/Handler/Discussion.hs b/src/Vervis/Handler/Discussion.hs index 66fe8da..392cd03 100644 --- a/src/Vervis/Handler/Discussion.hs +++ b/src/Vervis/Handler/Discussion.hs @@ -43,6 +43,7 @@ import Yesod.Form.Types (FormResult (..)) import Yesod.Persist.Core (runDB, get404, getBy404) import Data.Aeson.Encode.Pretty.ToEncoding +import Database.Persist.JSON import Network.FedURI import Web.ActivityPub import Yesod.Auth.Unverified @@ -147,6 +148,8 @@ getDiscussionMessage shr lmid = do rs <- getJust $ remoteMessageAuthor rmParent i <- getJust $ remoteActorInstance rs return $ l2f (instanceHost i) (remoteActorIdent rs) + ob <- getJust $ localMessageCreate lm + let activity = docValue $ persistJSONValue $ outboxItemActivity ob host <- getsYesod $ appInstanceHost . appSettings route2local <- getEncodeRouteLocal @@ -154,7 +157,10 @@ getDiscussionMessage shr lmid = do return $ Doc host Note { noteId = Just $ route2local $ MessageR shr lmhid , noteAttrib = route2local $ SharerR shr - , noteAudience = error "TODO noteAudience" + , noteAudience = + case activitySpecific activity of + CreateActivity (Create note) -> noteAudience note + _ -> error $ "lmid#" ++ show (fromSqlKey lmid) ++ "'s create isn't a Create activity!" , noteReplyTo = Just $ fromMaybe uContext muParent , noteContext = Just uContext , notePublished = Just $ messageCreated m