diff --git a/src/Vervis/Handler/Project.hs b/src/Vervis/Handler/Project.hs index cf10fb0..9c503c3 100644 --- a/src/Vervis/Handler/Project.hs +++ b/src/Vervis/Handler/Project.hs @@ -38,7 +38,6 @@ module Vervis.Handler.Project , getProjectComponentsR , getProjectCollabLiveR - , getProjectInviteCompR , postProjectInviteCompR , getProjectChildrenR @@ -484,6 +483,12 @@ getProjectComponentsR projectHash = do return (i E.^. InstanceHost, ro E.^. RemoteObjectIdent) getHtml projectID = do + mp <- maybeAuthId + haveAdmin <- fmap isJust $ handlerToWidget $ runDB $ runMaybeT $ do + personID <- MaybeT $ pure mp + project <- lift $ get404 projectID + MaybeT $ getCapability personID (Left $ projectResource project) AP.RoleAdmin + ((_, widgetIC), enctypeIC) <- handlerToWidget $ runFormPost projectInviteCompForm (project, actor, comps, drafts) <- handlerToWidget $ runDB $ do project <- get404 projectID actor <- getJust $ projectActor project @@ -556,12 +561,6 @@ getProjectCollabLiveR projectHash enableHash = do Collab _ resourceID' <- getJust collabID unless (resourceID == resourceID') notFound -getProjectInviteCompR :: KeyHashid Project -> Handler Html -getProjectInviteCompR projectHash = do - projectID <- decodeKeyHashid404 projectHash - ((_result, widget), enctype) <- runFormPost projectInviteCompForm - defaultLayout $(widgetFile "project/component-new") - postProjectInviteCompR :: KeyHashid Project -> Handler Html postProjectInviteCompR projectHash = do projectID <- decodeKeyHashid404 projectHash @@ -575,27 +574,22 @@ postProjectInviteCompR projectHash = do result <- runExceptT $ do (maybeSummary, audience, invite) <- C.inviteComponent personID projectID uComp - grantID <- do + cap <- do maybeItem <- lift $ runDB $ do resourceID <- projectResource <$> get404 projectID - getGrant resourceID personID - fromMaybeE maybeItem "You need to be a collaborator in the Project to invite people" - grantHash <- encodeKeyHashid grantID - let uCap = encodeRouteHome $ ProjectOutboxItemR projectHash grantHash + getCapability personID (Left resourceID) AP.RoleAdmin + fromMaybeE maybeItem "You need to be have Admin access to the Project to invite components" + uCap <- lift $ renderActivityURI cap (localRecips, remoteRecips, fwdHosts, action) <- C.makeServerInput (Just uCap) maybeSummary audience $ AP.InviteActivity invite - let cap = - Left (LocalActorProject projectID, LocalActorProject projectHash, grantID) + let cap' = first (\ (la, i) -> (la, error "lah", i)) cap handleViaActor - personID (Just cap) localRecips remoteRecips fwdHosts action + personID (Just cap') localRecips remoteRecips fwdHosts action case result of - Left e -> do - setMessage $ toHtml e - redirect $ ProjectInviteCompR projectHash - Right inviteID -> do - setMessage "Invite sent" - redirect $ ProjectComponentsR projectHash + Left e -> setMessage $ toHtml e + Right inviteID -> setMessage "Invite sent" + redirect $ ProjectComponentsR projectHash getProjectChildrenR :: KeyHashid Project -> Handler TypedContent getProjectChildrenR projectHash = do diff --git a/src/Vervis/Widget/Person.hs b/src/Vervis/Widget/Person.hs index a3dbbff..e56a0d5 100644 --- a/src/Vervis/Widget/Person.hs +++ b/src/Vervis/Widget/Person.hs @@ -130,7 +130,7 @@ followW' (Right actorID) = do [whamlet|