diff --git a/src/Vervis/Actor/Person.hs b/src/Vervis/Actor/Person.hs index 9004177..01e14e0 100644 --- a/src/Vervis/Actor/Person.hs +++ b/src/Vervis/Actor/Person.hs @@ -438,6 +438,36 @@ personCreateNote now recipPersonID (Verse authorIdMsig body) note = do -- Access ------------------------------------------------------------------------------ +-- Meaning: Someone is adding something to something +-- Behavior: +-- * Insert to my inbox +personAdd + :: UTCTime + -> PersonId + -> Verse + -> AP.Add URIMode + -> ActE (Text, Act (), Next) +personAdd now recipPersonID (Verse authorIdMsig body) add = do + + -- Check input + let author = bimap (view _1) (remoteAuthorURI . view _1) authorIdMsig + _ <- parseAdd author add + + maybeNew <- withDBExcept $ do + + -- Grab me from DB + (personRecip, actorRecip) <- lift $ do + p <- getJust recipPersonID + (p,) <$> getJust (personActor p) + + maybeAddDB <- lift $ insertToInbox now authorIdMsig body (actorInbox actorRecip) True + for maybeAddDB $ \ _addDB -> + return $ personActor personRecip + + case maybeNew of + Nothing -> done "I already have this activity in my inbox" + Just _actorID -> done "Inserted this Add to my inbox" + -- Meaning: Someone invited someone to a resource -- Behavior: -- * Insert to my inbox @@ -579,10 +609,11 @@ personGrant now recipPersonID (Verse authorIdMsig body) grant = do -- Check input target <- do - h <- lift $ objUriAuthority <$> getActorURI authorIdMsig - (_role, resource, recip, _mresult, _mstart, _mend) <- parseGrant h grant + --h <- lift $ objUriAuthority <$> getActorURI authorIdMsig + (_role, resource, recip, _mresult, _mstart, _mend, _usage, _mdeleg) <- + parseGrant' grant case (recip, authorIdMsig) of - (Left (GrantRecipPerson p), Left (LocalActorPerson p', _, _)) + (Left (GrantRecipPerson' p), Left (LocalActorPerson p', _, _)) | p == p' -> throwE "Grant sender and target are the same local Person" (Right uRecip, Right (author, _, _)) @@ -606,7 +637,7 @@ personGrant now recipPersonID (Verse authorIdMsig body) grant = do Just _actorID -> do let targetIsRecip = case target of - Left (GrantRecipPerson p) -> p == recipPersonID + Left (GrantRecipPerson' p) -> p == recipPersonID _ -> False if not targetIsRecip then done "I'm not the target; Inserted to inbox" @@ -643,6 +674,7 @@ personBehavior :: UTCTime -> PersonId -> VerseExt -> ActE (Text, Act (), Next) personBehavior now personID (Left verse@(Verse _authorIdMsig body)) = case AP.activitySpecific $ actbActivity body of AP.AcceptActivity accept -> personAccept now personID verse accept + AP.AddActivity add -> personAdd now personID verse add AP.CreateActivity (AP.Create obj mtarget) -> case obj of AP.CreateNote _ note ->