Person: Implement (the quite trivial) Join handler

This commit is contained in:
Pere Lev 2023-05-30 22:21:51 +03:00
parent 4d8e5de8b8
commit b759b87d0f
No known key found for this signature in database
GPG key ID: 5252C5C863E5E57D

View file

@ -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