In S2S Follow, projects allow following their tickets
This commit is contained in:
parent
612dfa1fce
commit
1673851db0
1 changed files with 44 additions and 23 deletions
|
@ -234,11 +234,12 @@ repoRejectF shr rp = rejectF getIbid route
|
||||||
-}
|
-}
|
||||||
|
|
||||||
followF
|
followF
|
||||||
:: AppDB a
|
:: (Route App -> Maybe a)
|
||||||
-> Route App
|
-> Route App
|
||||||
-> (a -> InboxId)
|
-> (a -> AppDB b)
|
||||||
-> (a -> OutboxId)
|
-> (b -> InboxId)
|
||||||
-> (a -> FollowerSetId)
|
-> (b -> OutboxId)
|
||||||
|
-> (b -> FollowerSetId)
|
||||||
-> (KeyHashid OutboxItem -> Route App)
|
-> (KeyHashid OutboxItem -> Route App)
|
||||||
-> UTCTime
|
-> UTCTime
|
||||||
-> RemoteAuthor
|
-> RemoteAuthor
|
||||||
|
@ -246,22 +247,23 @@ followF
|
||||||
-> AP.Follow URIMode
|
-> AP.Follow URIMode
|
||||||
-> ExceptT Text Handler Text
|
-> ExceptT Text Handler Text
|
||||||
followF
|
followF
|
||||||
getRecip recipRoute recipInbox recipOutbox recipFollowers outboxItemRoute
|
objRoute recipRoute getRecip recipInbox recipOutbox recipFollowers outboxItemRoute
|
||||||
now author body (AP.Follow (ObjURI hObj luObj) hide) = do
|
now author body (AP.Follow (ObjURI hObj luObj) hide) = do
|
||||||
me <- do
|
mobj <- do
|
||||||
local <- hostIsLocal hObj
|
local <- hostIsLocal hObj
|
||||||
return $
|
return $
|
||||||
case decodeRouteLocal luObj of
|
if local
|
||||||
Just r | local && r == recipRoute -> True
|
then Nothing
|
||||||
_ -> False
|
else objRoute =<< decodeRouteLocal luObj
|
||||||
if me
|
case mobj of
|
||||||
then do
|
Nothing -> return "Follow object unrelated to me, ignoring activity"
|
||||||
|
Just obj -> do
|
||||||
luFollow <-
|
luFollow <-
|
||||||
fromMaybeE
|
fromMaybeE
|
||||||
(activityId $ actbActivity body)
|
(activityId $ actbActivity body)
|
||||||
"Follow without 'id'"
|
"Follow without 'id'"
|
||||||
emsg <- lift $ runDB $ do
|
emsg <- lift $ runDB $ do
|
||||||
recip <- getRecip
|
recip <- getRecip obj
|
||||||
newItem <- insertToInbox luFollow $ recipInbox recip
|
newItem <- insertToInbox luFollow $ recipInbox recip
|
||||||
if newItem
|
if newItem
|
||||||
then do
|
then do
|
||||||
|
@ -287,7 +289,6 @@ followF
|
||||||
forkWorker "followF: Accept delivery" $
|
forkWorker "followF: Accept delivery" $
|
||||||
deliverRemoteHttp dont obiid doc remotesHttp
|
deliverRemoteHttp dont obiid doc remotesHttp
|
||||||
return "Follow request accepted"
|
return "Follow request accepted"
|
||||||
else return "Follow object unrelated to me, ignoring activity"
|
|
||||||
where
|
where
|
||||||
dont = Authority "dont-do.any-forwarding" Nothing
|
dont = Authority "dont-do.any-forwarding" Nothing
|
||||||
|
|
||||||
|
@ -357,14 +358,18 @@ sharerFollowF
|
||||||
-> ExceptT Text Handler Text
|
-> ExceptT Text Handler Text
|
||||||
sharerFollowF shr =
|
sharerFollowF shr =
|
||||||
followF
|
followF
|
||||||
getRecip
|
objRoute
|
||||||
(SharerR shr)
|
(SharerR shr)
|
||||||
|
getRecip
|
||||||
personInbox
|
personInbox
|
||||||
personOutbox
|
personOutbox
|
||||||
personFollowers
|
personFollowers
|
||||||
(SharerOutboxItemR shr)
|
(SharerOutboxItemR shr)
|
||||||
where
|
where
|
||||||
getRecip = do
|
objRoute (SharerR shr') | shr == shr' = Just ()
|
||||||
|
objRoute _ = Nothing
|
||||||
|
|
||||||
|
getRecip () = do
|
||||||
sid <- getKeyBy404 $ UniqueSharer shr
|
sid <- getKeyBy404 $ UniqueSharer shr
|
||||||
getValBy404 $ UniquePersonIdent sid
|
getValBy404 $ UniquePersonIdent sid
|
||||||
|
|
||||||
|
@ -378,16 +383,28 @@ projectFollowF
|
||||||
-> ExceptT Text Handler Text
|
-> ExceptT Text Handler Text
|
||||||
projectFollowF shr prj =
|
projectFollowF shr prj =
|
||||||
followF
|
followF
|
||||||
getRecip
|
objRoute
|
||||||
(ProjectR shr prj)
|
(ProjectR shr prj)
|
||||||
projectInbox
|
getRecip
|
||||||
projectOutbox
|
(projectInbox . fst)
|
||||||
projectFollowers
|
(projectOutbox . fst)
|
||||||
|
followers
|
||||||
(ProjectOutboxItemR shr prj)
|
(ProjectOutboxItemR shr prj)
|
||||||
where
|
where
|
||||||
getRecip = do
|
objRoute (ProjectR shr' prj')
|
||||||
|
| shr == shr' && prj == prj' = Just Nothing
|
||||||
|
objRoute (TicketR shr' prj' num)
|
||||||
|
| shr == shr' && prj == prj' = Just $ Just num
|
||||||
|
objRoute _ = Nothing
|
||||||
|
|
||||||
|
getRecip mnum = do
|
||||||
sid <- getKeyBy404 $ UniqueSharer shr
|
sid <- getKeyBy404 $ UniqueSharer shr
|
||||||
getValBy404 $ UniqueProject prj sid
|
Entity jid j <- getBy404 $ UniqueProject prj sid
|
||||||
|
mt <- for mnum $ \ num -> getValBy404 $ UniqueTicket jid num
|
||||||
|
return (j, mt)
|
||||||
|
|
||||||
|
followers (j, Nothing) = projectFollowers j
|
||||||
|
followers (_, Just t) = ticketFollowers t
|
||||||
|
|
||||||
repoFollowF
|
repoFollowF
|
||||||
:: ShrIdent
|
:: ShrIdent
|
||||||
|
@ -399,13 +416,17 @@ repoFollowF
|
||||||
-> ExceptT Text Handler Text
|
-> ExceptT Text Handler Text
|
||||||
repoFollowF shr rp =
|
repoFollowF shr rp =
|
||||||
followF
|
followF
|
||||||
getRecip
|
objRoute
|
||||||
(RepoR shr rp)
|
(RepoR shr rp)
|
||||||
|
getRecip
|
||||||
repoInbox
|
repoInbox
|
||||||
repoOutbox
|
repoOutbox
|
||||||
repoFollowers
|
repoFollowers
|
||||||
(RepoOutboxItemR shr rp)
|
(RepoOutboxItemR shr rp)
|
||||||
where
|
where
|
||||||
getRecip = do
|
objRoute (RepoR shr' rp') | shr == shr' && rp == rp' = Just ()
|
||||||
|
objRoute _ = Nothing
|
||||||
|
|
||||||
|
getRecip () = do
|
||||||
sid <- getKeyBy404 $ UniqueSharer shr
|
sid <- getKeyBy404 $ UniqueSharer shr
|
||||||
getValBy404 $ UniqueRepo rp sid
|
getValBy404 $ UniqueRepo rp sid
|
||||||
|
|
Loading…
Reference in a new issue