S2S: Support unfollowing sharer-patch and repo-patch

- Sharer-patch was already working due to the shared DB tabled
- Repo-patch support added
- Fixed a bug in following project-tickets: It allowed to follow a
  sharer-ticket by sending the Follow to the project. Now, the project allows
  to follow only the project-tickets, and refuses to handle a sharer-ticket.
This commit is contained in:
fr33domlover 2020-05-27 11:59:53 +00:00
parent c7b6ad643b
commit cf946e0326

View file

@ -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"