UI: Inbox: For each item, display the result of processing

This commit is contained in:
Pere Lev 2024-04-27 19:29:33 +03:00
parent eef4c3f79a
commit b519bbe7b9
No known key found for this signature in database
GPG key ID: 5252C5C863E5E57D
2 changed files with 17 additions and 6 deletions

View file

@ -1,6 +1,7 @@
{- This file is part of Vervis.
-
- Written in 2019, 2020, 2022, 2023 by fr33domlover <fr33domlover@riseup.net>.
- Written in 2019, 2020, 2022, 2023, 2024
- by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
@ -53,6 +54,7 @@ import Data.Traversable
import Database.Persist
import Database.Persist.Sql
import Network.HTTP.Types.Status
import Optics.Core
import Text.Blaze.Html (Html, preEscapedToHtml)
import Text.Blaze.Html.Renderer.Text
import Text.HTML.SanitizeXSS
@ -181,7 +183,7 @@ getInbox here actor hash = do
then Just $ pageUrl $ current + 1
else Nothing
, collectionPageStartIndex = Nothing
, collectionPageItems = map fst items
, collectionPageItems = map (view _1) items
}
provideRep $ do
let pageNav = navWidget navModel
@ -215,18 +217,19 @@ getInbox here actor hash = do
, ob E.?. OutboxItemPublished
, ract E.?. RemoteActivityContent
, ract E.?. RemoteActivityReceived
, ib E.^. InboxItemResult
)
adaptItem
(E.Value ibid, E.Value mact, E.Value mpub, E.Value mobj, E.Value mrec) =
(E.Value ibid, E.Value mact, E.Value mpub, E.Value mobj, E.Value mrec, E.Value result) =
case (mact, mpub, mobj, mrec) of
(Nothing, Nothing, Nothing, Nothing) ->
error $ ibiidString ++ " neither local nor remote"
(Just _, Just _, Just _, Just _) ->
error $ ibiidString ++ " both local and remote"
(Just act, Just pub, Nothing, Nothing) ->
(persistJSONObject act, (pub, False))
(persistJSONObject act, (pub, False), result)
(Nothing, Nothing, Just obj, Just rec) ->
(persistJSONObject obj, (rec, True))
(persistJSONObject obj, (rec, True), result)
_ -> error $ "Unexpected query result for " ++ ibiidString
where
ibiidString = "InboxItem #" ++ show (fromSqlKey ibid)

View file

@ -20,7 +20,7 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
^{pageNav}
<div>
$forall (obj, (time, isRemote)) <- items
$forall (obj, (time, isRemote), result) <- items
<div>
$if isRemote
Received #
@ -29,6 +29,14 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
<a href="#{objectId obj}">
#{showTime time}
<div>
Result:
<i>
$if T.null result
[None]
$else
#{result}
$maybe summary <- objectSummary obj
<div>
^{preEscapedToHtml summary}