C2S: Support following a sharer-patch and repo-patch
This commit is contained in:
parent
3fb529325d
commit
854d35fd9b
1 changed files with 33 additions and 24 deletions
|
@ -787,9 +787,11 @@ createTicketC (Entity pidUser personUser) sharerUser summary audience ticket muT
|
|||
data Followee
|
||||
= FolloweeSharer ShrIdent
|
||||
| FolloweeSharerTicket ShrIdent (KeyHashid TicketAuthorLocal)
|
||||
| FolloweeSharerPatch ShrIdent (KeyHashid TicketAuthorLocal)
|
||||
| FolloweeProject ShrIdent PrjIdent
|
||||
| FolloweeProjectTicket ShrIdent PrjIdent (KeyHashid LocalTicket)
|
||||
| FolloweeRepo ShrIdent RpIdent
|
||||
| FolloweeRepoPatch ShrIdent RpIdent (KeyHashid LocalTicket)
|
||||
|
||||
followC
|
||||
:: ShrIdent
|
||||
|
@ -849,16 +851,20 @@ followC shrUser summary audience follow@(AP.Follow uObject muContext hide) = run
|
|||
where
|
||||
parseFollowee (SharerR shr) = Just $ FolloweeSharer shr
|
||||
parseFollowee (SharerTicketR shr khid) = Just $ FolloweeSharerTicket shr khid
|
||||
parseFollowee (SharerPatchR shr khid) = Just $ FolloweeSharerPatch shr khid
|
||||
parseFollowee (ProjectR shr prj) = Just $ FolloweeProject shr prj
|
||||
parseFollowee (ProjectTicketR shr prj num) = Just $ FolloweeProjectTicket shr prj num
|
||||
parseFollowee (RepoR shr rp) = Just $ FolloweeRepo shr rp
|
||||
parseFollowee (RepoPatchR shr rp khid) = Just $ FolloweeRepoPatch shr rp khid
|
||||
parseFollowee _ = Nothing
|
||||
|
||||
followeeActor (FolloweeSharer shr) = LocalActorSharer shr
|
||||
followeeActor (FolloweeSharerTicket shr _) = LocalActorSharer shr
|
||||
followeeActor (FolloweeSharerPatch shr _) = LocalActorSharer shr
|
||||
followeeActor (FolloweeProject shr prj) = LocalActorProject shr prj
|
||||
followeeActor (FolloweeProjectTicket shr prj _) = LocalActorProject shr prj
|
||||
followeeActor (FolloweeRepo shr rp) = LocalActorRepo shr rp
|
||||
followeeActor (FolloweeRepoPatch shr rp _) = LocalActorRepo shr rp
|
||||
|
||||
getAuthor shr = do
|
||||
sid <- getKeyBy404 $ UniqueSharer shr
|
||||
|
@ -877,17 +883,20 @@ followC shrUser summary audience follow@(AP.Follow uObject muContext hide) = run
|
|||
Left person -> return (personFollowers person, personInbox person, True, personOutbox person)
|
||||
Right _group -> throwE "Follow object is a group"
|
||||
getFollowee (FolloweeSharerTicket shr talkhid) = do
|
||||
mfollowee <- lift $ runMaybeT $ do
|
||||
sid <- MaybeT $ getKeyBy $ UniqueSharer shr
|
||||
Entity pid p <- MaybeT $ getBy $ UniquePersonIdent sid
|
||||
talid <- decodeKeyHashidM talkhid
|
||||
tal <- MaybeT $ get talid
|
||||
guard $ ticketAuthorLocalAuthor tal == pid
|
||||
mtup <- lift $ getBy $ UniqueTicketUnderProjectAuthor talid
|
||||
guard $ isNothing mtup
|
||||
lt <- lift $ getJust $ ticketAuthorLocalTicket tal
|
||||
return (lt, p)
|
||||
(lt, p) <- fromMaybeE mfollowee "Follow object: No such sharer ticket in DB"
|
||||
(Entity _ tal, Entity _ lt, _, _) <- do
|
||||
mticket <- lift $ runMaybeT $ do
|
||||
talid <- decodeKeyHashidM talkhid
|
||||
MaybeT $ getSharerTicket shr talid
|
||||
fromMaybeE mticket "Follow object: No such sharer-ticket in DB"
|
||||
p <- lift $ getJust $ ticketAuthorLocalAuthor tal
|
||||
return (localTicketFollowers lt, personInbox p, True, personOutbox p)
|
||||
getFollowee (FolloweeSharerPatch shr talkhid) = do
|
||||
(Entity _ tal, Entity _ lt, _, _, _) <- do
|
||||
mticket <- lift $ runMaybeT $ do
|
||||
talid <- decodeKeyHashidM talkhid
|
||||
MaybeT $ getSharerPatch shr talid
|
||||
fromMaybeE mticket "Follow object: No such sharer-patch in DB"
|
||||
p <- lift $ getJust $ ticketAuthorLocalAuthor tal
|
||||
return (localTicketFollowers lt, personInbox p, True, personOutbox p)
|
||||
getFollowee (FolloweeProject shr prj) = do
|
||||
mproject <- lift $ runMaybeT $ do
|
||||
|
@ -896,25 +905,25 @@ followC shrUser summary audience follow@(AP.Follow uObject muContext hide) = run
|
|||
project <- fromMaybeE mproject "Follow object: No such project in DB"
|
||||
return (projectFollowers project, projectInbox project, False, projectOutbox project)
|
||||
getFollowee (FolloweeProjectTicket shr prj ltkhid) = do
|
||||
mproject <- lift $ runMaybeT $ do
|
||||
sid <- MaybeT $ getKeyBy $ UniqueSharer shr
|
||||
Entity jid project <- MaybeT $ getBy $ UniqueProject prj sid
|
||||
ltid <- decodeKeyHashidM ltkhid
|
||||
lticket <- MaybeT $ get ltid
|
||||
tclid <-
|
||||
MaybeT $ getKeyBy $
|
||||
UniqueTicketContextLocal $ localTicketTicket lticket
|
||||
tpl <- MaybeT $ getValBy $ UniqueTicketProjectLocal tclid
|
||||
guard $ ticketProjectLocalProject tpl == jid
|
||||
return (lticket, project)
|
||||
(lticket, project) <- fromMaybeE mproject "Follow object: No such project ticket in DB"
|
||||
return (localTicketFollowers lticket, projectInbox project, False, projectOutbox project)
|
||||
(_, Entity _ j, _, Entity _ lt, _, _, _) <- do
|
||||
mticket <- lift $ runMaybeT $ do
|
||||
ltid <- decodeKeyHashidM ltkhid
|
||||
MaybeT $ getProjectTicket shr prj ltid
|
||||
fromMaybeE mticket "Follow object: No such project-ticket in DB"
|
||||
return (localTicketFollowers lt, projectInbox j, False, projectOutbox j)
|
||||
getFollowee (FolloweeRepo shr rp) = do
|
||||
mrepo <- lift $ runMaybeT $ do
|
||||
sid <- MaybeT $ getKeyBy $ UniqueSharer shr
|
||||
MaybeT $ getValBy $ UniqueRepo rp sid
|
||||
repo <- fromMaybeE mrepo "Follow object: No such repo in DB"
|
||||
return (repoFollowers repo, repoInbox repo, False, repoOutbox repo)
|
||||
getFollowee (FolloweeRepoPatch shr rp ltkhid) = do
|
||||
(_, Entity _ r, _, Entity _ lt, _, _, _, _) <- do
|
||||
mticket <- lift $ runMaybeT $ do
|
||||
ltid <- decodeKeyHashidM ltkhid
|
||||
MaybeT $ getRepoPatch shr rp ltid
|
||||
fromMaybeE mticket "Follow object: No such repo-patch in DB"
|
||||
return (localTicketFollowers lt, repoInbox r, False, repoOutbox r)
|
||||
|
||||
insertFollowToOutbox obid = do
|
||||
hLocal <- asksSite siteInstanceHost
|
||||
|
|
Loading…
Reference in a new issue