Add a custom ActivityPub actor type: Project

This commit is contained in:
fr33domlover 2019-03-20 10:36:00 +00:00
parent 3f2a178830
commit ade1157a04

View file

@ -154,19 +154,22 @@ instance ActivityPub a => ToJSON (Doc a) where
$ "@context" .= jsonldContext (proxy v)
<> toSeries h v
data ActorType = ActorTypePerson | ActorTypeOther Text
data ActorType = ActorTypePerson | ActorTypeProject | ActorTypeOther Text
instance FromJSON ActorType where
parseJSON = withText "ActorType" $ \ t ->
pure $ case t of
"Person" -> ActorTypePerson
_ -> ActorTypeOther t
parseJSON = withText "ActorType" $ pure . parse
where
parse t
| t == "Person" = ActorTypePerson
| t == frg <> "Project" = ActorTypeProject
| otherwise = ActorTypeOther t
instance ToJSON ActorType where
toJSON = error "toJSON ActorType"
toEncoding at =
toEncoding $ case at of
ActorTypePerson -> "Person"
ActorTypeProject -> frg <> "Project"
ActorTypeOther t -> t
{-