{- This file is part of Vervis. - - Written in 2019 by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - - The author(s) have dedicated all copyright and related and neighboring - rights to this software to the public domain worldwide. This software is - distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along - with this software. If not, see - . -} module Vervis.Handler.Inbox ( getInboxR , getSharerInboxR , getProjectInboxR , postSharerInboxR , postProjectInboxR , getPublishR , getOutboxR , getOutboxItemR , postOutboxR , getActorKey1R , getActorKey2R ) where import Prelude import Control.Applicative ((<|>)) import Control.Concurrent.STM.TVar (readTVarIO, modifyTVar') import Control.Exception (displayException) import Control.Monad import Control.Monad.IO.Class (liftIO) import Control.Monad.Logger.CallStack import Control.Monad.STM (atomically) import Control.Monad.Trans.Except import Control.Monad.Trans.Maybe import Crypto.Error (CryptoFailable (..)) import Crypto.PubKey.Ed25519 (publicKey, signature, verify) import Data.Aeson import Data.Bifunctor (first, second) import Data.Foldable (for_) import Data.HashMap.Strict (HashMap) import Data.List import Data.List.NonEmpty (NonEmpty (..)) import Data.Maybe import Data.PEM (PEM (..)) import Data.Text (Text) import Data.Text.Encoding (encodeUtf8, decodeUtf8') import Data.Text.Lazy.Encoding (decodeUtf8) import Data.Time.Clock (UTCTime, getCurrentTime) import Data.Time.Interval (TimeInterval, toTimeUnit) import Data.Time.Units (Second) import Database.Persist (Entity (..), getBy, insertBy, insert_) import Network.HTTP.Client (Manager, HttpException, requestFromURI) import Network.HTTP.Simple (httpJSONEither, getResponseBody, setRequestManager, addRequestHeader) import Network.HTTP.Types.Header (hDate, hHost) import Network.HTTP.Types.Status import Text.Blaze.Html (Html) import Text.Shakespeare.I18N (RenderMessage) import UnliftIO.Exception (try) import Yesod.Auth (requireAuth) import Yesod.Core (ContentType, defaultLayout, whamlet, toHtml, HandlerSite) import Yesod.Core.Content (TypedContent) import Yesod.Core.Json (requireJsonBody) import Yesod.Core.Handler import Yesod.Form.Fields (Textarea (..), textField, textareaField) import Yesod.Form.Functions import Yesod.Form.Types import Yesod.Persist.Core (runDB, get404) import qualified Data.ByteString.Char8 as BC (unpack) import qualified Data.CaseInsensitive as CI (mk) import qualified Data.HashMap.Strict as M (lookup, insert, adjust, fromList) import qualified Data.Text as T (pack, unpack, concat) import qualified Data.Text.Lazy as TL (toStrict) import qualified Data.Vector as V import qualified Network.Wai as W (requestMethod, rawPathInfo, requestHeaders) import Network.HTTP.Signature hiding (Algorithm (..)) import Yesod.HttpSignature (verifyRequestSignature) import qualified Network.HTTP.Signature as S (Algorithm (..)) import Data.Aeson.Encode.Pretty import Data.Aeson.Local import Database.Persist.Local import Network.FedURI import Web.ActivityPub import Yesod.Auth.Unverified import Yesod.FedURI import Yesod.Hashids import Vervis.ActorKey import Vervis.Federation import Vervis.Foundation import Vervis.Model import Vervis.Model.Ident import Vervis.RemoteActorStore import Vervis.Settings getInboxR :: Handler Html getInboxR = do acts <- liftIO . readTVarIO =<< getsYesod appActivities defaultLayout [whamlet|

Welcome to the ActivityPub inbox test page! Activities received by this Vervis instance are listed here for testing and debugging. To test, go to another Vervis instance and publish something that supports federation (currently, only ticket comments), either through the regular UI or via the /publish page, and then come back here to see the result. Activities that aren't understood or their processing fails get listed here too, with a report of what exactly happened.

Last 10 activities posted: