S2S: loomFollowF & repoFollowF

This commit is contained in:
fr33domlover 2022-10-26 05:25:44 +00:00
parent ee3548a940
commit 340d1eacb1
3 changed files with 61 additions and 44 deletions

View file

@ -22,7 +22,8 @@ module Vervis.Federation.Offer
personFollowF personFollowF
, deckFollowF , deckFollowF
--, repoFollowF , loomFollowF
, repoFollowF
--, sharerUndoF --, sharerUndoF
--, projectUndoF --, projectUndoF
@ -615,53 +616,65 @@ deckFollowF now recipDeckHash =
now now
recipDeckHash recipDeckHash
{- loomFollowF
repoFollowF :: UTCTime
:: KeyHashid Repo -> KeyHashid Loom
-> UTCTime
-> RemoteAuthor -> RemoteAuthor
-> ActivityBody -> ActivityBody
-> Maybe (LocalRecipientSet, ByteString) -> Maybe (RecipientRoutes, ByteString)
-> LocalURI -> LocalURI
-> AP.Follow URIMode -> AP.Follow URIMode
-> ExceptT Text Handler Text -> ExceptT Text Handler (Text, Maybe (ExceptT Text Worker Text))
repoFollowF repoHash = loomFollowF now recipLoomHash =
error "repoFollowF temporarily disabled"
followF followF
objRoute (\case
(RepoR shr rp) LoomR l | l == recipLoomHash -> pure Nothing
getRecip ClothR l c | l == recipLoomHash ->
(repoInbox . fst) Just <$> decodeKeyHashidE c "Invalid cloth keyhashid"
(repoOutbox . fst) _ -> throwE "Asking to follow someone else"
followers )
(RepoOutboxItemR shr rp) loomActor
where False
objRoute (RepoR shr' rp') (\ recipLoomID recipLoomActor maybeClothID ->
| shr == shr' && rp == rp' = Just Nothing case maybeClothID of
objRoute (RepoProposalR shr' rp' ltkhid) Nothing -> pure $ actorFollowers recipLoomActor
| shr == shr' && rp == rp' = Just $ Just ltkhid Just clothID -> do
objRoute _ = Nothing maybeCloth <- lift $ getCloth recipLoomID clothID
(_loom, _cloth, Entity _ ticket, _author, _resolve, _merge) <-
fromMaybeE maybeCloth "I don't have this MR in DB"
return $ ticketFollowers ticket
)
(\ _ -> pure $ makeRecipientSet [] [])
LocalActorLoom
(\ _ -> pure [])
now
recipLoomHash
getRecip mltkhid = do repoFollowF
sid <- getKeyBy404 $ UniqueSharer shr :: UTCTime
r <- getValBy404 $ UniqueRepo rp sid -> KeyHashid Repo
mmt <- for mltkhid $ \ ltkhid -> runMaybeT $ do -> RemoteAuthor
ltid <- decodeKeyHashidM ltkhid -> ActivityBody
(_, _, _, Entity _ lt, _, _, _, _, _) <- MaybeT $ getRepoProposal shr rp ltid -> Maybe (RecipientRoutes, ByteString)
return lt -> LocalURI
return $ -> AP.Follow URIMode
case mmt of -> ExceptT Text Handler (Text, Maybe (ExceptT Text Worker Text))
Nothing -> Just (r, Nothing) repoFollowF now recipRepoHash =
Just Nothing -> Nothing followF
Just (Just t) -> Just (r, Just t) (\case
RepoR r | r == recipRepoHash -> pure ()
followers (r, Nothing) = repoFollowers r _ -> throwE "Asking to follow someone else"
followers (_, Just lt) = localTicketFollowers lt )
-} repoActor
False
(\ _recipRepoID recipRepoActor () ->
pure $ actorFollowers recipRepoActor
)
(\ () -> pure $ makeRecipientSet [] [])
LocalActorRepo
(\ () -> pure [])
now
recipRepoHash
{- {-
getFollow (Left _) = return Nothing getFollow (Left _) = return Nothing

View file

@ -78,6 +78,7 @@ import Vervis.API
import Vervis.Federation.Auth import Vervis.Federation.Auth
import Vervis.Federation.Collab import Vervis.Federation.Collab
import Vervis.Federation.Discussion import Vervis.Federation.Discussion
import Vervis.Federation.Offer
import Vervis.Federation.Ticket import Vervis.Federation.Ticket
import Vervis.FedURI import Vervis.FedURI
import Vervis.Form.Ticket import Vervis.Form.Ticket
@ -159,6 +160,8 @@ postLoomInboxR recipLoomHash =
AP.CreateNote _ note -> AP.CreateNote _ note ->
(,Nothing) <$> loomCreateNoteF now recipLoomHash author body mfwd luActivity note (,Nothing) <$> loomCreateNoteF now recipLoomHash author body mfwd luActivity note
_ -> return ("Unsupported create object type for looms", Nothing) _ -> return ("Unsupported create object type for looms", Nothing)
AP.FollowActivity follow ->
loomFollowF now recipLoomHash author body mfwd luActivity follow
AP.InviteActivity invite -> AP.InviteActivity invite ->
topicInviteF now (GrantResourceLoom recipLoomHash) author body mfwd luActivity invite topicInviteF now (GrantResourceLoom recipLoomHash) author body mfwd luActivity invite
AP.OfferActivity (AP.Offer obj target) -> AP.OfferActivity (AP.Offer obj target) ->

View file

@ -160,6 +160,7 @@ import Vervis.Access
import Vervis.API import Vervis.API
import Vervis.Federation.Auth import Vervis.Federation.Auth
import Vervis.Federation.Collab import Vervis.Federation.Collab
import Vervis.Federation.Offer
import Vervis.FedURI import Vervis.FedURI
import Vervis.Form.Repo import Vervis.Form.Repo
import Vervis.Foundation import Vervis.Foundation
@ -265,9 +266,9 @@ postRepoInboxR recipRepoHash =
CreateTicket _ ticket -> CreateTicket _ ticket ->
(,Nothing) <$> repoCreateTicketF now shrRecip rpRecip remoteAuthor body mfwd luActivity ticket mtarget (,Nothing) <$> repoCreateTicketF now shrRecip rpRecip remoteAuthor body mfwd luActivity ticket mtarget
_ -> error "Unsupported create object type for repos" _ -> error "Unsupported create object type for repos"
FollowActivity follow ->
(,Nothing) <$> repoFollowF shrRecip rpRecip now remoteAuthor body mfwd luActivity follow
-} -}
AP.FollowActivity follow ->
repoFollowF now recipRepoHash author body mfwd luActivity follow
AP.InviteActivity invite -> AP.InviteActivity invite ->
topicInviteF now (GrantResourceRepo recipRepoHash) author body mfwd luActivity invite topicInviteF now (GrantResourceRepo recipRepoHash) author body mfwd luActivity invite
{- {-