1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-28 23:44: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 data Followee
= FolloweeSharer ShrIdent = FolloweeSharer ShrIdent
| FolloweeSharerTicket ShrIdent (KeyHashid TicketAuthorLocal)
| FolloweeProject ShrIdent PrjIdent | FolloweeProject ShrIdent PrjIdent
| FolloweeTicket ShrIdent PrjIdent (KeyHashid LocalTicket) | FolloweeProjectTicket ShrIdent PrjIdent (KeyHashid LocalTicket)
| FolloweeRepo ShrIdent RpIdent | FolloweeRepo ShrIdent RpIdent
followC followC
@ -781,15 +782,17 @@ followC shrUser summary audience follow@(AP.Follow uObject muContext hide) = run
return obiidFollow return obiidFollow
where where
parseFollowee (SharerR shr) = Just $ FolloweeSharer shr parseFollowee (SharerR shr) = Just $ FolloweeSharer shr
parseFollowee (SharerTicketR shr khid) = Just $ FolloweeSharerTicket shr khid
parseFollowee (ProjectR shr prj) = Just $ FolloweeProject shr prj 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 (RepoR shr rp) = Just $ FolloweeRepo shr rp
parseFollowee _ = Nothing parseFollowee _ = Nothing
followeeActor (FolloweeSharer shr) = LocalActorSharer shr followeeActor (FolloweeSharer shr) = LocalActorSharer shr
followeeActor (FolloweeProject shr prj) = LocalActorProject shr prj followeeActor (FolloweeSharerTicket shr _) = LocalActorSharer shr
followeeActor (FolloweeTicket shr prj _) = LocalActorProject shr prj followeeActor (FolloweeProject shr prj) = LocalActorProject shr prj
followeeActor (FolloweeRepo shr rp) = LocalActorRepo shr rp followeeActor (FolloweeProjectTicket shr prj _) = LocalActorProject shr prj
followeeActor (FolloweeRepo shr rp) = LocalActorRepo shr rp
getAuthor shr = do getAuthor shr = do
sid <- getKeyBy404 $ UniqueSharer shr sid <- getKeyBy404 $ UniqueSharer shr
@ -807,13 +810,26 @@ followC shrUser summary audience follow@(AP.Follow uObject muContext hide) = run
case val of case val of
Left person -> return (personFollowers person, personInbox person, True, personOutbox person) Left person -> return (personFollowers person, personInbox person, True, personOutbox person)
Right _group -> throwE "Follow object is a group" 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 getFollowee (FolloweeProject shr prj) = do
mproject <- lift $ runMaybeT $ do mproject <- lift $ runMaybeT $ do
sid <- MaybeT $ getKeyBy $ UniqueSharer shr sid <- MaybeT $ getKeyBy $ UniqueSharer shr
MaybeT $ getValBy $ UniqueProject prj sid MaybeT $ getValBy $ UniqueProject prj sid
project <- fromMaybeE mproject "Follow object: No such project in DB" project <- fromMaybeE mproject "Follow object: No such project in DB"
return (projectFollowers project, projectInbox project, False, projectOutbox project) return (projectFollowers project, projectInbox project, False, projectOutbox project)
getFollowee (FolloweeTicket shr prj ltkhid) = do getFollowee (FolloweeProjectTicket shr prj ltkhid) = do
mproject <- lift $ runMaybeT $ do mproject <- lift $ runMaybeT $ do
sid <- MaybeT $ getKeyBy $ UniqueSharer shr sid <- MaybeT $ getKeyBy $ UniqueSharer shr
Entity jid project <- MaybeT $ getBy $ UniqueProject prj sid 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 UniqueTicketProjectLocal $ localTicketTicket lticket
guard $ ticketProjectLocalProject tpl == jid guard $ ticketProjectLocalProject tpl == jid
return (lticket, project) 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) return (localTicketFollowers lticket, projectInbox project, False, projectOutbox project)
getFollowee (FolloweeRepo shr rp) = do getFollowee (FolloweeRepo shr rp) = do
mrepo <- lift $ runMaybeT $ do mrepo <- lift $ runMaybeT $ do