1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-28 23:34:51 +09:00

C2S: In Follow handler, support following sharer-hosted tickets

This commit is contained in:
fr33domlover 2020-04-09 20:04:21 +00:00
parent 90bac5c34e
commit f4ab99f7bb

View file

@ -719,8 +719,9 @@ createTicketC (Entity pidUser personUser) sharerUser summary audience ticket muT
data Followee
= FolloweeSharer ShrIdent
| FolloweeSharerTicket ShrIdent (KeyHashid TicketAuthorLocal)
| FolloweeProject ShrIdent PrjIdent
| FolloweeTicket ShrIdent PrjIdent (KeyHashid LocalTicket)
| FolloweeProjectTicket ShrIdent PrjIdent (KeyHashid LocalTicket)
| FolloweeRepo ShrIdent RpIdent
followC
@ -781,14 +782,16 @@ followC shrUser summary audience follow@(AP.Follow uObject muContext hide) = run
return obiidFollow
where
parseFollowee (SharerR shr) = Just $ FolloweeSharer shr
parseFollowee (SharerTicketR shr khid) = Just $ FolloweeSharerTicket shr khid
parseFollowee (ProjectR shr prj) = Just $ FolloweeProject shr prj
parseFollowee (ProjectTicketR shr prj num) = Just $ FolloweeTicket shr prj num
parseFollowee (ProjectTicketR shr prj num) = Just $ FolloweeProjectTicket shr prj num
parseFollowee (RepoR shr rp) = Just $ FolloweeRepo shr rp
parseFollowee _ = Nothing
followeeActor (FolloweeSharer shr) = LocalActorSharer shr
followeeActor (FolloweeSharerTicket shr _) = LocalActorSharer shr
followeeActor (FolloweeProject shr prj) = LocalActorProject shr prj
followeeActor (FolloweeTicket shr prj _) = LocalActorProject shr prj
followeeActor (FolloweeProjectTicket shr prj _) = LocalActorProject shr prj
followeeActor (FolloweeRepo shr rp) = LocalActorRepo shr rp
getAuthor shr = do
@ -807,13 +810,26 @@ followC shrUser summary audience follow@(AP.Follow uObject muContext hide) = run
case val of
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"
return (localTicketFollowers lt, personInbox p, True, personOutbox p)
getFollowee (FolloweeProject shr prj) = do
mproject <- lift $ runMaybeT $ do
sid <- MaybeT $ getKeyBy $ UniqueSharer shr
MaybeT $ getValBy $ UniqueProject prj sid
project <- fromMaybeE mproject "Follow object: No such project in DB"
return (projectFollowers project, projectInbox project, False, projectOutbox project)
getFollowee (FolloweeTicket shr prj ltkhid) = do
getFollowee (FolloweeProjectTicket shr prj ltkhid) = do
mproject <- lift $ runMaybeT $ do
sid <- MaybeT $ getKeyBy $ UniqueSharer shr
Entity jid project <- MaybeT $ getBy $ UniqueProject prj sid
@ -824,7 +840,7 @@ followC shrUser summary audience follow@(AP.Follow uObject muContext hide) = run
UniqueTicketProjectLocal $ localTicketTicket lticket
guard $ ticketProjectLocalProject tpl == jid
return (lticket, project)
(lticket, project) <- fromMaybeE mproject "Follow object: No such ticket in DB"
(lticket, project) <- fromMaybeE mproject "Follow object: No such project ticket in DB"
return (localTicketFollowers lticket, projectInbox project, False, projectOutbox project)
getFollowee (FolloweeRepo shr rp) = do
mrepo <- lift $ runMaybeT $ do