From 40a5b336a4af7658e5bafd988ac0d65574f73ed7 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Fri, 10 Apr 2020 10:47:43 +0000 Subject: [PATCH] S2S: In Undo handler for sharer inbox, support unfollowing sharer tickets --- src/Vervis/Federation/Offer.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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