diff --git a/src/Vervis/Actor/Person.hs b/src/Vervis/Actor/Person.hs index 3b61b65..2fa3338 100644 --- a/src/Vervis/Actor/Person.hs +++ b/src/Vervis/Actor/Person.hs @@ -900,9 +900,10 @@ personGrant now recipPersonID (Verse authorIdMsig body) grant = do AP.RXRole r -> pure r AP.RXDelegator -> throwE "I've been delegated a Grant with role being delegate" resourceDB <- bitraverse - (\ la -> - withDBExcept $ localActorID <$> - getLocalActorEntityE la "Extension-Grant resource not found in DB" + (\ la -> do + lr <- fromMaybeE (actorToResource la) "Got an extension-Grant with resource being a local Person" + withDBExcept $ localResourceID <$> + getLocalResourceEntityE lr "Extension-Grant resource not found in DB" ) (\ (ObjURI h lu) -> do manager <- asksEnv envHttpManager @@ -1057,7 +1058,7 @@ personGrant now recipPersonID (Verse authorIdMsig body) grant = do return extendID _ -> error "personGrant impossible 2" lift $ case resourceDB of - Left actorID -> insert_ $ PermitTopicExtendResourceLocal extendID actorID + Left resourceID -> insert_ $ PermitTopicExtendResourceLocal extendID resourceID Right actorID -> insert_ $ PermitTopicExtendResourceRemote extendID actorID ) diff --git a/src/Vervis/Application.hs b/src/Vervis/Application.hs index 0ba7b09..de6d7f8 100644 --- a/src/Vervis/Application.hs +++ b/src/Vervis/Application.hs @@ -495,13 +495,13 @@ fillPermitRecords = do (_doc, g) <- getGrantActivityBody ext return $ AP.grantContext g result <- runExceptT $ do - a <- parseActorURI uResource + a <- parseResourceURI uResource case a of - Left la -> runSiteDBExcept $ do - actorID <- - localActorID <$> - getLocalActorEntityE la "Extension-Grant resource not found in DB" - lift $ insert_ $ PermitTopicExtendResourceLocal extendID actorID + Left lr -> runSiteDBExcept $ do + resourceID <- + localResourceID <$> + getLocalResourceEntityE lr "Extension-Grant resource not found in DB" + lift $ insert_ $ PermitTopicExtendResourceLocal extendID resourceID Right (ObjURI h lu) -> do actorID <- do manager <- asksSite appHttpManager diff --git a/src/Vervis/Handler/Deck.hs b/src/Vervis/Handler/Deck.hs index 2642a3c..f6b0241 100644 --- a/src/Vervis/Handler/Deck.hs +++ b/src/Vervis/Handler/Deck.hs @@ -261,7 +261,7 @@ getDeckTicketsR deckHash = selectRep $ do mp <- maybeAuthId case mp of Nothing -> pure [] - Just personID -> runDB $ getPermitsForResource personID (Left $ deckActor deck) + Just personID -> runDB $ getPermitsForResource personID (Left $ deckResource deck) case mpage of Nothing -> redirectFirstPage here Just (rows, navModel) -> diff --git a/src/Vervis/Handler/Group.hs b/src/Vervis/Handler/Group.hs index 20eafba..b69a6e7 100644 --- a/src/Vervis/Handler/Group.hs +++ b/src/Vervis/Handler/Group.hs @@ -170,7 +170,7 @@ getGroupR groupHash = do permits <- case mp of Nothing -> pure [] - Just personID -> getPermitsForResource personID (Left aid) + Just personID -> getPermitsForResource personID (Left $ groupResource g) return (g, a, sigKeys, permits) encodeRouteLocal <- getEncodeRouteLocal diff --git a/src/Vervis/Handler/Loom.hs b/src/Vervis/Handler/Loom.hs index 40bf679..f698d93 100644 --- a/src/Vervis/Handler/Loom.hs +++ b/src/Vervis/Handler/Loom.hs @@ -215,7 +215,7 @@ getLoomClothsR loomHash = selectRep $ do mp <- maybeAuthId case mp of Nothing -> pure [] - Just personID -> runDB $ getPermitsForResource personID (Left $ loomActor loom) + Just personID -> runDB $ getPermitsForResource personID (Left $ loomResource loom) case mpage of Nothing -> redirectFirstPage here Just (rows, navModel) -> diff --git a/src/Vervis/Handler/Project.hs b/src/Vervis/Handler/Project.hs index 8655f72..d9e0c62 100644 --- a/src/Vervis/Handler/Project.hs +++ b/src/Vervis/Handler/Project.hs @@ -134,7 +134,7 @@ getProjectR projectHash = do permits <- case mp of Nothing -> pure [] - Just personID -> getPermitsForResource personID (Left aid) + Just personID -> getPermitsForResource personID (Left $ projectResource d) return (d, a, sigKeys, permits) encodeRouteLocal <- getEncodeRouteLocal diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index dcb02de..6d884f2 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -3464,7 +3464,6 @@ changes hLocal ctx = "resource" "Resource" -- 609 - {- , addFieldRefRequired'' "PermitTopicExtendResourceLocal" (do inboxID <- insert Inbox604 @@ -3488,7 +3487,8 @@ changes hLocal ctx = ) "resource" "Resource" - -} + -- 610 + , removeField "PermitTopicExtendResourceLocal" "actor" ] migrateDB diff --git a/src/Vervis/Persist/Collab.hs b/src/Vervis/Persist/Collab.hs index c39501c..237feae 100644 --- a/src/Vervis/Persist/Collab.hs +++ b/src/Vervis/Persist/Collab.hs @@ -1067,7 +1067,7 @@ getGrantActivityBody k = do getPermitsForResource :: MonadIO m => PersonId - -> Either ActorId RemoteActorId + -> Either ResourceId RemoteActorId -> ReaderT SqlBackend m [ ( Either (LocalActorBy Key, OutboxItemId) FedURI , AP.Role @@ -1079,7 +1079,7 @@ getPermitsForResource getPermitsForResource personID actor = do exts <- case actor of - Left actorID -> + Left resourceID -> E.select $ E.from $ \ (permit `E.InnerJoin` gesture `E.InnerJoin` send `E.InnerJoin` extend `E.InnerJoin` resource) -> do E.on $ extend E.^. PermitTopicExtendId E.==. resource E.^. PermitTopicExtendResourceLocalPermit E.on $ send E.^. PermitPersonSendDelegatorId E.==. extend E.^. PermitTopicExtendPermit @@ -1087,7 +1087,7 @@ getPermitsForResource personID actor = do E.on $ permit E.^. PermitId E.==. gesture E.^. PermitPersonGesturePermit E.where_ $ permit E.^. PermitPerson E.==. E.val personID E.&&. - resource E.^. PermitTopicExtendResourceLocalActor E.==. E.val actorID + resource E.^. PermitTopicExtendResourceLocalResource E.==. E.val resourceID return ( permit E.^. PermitId , extend E.^. PermitTopicExtendId diff --git a/src/Vervis/Web/Darcs.hs b/src/Vervis/Web/Darcs.hs index e9a6081..c6fcc40 100644 --- a/src/Vervis/Web/Darcs.hs +++ b/src/Vervis/Web/Darcs.hs @@ -101,7 +101,7 @@ getDarcsRepoSource repository actor repo dir loomIDs = do mp <- maybeAuthId case mp of Nothing -> pure [] - Just personID -> runDB $ getPermitsForResource personID (Left $ repoActor repository) + Just personID -> runDB $ getPermitsForResource personID (Left $ repoResource repository) defaultLayout $ do hashLoom <- getEncodeKeyHashid host <- asksSite siteInstanceHost diff --git a/src/Vervis/Web/Git.hs b/src/Vervis/Web/Git.hs index 5685f7a..6aab254 100644 --- a/src/Vervis/Web/Git.hs +++ b/src/Vervis/Web/Git.hs @@ -116,7 +116,7 @@ getGitRepoSource repository actor repo ref dir loomIDs = do mp <- maybeAuthId case mp of Nothing -> pure [] - Just personID -> runDB $ getPermitsForResource personID (Left $ repoActor repository) + Just personID -> runDB $ getPermitsForResource personID (Left $ repoResource repository) defaultLayout $ do hashLoom <- getEncodeKeyHashid host <- asksSite siteInstanceHost diff --git a/th/models b/th/models index e4780c7..80e7661 100644 --- a/th/models +++ b/th/models @@ -947,8 +947,7 @@ PermitTopicExtendRemote PermitTopicExtendResourceLocal permit PermitTopicExtendId - actor ActorId - --resource ResourceId + resource ResourceId UniquePermitTopicExtendResourceLocal permit