DB: Permit: Use Resource instead of Actor in extension resource
This commit is contained in:
parent
acdce58fc6
commit
4881154579
11 changed files with 23 additions and 23 deletions
|
@ -900,9 +900,10 @@ personGrant now recipPersonID (Verse authorIdMsig body) grant = do
|
||||||
AP.RXRole r -> pure r
|
AP.RXRole r -> pure r
|
||||||
AP.RXDelegator -> throwE "I've been delegated a Grant with role being delegate"
|
AP.RXDelegator -> throwE "I've been delegated a Grant with role being delegate"
|
||||||
resourceDB <- bitraverse
|
resourceDB <- bitraverse
|
||||||
(\ la ->
|
(\ la -> do
|
||||||
withDBExcept $ localActorID <$>
|
lr <- fromMaybeE (actorToResource la) "Got an extension-Grant with resource being a local Person"
|
||||||
getLocalActorEntityE la "Extension-Grant resource not found in DB"
|
withDBExcept $ localResourceID <$>
|
||||||
|
getLocalResourceEntityE lr "Extension-Grant resource not found in DB"
|
||||||
)
|
)
|
||||||
(\ (ObjURI h lu) -> do
|
(\ (ObjURI h lu) -> do
|
||||||
manager <- asksEnv envHttpManager
|
manager <- asksEnv envHttpManager
|
||||||
|
@ -1057,7 +1058,7 @@ personGrant now recipPersonID (Verse authorIdMsig body) grant = do
|
||||||
return extendID
|
return extendID
|
||||||
_ -> error "personGrant impossible 2"
|
_ -> error "personGrant impossible 2"
|
||||||
lift $ case resourceDB of
|
lift $ case resourceDB of
|
||||||
Left actorID -> insert_ $ PermitTopicExtendResourceLocal extendID actorID
|
Left resourceID -> insert_ $ PermitTopicExtendResourceLocal extendID resourceID
|
||||||
Right actorID -> insert_ $ PermitTopicExtendResourceRemote extendID actorID
|
Right actorID -> insert_ $ PermitTopicExtendResourceRemote extendID actorID
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -495,13 +495,13 @@ fillPermitRecords = do
|
||||||
(_doc, g) <- getGrantActivityBody ext
|
(_doc, g) <- getGrantActivityBody ext
|
||||||
return $ AP.grantContext g
|
return $ AP.grantContext g
|
||||||
result <- runExceptT $ do
|
result <- runExceptT $ do
|
||||||
a <- parseActorURI uResource
|
a <- parseResourceURI uResource
|
||||||
case a of
|
case a of
|
||||||
Left la -> runSiteDBExcept $ do
|
Left lr -> runSiteDBExcept $ do
|
||||||
actorID <-
|
resourceID <-
|
||||||
localActorID <$>
|
localResourceID <$>
|
||||||
getLocalActorEntityE la "Extension-Grant resource not found in DB"
|
getLocalResourceEntityE lr "Extension-Grant resource not found in DB"
|
||||||
lift $ insert_ $ PermitTopicExtendResourceLocal extendID actorID
|
lift $ insert_ $ PermitTopicExtendResourceLocal extendID resourceID
|
||||||
Right (ObjURI h lu) -> do
|
Right (ObjURI h lu) -> do
|
||||||
actorID <- do
|
actorID <- do
|
||||||
manager <- asksSite appHttpManager
|
manager <- asksSite appHttpManager
|
||||||
|
|
|
@ -261,7 +261,7 @@ getDeckTicketsR deckHash = selectRep $ do
|
||||||
mp <- maybeAuthId
|
mp <- maybeAuthId
|
||||||
case mp of
|
case mp of
|
||||||
Nothing -> pure []
|
Nothing -> pure []
|
||||||
Just personID -> runDB $ getPermitsForResource personID (Left $ deckActor deck)
|
Just personID -> runDB $ getPermitsForResource personID (Left $ deckResource deck)
|
||||||
case mpage of
|
case mpage of
|
||||||
Nothing -> redirectFirstPage here
|
Nothing -> redirectFirstPage here
|
||||||
Just (rows, navModel) ->
|
Just (rows, navModel) ->
|
||||||
|
|
|
@ -170,7 +170,7 @@ getGroupR groupHash = do
|
||||||
permits <-
|
permits <-
|
||||||
case mp of
|
case mp of
|
||||||
Nothing -> pure []
|
Nothing -> pure []
|
||||||
Just personID -> getPermitsForResource personID (Left aid)
|
Just personID -> getPermitsForResource personID (Left $ groupResource g)
|
||||||
return (g, a, sigKeys, permits)
|
return (g, a, sigKeys, permits)
|
||||||
|
|
||||||
encodeRouteLocal <- getEncodeRouteLocal
|
encodeRouteLocal <- getEncodeRouteLocal
|
||||||
|
|
|
@ -215,7 +215,7 @@ getLoomClothsR loomHash = selectRep $ do
|
||||||
mp <- maybeAuthId
|
mp <- maybeAuthId
|
||||||
case mp of
|
case mp of
|
||||||
Nothing -> pure []
|
Nothing -> pure []
|
||||||
Just personID -> runDB $ getPermitsForResource personID (Left $ loomActor loom)
|
Just personID -> runDB $ getPermitsForResource personID (Left $ loomResource loom)
|
||||||
case mpage of
|
case mpage of
|
||||||
Nothing -> redirectFirstPage here
|
Nothing -> redirectFirstPage here
|
||||||
Just (rows, navModel) ->
|
Just (rows, navModel) ->
|
||||||
|
|
|
@ -134,7 +134,7 @@ getProjectR projectHash = do
|
||||||
permits <-
|
permits <-
|
||||||
case mp of
|
case mp of
|
||||||
Nothing -> pure []
|
Nothing -> pure []
|
||||||
Just personID -> getPermitsForResource personID (Left aid)
|
Just personID -> getPermitsForResource personID (Left $ projectResource d)
|
||||||
return (d, a, sigKeys, permits)
|
return (d, a, sigKeys, permits)
|
||||||
|
|
||||||
encodeRouteLocal <- getEncodeRouteLocal
|
encodeRouteLocal <- getEncodeRouteLocal
|
||||||
|
|
|
@ -3464,7 +3464,6 @@ changes hLocal ctx =
|
||||||
"resource"
|
"resource"
|
||||||
"Resource"
|
"Resource"
|
||||||
-- 609
|
-- 609
|
||||||
{-
|
|
||||||
, addFieldRefRequired''
|
, addFieldRefRequired''
|
||||||
"PermitTopicExtendResourceLocal"
|
"PermitTopicExtendResourceLocal"
|
||||||
(do inboxID <- insert Inbox604
|
(do inboxID <- insert Inbox604
|
||||||
|
@ -3488,7 +3487,8 @@ changes hLocal ctx =
|
||||||
)
|
)
|
||||||
"resource"
|
"resource"
|
||||||
"Resource"
|
"Resource"
|
||||||
-}
|
-- 610
|
||||||
|
, removeField "PermitTopicExtendResourceLocal" "actor"
|
||||||
]
|
]
|
||||||
|
|
||||||
migrateDB
|
migrateDB
|
||||||
|
|
|
@ -1067,7 +1067,7 @@ getGrantActivityBody k = do
|
||||||
getPermitsForResource
|
getPermitsForResource
|
||||||
:: MonadIO m
|
:: MonadIO m
|
||||||
=> PersonId
|
=> PersonId
|
||||||
-> Either ActorId RemoteActorId
|
-> Either ResourceId RemoteActorId
|
||||||
-> ReaderT SqlBackend m
|
-> ReaderT SqlBackend m
|
||||||
[ ( Either (LocalActorBy Key, OutboxItemId) FedURI
|
[ ( Either (LocalActorBy Key, OutboxItemId) FedURI
|
||||||
, AP.Role
|
, AP.Role
|
||||||
|
@ -1079,7 +1079,7 @@ getPermitsForResource
|
||||||
getPermitsForResource personID actor = do
|
getPermitsForResource personID actor = do
|
||||||
exts <-
|
exts <-
|
||||||
case actor of
|
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.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 $ extend E.^. PermitTopicExtendId E.==. resource E.^. PermitTopicExtendResourceLocalPermit
|
||||||
E.on $ send E.^. PermitPersonSendDelegatorId E.==. extend E.^. PermitTopicExtendPermit
|
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.on $ permit E.^. PermitId E.==. gesture E.^. PermitPersonGesturePermit
|
||||||
E.where_ $
|
E.where_ $
|
||||||
permit E.^. PermitPerson E.==. E.val personID E.&&.
|
permit E.^. PermitPerson E.==. E.val personID E.&&.
|
||||||
resource E.^. PermitTopicExtendResourceLocalActor E.==. E.val actorID
|
resource E.^. PermitTopicExtendResourceLocalResource E.==. E.val resourceID
|
||||||
return
|
return
|
||||||
( permit E.^. PermitId
|
( permit E.^. PermitId
|
||||||
, extend E.^. PermitTopicExtendId
|
, extend E.^. PermitTopicExtendId
|
||||||
|
|
|
@ -101,7 +101,7 @@ getDarcsRepoSource repository actor repo dir loomIDs = do
|
||||||
mp <- maybeAuthId
|
mp <- maybeAuthId
|
||||||
case mp of
|
case mp of
|
||||||
Nothing -> pure []
|
Nothing -> pure []
|
||||||
Just personID -> runDB $ getPermitsForResource personID (Left $ repoActor repository)
|
Just personID -> runDB $ getPermitsForResource personID (Left $ repoResource repository)
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
hashLoom <- getEncodeKeyHashid
|
hashLoom <- getEncodeKeyHashid
|
||||||
host <- asksSite siteInstanceHost
|
host <- asksSite siteInstanceHost
|
||||||
|
|
|
@ -116,7 +116,7 @@ getGitRepoSource repository actor repo ref dir loomIDs = do
|
||||||
mp <- maybeAuthId
|
mp <- maybeAuthId
|
||||||
case mp of
|
case mp of
|
||||||
Nothing -> pure []
|
Nothing -> pure []
|
||||||
Just personID -> runDB $ getPermitsForResource personID (Left $ repoActor repository)
|
Just personID -> runDB $ getPermitsForResource personID (Left $ repoResource repository)
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
hashLoom <- getEncodeKeyHashid
|
hashLoom <- getEncodeKeyHashid
|
||||||
host <- asksSite siteInstanceHost
|
host <- asksSite siteInstanceHost
|
||||||
|
|
|
@ -947,8 +947,7 @@ PermitTopicExtendRemote
|
||||||
|
|
||||||
PermitTopicExtendResourceLocal
|
PermitTopicExtendResourceLocal
|
||||||
permit PermitTopicExtendId
|
permit PermitTopicExtendId
|
||||||
actor ActorId
|
resource ResourceId
|
||||||
--resource ResourceId
|
|
||||||
|
|
||||||
UniquePermitTopicExtendResourceLocal permit
|
UniquePermitTopicExtendResourceLocal permit
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue