diff --git a/src/Vervis/API.hs b/src/Vervis/API.hs index 35e3395..611acac 100644 --- a/src/Vervis/API.hs +++ b/src/Vervis/API.hs @@ -776,30 +776,37 @@ pushCommitsC (eperson, sharer) summary push shrRepo rpRepo = runExceptT $ do getFollowersCollection :: Route App -> AppDB FollowerSetId -> Handler TypedContent getFollowersCollection here getFsid = do - (locals, remotes) <- runDB $ do + (locals, remotes, l, r) <- runDB $ do fsid <- getFsid - (,) <$> do pids <- map (followPerson . entityVal) <$> - selectList [FollowTarget ==. fsid] [] - sids <- + (,,,) <$> do pids <- + map (followPerson . entityVal) <$> + selectList + [FollowTarget ==. fsid, FollowPublic ==. True] + [] + sids <- map (personIdent . entityVal) <$> selectList [PersonId <-. pids] [] - map (sharerIdent . entityVal) <$> + map (sharerIdent . entityVal) <$> selectList [SharerId <-. sids] [] - <*> do E.select $ E.from $ \ (rf `E.InnerJoin` ra `E.InnerJoin` i) -> do + <*> do E.select $ E.from $ \ (rf `E.InnerJoin` ra `E.InnerJoin` i) -> do E.on $ ra E.^. RemoteActorInstance E.==. i E.^. InstanceId E.on $ rf E.^. RemoteFollowActor E.==. ra E.^. RemoteActorId - E.where_ $ rf E.^. RemoteFollowTarget E.==. E.val fsid + E.where_ + $ rf E.^. RemoteFollowTarget E.==. E.val fsid + E.&&. rf E.^. RemoteFollowPublic E.==. E.val True return ( i E.^. InstanceHost , ra E.^. RemoteActorIdent ) + <*> count [FollowTarget ==. fsid] + <*> count [RemoteFollowTarget ==. fsid] encodeRouteLocal <- getEncodeRouteLocal encodeRouteHome <- getEncodeRouteHome let followersAP = Collection { collectionId = encodeRouteLocal here , collectionType = CollectionTypeUnordered - , collectionTotalItems = Just $ length locals + length remotes + , collectionTotalItems = Just $ l + r , collectionCurrent = Nothing , collectionFirst = Nothing , collectionLast = Nothing