45 lines
902 B
Haskell
45 lines
902 B
Haskell
module Fedi.Types where
|
|
|
|
import GHC.Generics (Generic)
|
|
import Data.Aeson qualified as A
|
|
import Data.Text qualified as T
|
|
|
|
data Rel = Self
|
|
deriving Show
|
|
|
|
instance A.ToJSON Rel where
|
|
toJSON Self = A.String "self"
|
|
|
|
|
|
data LinkType = ActivityJson
|
|
deriving Show
|
|
|
|
instance A.ToJSON LinkType where
|
|
toJSON ActivityJson = A.String "application/activity+json"
|
|
|
|
type Url = String
|
|
type Domain = String
|
|
type Username = String
|
|
|
|
newtype Pem = Pem T.Text
|
|
deriving Show
|
|
deriving A.FromJSON via T.Text
|
|
|
|
instance A.ToJSON Pem where
|
|
toJSON (Pem pem) = A.String pem
|
|
|
|
data UserDetails
|
|
= UserDetails
|
|
{ domain :: Domain
|
|
, username :: String
|
|
, name :: String
|
|
, summary :: String
|
|
, icon :: Url
|
|
, publicPem :: Pem
|
|
, privatePem :: FilePath
|
|
}
|
|
deriving (Generic, A.FromJSON)
|
|
|
|
actorUrl :: UserDetails -> Url
|
|
actorUrl details =
|
|
"https://" <> details.domain <> "/" <> details.username
|