diff --git a/src/Vervis/Handler/Project.hs b/src/Vervis/Handler/Project.hs index ffefe42..16473c7 100644 --- a/src/Vervis/Handler/Project.hs +++ b/src/Vervis/Handler/Project.hs @@ -823,7 +823,71 @@ getProjectParentsR projectHash = do ) getHtml projectID project actor parents = do + invites <- handlerToWidget $ runDB $ do + dests <- E.select $ E.from $ \ (dest `E.InnerJoin` holder `E.LeftOuterJoin` accept `E.LeftOuterJoin` delegl `E.LeftOuterJoin` delegr) -> do + E.on $ accept E.?. DestUsAcceptId E.==. delegr E.?. DestThemSendDelegatorRemoteDest + E.on $ accept E.?. DestUsAcceptId E.==. delegl E.?. DestThemSendDelegatorLocalDest + E.on $ E.just (dest E.^. DestId) E.==. accept E.?. DestUsAcceptDest + E.on $ dest E.^. DestId E.==. holder E.^. DestHolderProjectDest + E.where_ $ + holder E.^. DestHolderProjectProject E.==. E.val projectID E.&&. + E.isNothing (delegl E.?. DestThemSendDelegatorLocalId) E.&&. + E.isNothing (delegr E.?. DestThemSendDelegatorRemoteId) + E.orderBy [E.asc $ dest E.^. DestId] + return dest + for dests $ \ (Entity destID (Dest role)) -> do + parent <- do + topic <- getDestTopic destID + bitraverse + (\ (_, e) -> do + jID <- + case e of + Left j -> pure j + Right _ -> error "I'm a Project but my parent is a Group" + j <- getJust jID + actor <- getJust $ projectActor j + return (jID, actor) + ) + (\ (_, actorID) -> getRemoteActorData actorID) + topic + accept <- isJust <$> getBy (UniqueDestUsAccept destID) + ((inviter, time), us) <- do + usOrThem <- + requireEitherAlt + (getKeyBy $ UniqueDestOriginUs destID) + (getKeyBy $ UniqueDestOriginThem destID) + "Neither us nor them" + "Both us and them" + (addOrActor, us) <- + case usOrThem of + Left _usID -> (,True) <$> + requireEitherAlt + (fmap destUsGestureLocalActivity <$> getValBy (UniqueDestUsGestureLocal destID)) + (fmap (destUsGestureRemoteActor &&& destUsGestureRemoteActivity) <$> getValBy (UniqueDestUsGestureRemote destID)) + "Neither local not remote" + "Both local and remote" + Right themID -> (,False) <$> + requireEitherAlt + (fmap destThemGestureLocalAdd <$> getValBy (UniqueDestThemGestureLocal themID)) + (fmap (destThemGestureRemoteActor &&& destThemGestureRemoteAdd) <$> getValBy (UniqueDestThemGestureRemote themID)) + "Neither local not remote" + "Both local and remote" + (,us) <$> case addOrActor of + Left addID -> do + OutboxItem outboxID _ time <- getJust addID + Entity actorID actor <- getByJust $ UniqueActorOutbox outboxID + (,time) . Left . (,actor) <$> getLocalActor actorID + Right (actorID, addID) -> do + RemoteActivity _ _ time <- getJust addID + (,time) . Right <$> getRemoteActorData actorID + return (inviter, us, parent, accept, time, role) $(widgetFile "project/parents") + where + getRemoteActorData actorID = do + actor <- getJust actorID + object <- getJust $ remoteActorIdent actor + inztance <- getJust $ remoteObjectInstance object + return (inztance, object, actor) getProjectParentLocalLiveR :: KeyHashid Project -> KeyHashid DestThemSendDelegatorLocal -> Handler () getProjectParentLocalLiveR projectHash delegHash = do diff --git a/templates/project/parents.hamlet b/templates/project/parents.hamlet index 02239b4..b9fcd0c 100644 --- a/templates/project/parents.hamlet +++ b/templates/project/parents.hamlet @@ -1,6 +1,7 @@ $# This file is part of Vervis. $# -$# Written in 2016, 2019, 2022, 2023 by fr33domlover . +$# Written in 2016, 2019, 2022, 2023, 2024 +$# by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -20,9 +21,36 @@ $# . Role Since - Child + Parent $forall (role, since, parent) <- parents #{show role} #{showDate since} ^{projectLinkFedW parent} + +

Invites + + + + +
Inviter + Via + Invited parent + Parent accepted? + Role + Time + $forall (inviter, us, parent, accept, time, role) <- invites +
^{actorLinkFedW inviter} + + $if us + Us + $else + Them + ^{projectLinkFedW parent} + + $if accept + [x] + $else + [_] + #{show role} + #{showDate time}