Display summary and pretty JSON for notifications and for outboxes

This commit is contained in:
fr33domlover 2019-06-30 01:41:54 +00:00
parent 2109974709
commit d8da1f2abf
3 changed files with 17 additions and 8 deletions

View file

@ -127,6 +127,11 @@ import Vervis.RemoteActorStore
import Yesod.RenderSource
import Vervis.Settings
objectSummary o =
case M.lookup "summary" o of
Just (String t) | not (T.null t) -> Just t
_ -> Nothing
getInboxR :: Handler Html
getInboxR = do
acts <-
@ -236,10 +241,6 @@ getInbox here getInboxId = do
error $ "InboxItem #" ++ show ibid ++ " both local and remote"
(Just act, Nothing) -> persistJSONObject act
(Nothing, Just obj) -> persistJSONObject obj
objectSummary o =
case M.lookup "summary" o of
Just (String t) | not (T.null t) -> Just t
_ -> Nothing
getSharerInboxR :: ShrIdent -> Handler TypedContent
getSharerInboxR shr = getInbox here getInboxId

View file

@ -17,9 +17,12 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<input type=submit value="Mark all as read">
<div>
$forall (activity, widget, enctype) <- notifications
<div><pre>
#{TLB.toLazyText $ encodePrettyToTextBuilder activity}
$forall (obj, widget, enctype) <- notifications
$maybe summary <- objectSummary obj
<div>
^{preEscapedToHtml summary}
$nothing
^{renderPrettyJSONSkylighting obj}
<form method=POST action=@{NotificationsR shr} enctype=#{enctype}>
^{widget}
<input type=submit value="Mark as read">

View file

@ -22,6 +22,11 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<div>
$forall Entity _ (OutboxItem _ doc published) <- items
<div>#{showTime published}
<div>^{renderPrettyJSON' $ BL.fromStrict $ persistJSONBytes doc}
$with obj <- persistJSONObject doc
$maybe summary <- objectSummary obj
<div>
^{preEscapedToHtml summary}
$nothing
^{renderPrettyJSONSkylighting obj}
^{pageNav}