diff --git a/src/Vervis/Federation/Offer.hs b/src/Vervis/Federation/Offer.hs index 87f8610..84d23b3 100644 --- a/src/Vervis/Federation/Offer.hs +++ b/src/Vervis/Federation/Offer.hs @@ -545,11 +545,26 @@ sharerUndoF shr = getRecip personInbox personFollowers - (\ _ _ -> return $ Just "Undo object is a RemoteFollow, but isn't under this sharer") + tryTicket where getRecip = do sid <- getKeyBy404 $ UniqueSharer shr getBy404 $ UniquePersonIdent sid + tryTicket pid fsid = do + mltid <- getKeyBy $ UniqueLocalTicketFollowers fsid + case mltid of + Nothing -> return $ Just "Undo object is a RemoteFollow, but isn't under this sharer" + Just ltid -> do + mtal <- getBy $ UniqueTicketAuthorLocal ltid + case mtal of + Just (Entity talid tal) + | ticketAuthorLocalAuthor tal == pid -> do + mtup <- getBy $ UniqueTicketUnderProjectAuthor talid + return $ + case mtup of + Nothing -> Nothing + Just _ -> Just "Undo object is a RemoteFollow of a ticket authored by this sharer, but is hosted by the project" + _ -> return $ Just "Undo object is a RemoteFollow of a ticket of another author" projectUndoF :: ShrIdent