From ade1157a0408dd2da4530cbe48e3c7b006ca1a2d Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Wed, 20 Mar 2019 10:36:00 +0000 Subject: [PATCH] Add a custom ActivityPub actor type: Project --- src/Web/ActivityPub.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Web/ActivityPub.hs b/src/Web/ActivityPub.hs index bccaa18..ccc09ea 100644 --- a/src/Web/ActivityPub.hs +++ b/src/Web/ActivityPub.hs @@ -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 {-