postOutboxR: Use ResultShare for fetching recipient actor
This commit is contained in:
parent
d5eefd1553
commit
25fcceabde
1 changed files with 12 additions and 32 deletions
|
@ -293,38 +293,18 @@ postOutboxR shr = do
|
||||||
where
|
where
|
||||||
fetchInboxURI :: Manager -> Text -> LocalURI -> Handler (Maybe LocalURI)
|
fetchInboxURI :: Manager -> Text -> LocalURI -> Handler (Maybe LocalURI)
|
||||||
fetchInboxURI manager h lto = do
|
fetchInboxURI manager h lto = do
|
||||||
mrs <- runDB $ do
|
iid <- runDB $ either entityKey id <$> insertBy' (Instance h)
|
||||||
mi <- getBy $ UniqueInstance h
|
result <- fetchRemoteActor iid h lto
|
||||||
case mi of
|
case result of
|
||||||
Nothing -> return $ Left Nothing
|
Left err -> do
|
||||||
Just (Entity iid _) ->
|
setMessage $ toHtml $ T.concat
|
||||||
maybe (Left $ Just iid) Right <$>
|
[ "Tried to fetch recipient actor <"
|
||||||
getBy (UniqueRemoteActor iid lto)
|
, renderFedURI $ l2f h lto
|
||||||
case mrs of
|
, "> and got an error: "
|
||||||
Left miid -> do
|
, T.pack (show err)
|
||||||
eres <- fetchAPID manager actorId h lto
|
]
|
||||||
case eres of
|
return Nothing
|
||||||
Left s -> do
|
Right (Entity _ ra) -> return $ Just $ remoteActorInbox ra
|
||||||
setMessage $ toHtml $ T.concat
|
|
||||||
[ "Tried to fetch recipient actor <"
|
|
||||||
, renderFedURI $ l2f h lto
|
|
||||||
, "> and got an error: "
|
|
||||||
, T.pack s
|
|
||||||
]
|
|
||||||
return Nothing
|
|
||||||
Right actor -> withHostLock h $ do
|
|
||||||
let inbox = actorInbox actor
|
|
||||||
runDB $ do
|
|
||||||
(iid, inew) <-
|
|
||||||
case miid of
|
|
||||||
Just iid -> return (iid, False)
|
|
||||||
Nothing -> idAndNew <$> insertBy (Instance h)
|
|
||||||
let rs = RemoteActor lto iid inbox Nothing
|
|
||||||
if inew
|
|
||||||
then insert_ rs
|
|
||||||
else insertUnique_ rs
|
|
||||||
return $ Just inbox
|
|
||||||
Right (Entity _rsid rs) -> return $ Just $ remoteActorInbox rs
|
|
||||||
|
|
||||||
getActorKey :: ((ActorKey, ActorKey, Bool) -> ActorKey) -> Route App -> Handler TypedContent
|
getActorKey :: ((ActorKey, ActorKey, Bool) -> ActorKey) -> Route App -> Handler TypedContent
|
||||||
getActorKey choose route = selectRep $ provideAP $ do
|
getActorKey choose route = selectRep $ provideAP $ do
|
||||||
|
|
Loading…
Reference in a new issue