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 _) ->
|
|
||||||
maybe (Left $ Just iid) Right <$>
|
|
||||||
getBy (UniqueRemoteActor iid lto)
|
|
||||||
case mrs of
|
|
||||||
Left miid -> do
|
|
||||||
eres <- fetchAPID manager actorId h lto
|
|
||||||
case eres of
|
|
||||||
Left s -> do
|
|
||||||
setMessage $ toHtml $ T.concat
|
setMessage $ toHtml $ T.concat
|
||||||
[ "Tried to fetch recipient actor <"
|
[ "Tried to fetch recipient actor <"
|
||||||
, renderFedURI $ l2f h lto
|
, renderFedURI $ l2f h lto
|
||||||
, "> and got an error: "
|
, "> and got an error: "
|
||||||
, T.pack s
|
, T.pack (show err)
|
||||||
]
|
]
|
||||||
return Nothing
|
return Nothing
|
||||||
Right actor -> withHostLock h $ do
|
Right (Entity _ ra) -> return $ Just $ remoteActorInbox ra
|
||||||
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