diff --git a/src/Vervis/Federation/Offer.hs b/src/Vervis/Federation/Offer.hs index 4a05bf8..5cedcbc 100644 --- a/src/Vervis/Federation/Offer.hs +++ b/src/Vervis/Federation/Offer.hs @@ -621,12 +621,17 @@ projectUndoF shr prj = Just lt -> do mtpl <- runMaybeT $ do tclid <- MaybeT $ getKeyBy $ UniqueTicketContextLocal $ localTicketTicket lt - MaybeT $ getValBy $ UniqueTicketProjectLocal tclid - return $ - case mtpl of - Just tpl - | ticketProjectLocalProject tpl == jid -> Nothing - _ -> Just "Undo object is a RemoteFollow of a ticket of another project" + tpl <- MaybeT $ getValBy $ UniqueTicketProjectLocal tclid + return (tclid, tpl) + case mtpl of + Just (tclid, tpl) + | ticketProjectLocalProject tpl == jid -> do + mtup <- getBy $ UniqueTicketUnderProjectProject tclid + return $ + case mtup of + Nothing -> Just "Undo object is a RemoteFollow of a ticket under this project, but is hosted by the author" + Just _ -> Nothing + _ -> return $ Just "Undo object is a RemoteFollow of a ticket of another project" repoUndoF :: ShrIdent @@ -642,8 +647,26 @@ repoUndoF shr rp = getRecip repoInbox repoFollowers - (\ _ _ -> return $ Just "Undo object is a RemoteFollow, but isn't under this repo") + tryPatch where getRecip = do sid <- getKeyBy404 $ UniqueSharer shr getBy404 $ UniqueRepo rp sid + tryPatch rid fsid = do + mlt <- getValBy $ UniqueLocalTicketFollowers fsid + case mlt of + Nothing -> return $ Just "Undo object is a RemoteFollow, but isn't under this repo" + Just lt -> do + mtrl <- runMaybeT $ do + tclid <- MaybeT $ getKeyBy $ UniqueTicketContextLocal $ localTicketTicket lt + trl <- MaybeT $ getValBy $ UniqueTicketRepoLocal tclid + return (tclid, trl) + case mtrl of + Just (tclid, trl) + | ticketRepoLocalRepo trl == rid -> do + mtup <- getBy $ UniqueTicketUnderProjectProject tclid + return $ + case mtup of + Nothing -> Just "Undo object is a RemoteFollow of a patch under this repo, but is hosted by the author" + Just _ -> Nothing + _ -> return $ Just "Undo object is a RemoteFollow of a ticket of another project"