C2S: Implement Accept handler (without any filters)

This commit is contained in:
Pere Lev 2023-10-23 19:39:58 +03:00
parent 14ef892032
commit 5d52db9377
No known key found for this signature in database
GPG key ID: 5252C5C863E5E57D

View file

@ -136,6 +136,40 @@ verifyRemoteAddressed remoteRecips u =
lus <- lookup h remoteRecips lus <- lookup h remoteRecips
guard $ lu `elem` lus guard $ lu `elem` lus
-- Meaning: The human is approving or accepting something
-- Behavior:
-- * Insert to my inbox
-- * Deliver without filtering
clientAccept
:: UTCTime
-> PersonId
-> ClientMsg
-> AP.Accept URIMode
-> ActE OutboxItemId
clientAccept now personMeID (ClientMsg maybeCap localRecips remoteRecips fwdHosts action) accept = do
(actorMeID, localRecipsFinal, acceptID) <- withDBExcept $ do
-- Grab me from DB
(personMe, actorMe) <- lift $ do
p <- getJust personMeID
(p,) <$> getJust (personActor p)
-- Insert the Accept activity to my outbox
acceptID <- lift $ insertEmptyOutboxItem' (actorOutbox actorMe) now
_luAccept <- lift $ updateOutboxItem' (LocalActorPerson personMeID) acceptID action
return
( personActor personMe
, localRecips
, acceptID
)
lift $ sendActivity
(LocalActorPerson personMeID) actorMeID localRecipsFinal remoteRecips
fwdHosts acceptID action
return acceptID
-- Meaning: The human wants to add component C to project P -- Meaning: The human wants to add component C to project P
-- Behavior: -- Behavior:
-- * Some basic sanity checks -- * Some basic sanity checks
@ -885,6 +919,7 @@ clientBehavior :: UTCTime -> PersonId -> ClientMsg -> ActE (Text, Act (), Next)
clientBehavior now personID msg = clientBehavior now personID msg =
done . T.pack . show =<< done . T.pack . show =<<
case AP.actionSpecific $ cmAction msg of case AP.actionSpecific $ cmAction msg of
AP.AcceptActivity accept -> clientAccept now personID msg accept
AP.AddActivity add -> clientAdd now personID msg add AP.AddActivity add -> clientAdd now personID msg add
AP.CreateActivity create -> clientCreate now personID msg create AP.CreateActivity create -> clientCreate now personID msg create
AP.InviteActivity invite -> clientInvite now personID msg invite AP.InviteActivity invite -> clientInvite now personID msg invite