UI, DB: Store debug reports in DB and link to them from navbar
This commit is contained in:
parent
b8922b3157
commit
9ce745c725
10 changed files with 41 additions and 30 deletions
5
migrations/648_2024-07-06_report.model
Normal file
5
migrations/648_2024-07-06_report.model
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Report
|
||||||
|
time UTCTime
|
||||||
|
message Text
|
||||||
|
types ListOfByteStrings
|
||||||
|
body ByteString
|
|
@ -1,6 +1,6 @@
|
||||||
{- This file is part of Vervis.
|
{- This file is part of Vervis.
|
||||||
-
|
-
|
||||||
- Written in 2016, 2018, 2019, 2020, 2022, 2023
|
- Written in 2016, 2018, 2019, 2020, 2022, 2023, 2024
|
||||||
- by fr33domlover <fr33domlover@riseup.net>.
|
- by fr33domlover <fr33domlover@riseup.net>.
|
||||||
-
|
-
|
||||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||||
|
@ -202,11 +202,6 @@ makeFoundation appSettings = do
|
||||||
|
|
||||||
appActorFetchShare <- newResultShare actorFetchShareAction
|
appActorFetchShare <- newResultShare actorFetchShareAction
|
||||||
|
|
||||||
appActivities <-
|
|
||||||
case appInboxDebugReportLength appSettings of
|
|
||||||
Nothing -> return Nothing
|
|
||||||
Just n -> Just . (n,) <$> newTVarIO mempty
|
|
||||||
|
|
||||||
-- We need a log function to create a connection pool. We need a connection
|
-- We need a log function to create a connection pool. We need a connection
|
||||||
-- pool to create our foundation. And we need our foundation to get a
|
-- pool to create our foundation. And we need our foundation to get a
|
||||||
-- logging function. To get out of this loop, we initially create a
|
-- logging function. To get out of this loop, we initially create a
|
||||||
|
|
|
@ -137,8 +137,6 @@ data App = App
|
||||||
, appTheater :: Theater
|
, appTheater :: Theater
|
||||||
, appEnv :: Env
|
, appEnv :: Env
|
||||||
, appPersonLauncher :: MVar (PersonId, MVar Bool)
|
, appPersonLauncher :: MVar (PersonId, MVar Bool)
|
||||||
|
|
||||||
, appActivities :: Maybe (Int, TVar (Vector ActivityReport))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Aliases for the routes file, because it doesn't like spaces in path piece
|
-- Aliases for the routes file, because it doesn't like spaces in path piece
|
||||||
|
|
|
@ -94,7 +94,7 @@ import Yesod.Persist.Core
|
||||||
import qualified Data.ByteString.Char8 as BC
|
import qualified Data.ByteString.Char8 as BC
|
||||||
import qualified Data.HashMap.Strict as M
|
import qualified Data.HashMap.Strict as M
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.Lazy.Encoding as TLE
|
import qualified Data.Text.Encoding as TE
|
||||||
import qualified Database.Esqueleto as E
|
import qualified Database.Esqueleto as E
|
||||||
|
|
||||||
import Database.Persist.JSON
|
import Database.Persist.JSON
|
||||||
|
@ -792,8 +792,7 @@ postPublishR = do
|
||||||
|
|
||||||
getInboxDebugR :: Handler Html
|
getInboxDebugR :: Handler Html
|
||||||
getInboxDebugR = do
|
getInboxDebugR = do
|
||||||
acts <-
|
acts <- runDB $ selectList [] [Desc ReportId, LimitTo 30]
|
||||||
liftIO . readTVarIO . snd =<< maybe notFound return =<< getsYesod appActivities
|
|
||||||
defaultLayout
|
defaultLayout
|
||||||
[whamlet|
|
[whamlet|
|
||||||
<p>
|
<p>
|
||||||
|
@ -805,14 +804,14 @@ getInboxDebugR = do
|
||||||
result. Activities that aren't understood or their processing
|
result. Activities that aren't understood or their processing
|
||||||
fails get listed here too, with a report of what exactly
|
fails get listed here too, with a report of what exactly
|
||||||
happened.
|
happened.
|
||||||
<p>Last 10 activities posted:
|
<p>Last 30 activities posted:
|
||||||
<ul>
|
<ul>
|
||||||
$forall ActivityReport time msg ctypes body <- acts
|
$forall Entity _ (Report time msg ctypes body) <- acts
|
||||||
<li>
|
<li>
|
||||||
<div>#{show time}
|
<div>#{show time}
|
||||||
<div>#{msg}
|
<div>#{msg}
|
||||||
<div><code>#{intercalate " | " $ map BC.unpack ctypes}
|
<div><code>#{intercalate " | " $ map BC.unpack ctypes}
|
||||||
<div><pre>#{TLE.decodeUtf8 body}
|
<div><pre>#{TE.decodeUtf8 body}
|
||||||
|]
|
|]
|
||||||
|
|
||||||
{-
|
{-
|
||||||
|
|
|
@ -3829,6 +3829,8 @@ changes hLocal ctx =
|
||||||
, addFieldRefRequiredEmpty "EffortTopicLocal" "topic" "Resource"
|
, addFieldRefRequiredEmpty "EffortTopicLocal" "topic" "Resource"
|
||||||
-- 647
|
-- 647
|
||||||
, removeField "Effort" "topic"
|
, removeField "Effort" "topic"
|
||||||
|
-- 648
|
||||||
|
, addEntities model_648_report
|
||||||
]
|
]
|
||||||
|
|
||||||
migrateDB
|
migrateDB
|
||||||
|
|
|
@ -78,6 +78,7 @@ module Vervis.Migration.Entities
|
||||||
, model_626_komponent
|
, model_626_komponent
|
||||||
, model_638_effort_squad
|
, model_638_effort_squad
|
||||||
, model_639_component_convey
|
, model_639_component_convey
|
||||||
|
, model_648_report
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
@ -305,3 +306,8 @@ model_638_effort_squad = $(schema "638_2024-05-14_effort_squad")
|
||||||
|
|
||||||
model_639_component_convey :: [Entity SqlBackend]
|
model_639_component_convey :: [Entity SqlBackend]
|
||||||
model_639_component_convey = $(schema "639_2024-05-14_component_convey")
|
model_639_component_convey = $(schema "639_2024-05-14_component_convey")
|
||||||
|
|
||||||
|
type ListOfByteStrings = [ByteString]
|
||||||
|
|
||||||
|
model_648_report :: [Entity SqlBackend]
|
||||||
|
model_648_report = $(schema "648_2024-07-06_report")
|
||||||
|
|
|
@ -68,6 +68,7 @@ import Yesod.Form.Types
|
||||||
import Yesod.Persist.Core
|
import Yesod.Persist.Core
|
||||||
|
|
||||||
import qualified Data.ByteString.Char8 as BC (unpack)
|
import qualified Data.ByteString.Char8 as BC (unpack)
|
||||||
|
import qualified Data.ByteString.Lazy as BL
|
||||||
import qualified Data.HashMap.Strict as M
|
import qualified Data.HashMap.Strict as M
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.Lazy as TL
|
import qualified Data.Text.Lazy as TL
|
||||||
|
@ -277,22 +278,14 @@ postInbox recipByKey = do
|
||||||
sendResponseStatus badRequest400 err
|
sendResponseStatus badRequest400 err
|
||||||
Right _ -> return ()
|
Right _ -> return ()
|
||||||
where
|
where
|
||||||
recordActivity
|
recordActivity :: UTCTime -> Either Text (Object, Text) -> [ContentType] -> Handler ()
|
||||||
:: (MonadSite m, SiteEnv m ~ App)
|
|
||||||
=> UTCTime -> Either Text (Object, Text) -> [ContentType] -> m ()
|
|
||||||
recordActivity now result contentTypes = do
|
recordActivity now result contentTypes = do
|
||||||
macts <- asksSite appActivities
|
|
||||||
for_ macts $ \ (size, acts) ->
|
|
||||||
liftIO $ atomically $ modifyTVar' acts $ \ vec ->
|
|
||||||
let (msg, body) =
|
let (msg, body) =
|
||||||
case result of
|
case result of
|
||||||
Left t -> (t, "{?}")
|
Left t -> (t, "{?}")
|
||||||
Right (o, t) -> (t, encodePretty o)
|
Right (o, t) -> (t, BL.toStrict $ encodePretty o)
|
||||||
item = ActivityReport now msg contentTypes body
|
item = Report now msg contentTypes body
|
||||||
vec' = item `V.cons` vec
|
runDB $ insert_ item
|
||||||
in if V.length vec' > size
|
|
||||||
then V.init vec'
|
|
||||||
else vec'
|
|
||||||
parseAuthenticatedLocalActivityURI
|
parseAuthenticatedLocalActivityURI
|
||||||
:: (MonadSite m, YesodHashids (SiteEnv m))
|
:: (MonadSite m, YesodHashids (SiteEnv m))
|
||||||
=> LocalActorBy Key -> Maybe LocalURI -> ExceptT Text m OutboxItemId
|
=> LocalActorBy Key -> Maybe LocalURI -> ExceptT Text m OutboxItemId
|
||||||
|
|
|
@ -44,6 +44,9 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
<span>
|
<span>
|
||||||
<a href=@{RemoteActorsR}>
|
<a href=@{RemoteActorsR}>
|
||||||
[🌁 Browse remote actors]
|
[🌁 Browse remote actors]
|
||||||
|
<span>
|
||||||
|
<a href=@{InboxDebugR}>
|
||||||
|
[💥 Inbox Debug Reports]
|
||||||
<span>
|
<span>
|
||||||
<a href=@{HomeR}>
|
<a href=@{HomeR}>
|
||||||
[📣 Publish an activity]
|
[📣 Publish an activity]
|
||||||
|
@ -66,6 +69,10 @@ $# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
<a href=@{AuthR LoginR}>Log in.
|
<a href=@{AuthR LoginR}>Log in.
|
||||||
Or
|
Or
|
||||||
<a href=@{AuthR newAccountR}>Sign up.
|
<a href=@{AuthR newAccountR}>Sign up.
|
||||||
|
<span> -|-
|
||||||
|
<span>
|
||||||
|
<a href=@{InboxDebugR}>
|
||||||
|
[💥 Inbox Debug Reports]
|
||||||
|
|
||||||
$if federationDisabled
|
$if federationDisabled
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
-- with this software. If not, see
|
-- with this software. If not, see
|
||||||
-- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
-- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
|
Report
|
||||||
|
time UTCTime
|
||||||
|
message Text
|
||||||
|
types [ByteString]
|
||||||
|
body ByteString
|
||||||
|
|
||||||
-- ========================================================================= --
|
-- ========================================================================= --
|
||||||
-- Remote Object
|
-- Remote Object
|
||||||
-- ========================================================================= --
|
-- ========================================================================= --
|
||||||
|
|
|
@ -128,7 +128,7 @@
|
||||||
/browse BrowseR GET
|
/browse BrowseR GET
|
||||||
/notifications NotificationsR GET POST
|
/notifications NotificationsR GET POST
|
||||||
-- /publish PublishR GET POST
|
-- /publish PublishR GET POST
|
||||||
/inbox InboxDebugR GET
|
/inbox-debug InboxDebugR GET
|
||||||
|
|
||||||
/ssh-keys KeysR GET POST
|
/ssh-keys KeysR GET POST
|
||||||
/ssh-keys/#SshKeyKeyHashid/delete KeyDeleteR POST
|
/ssh-keys/#SshKeyKeyHashid/delete KeyDeleteR POST
|
||||||
|
|
Loading…
Reference in a new issue