diff --git a/src/Vervis/Actor/Person.hs b/src/Vervis/Actor/Person.hs index 0b122aa..08bb037 100644 --- a/src/Vervis/Actor/Person.hs +++ b/src/Vervis/Actor/Person.hs @@ -362,6 +362,35 @@ personInvite now recipPersonID author body mfwd luInvite invite = do "I'm the target; Inserted to inbox; \ \Forwarded to followers if addressed" +-- Meaning: Someone asked to join a resource +-- Behavior: Insert to my inbox +personJoin + :: UTCTime + -> PersonId + -> RemoteAuthor + -> ActivityBody + -> Maybe (RecipientRoutes, ByteString) + -> LocalURI + -> AP.Join URIMode + -> ActE (Text, Act (), Next) +personJoin now recipPersonID author body mfwd luJoin join = do + + -- Check input + _resource <- parseJoin join + + maybeJoinID <- lift $ withDB $ do + + -- Grab recipient person from DB + (_personRecip, actorRecip) <- do + p <- getJust recipPersonID + (p,) <$> getJust (personActor p) + + insertToInbox now author body (actorInbox actorRecip) luJoin True + + case maybeJoinID of + Nothing -> done "I already have this activity in my inbox" + Just _joinID -> done "Inserted to my inbox" + -- Meaning: A remote actor published a Grant -- Behavior: -- * Insert to my inbox @@ -469,6 +498,8 @@ personBehavior now personID (Right (VerseRemote author body mfwd luActivity)) = personGrant now personID author body mfwd luActivity grant AP.InviteActivity invite -> personInvite now personID author body mfwd luActivity invite + AP.JoinActivity join -> + personJoin now personID author body mfwd luActivity join {- AP.UndoActivity undo -> (,Nothing) <$> personUndoA now personID author body mfwd luActivity undo