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
|
||||
fetchInboxURI :: Manager -> Text -> LocalURI -> Handler (Maybe LocalURI)
|
||||
fetchInboxURI manager h lto = do
|
||||
mrs <- runDB $ do
|
||||
mi <- getBy $ UniqueInstance h
|
||||
case mi of
|
||||
Nothing -> return $ Left Nothing
|
||||
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
|
||||
iid <- runDB $ either entityKey id <$> insertBy' (Instance h)
|
||||
result <- fetchRemoteActor iid h lto
|
||||
case result of
|
||||
Left err -> do
|
||||
setMessage $ toHtml $ T.concat
|
||||
[ "Tried to fetch recipient actor <"
|
||||
, renderFedURI $ l2f h lto
|
||||
, "> and got an error: "
|
||||
, T.pack s
|
||||
, T.pack (show err)
|
||||
]
|
||||
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
|
||||
Right (Entity _ ra) -> return $ Just $ remoteActorInbox ra
|
||||
|
||||
getActorKey :: ((ActorKey, ActorKey, Bool) -> ActorKey) -> Route App -> Handler TypedContent
|
||||
getActorKey choose route = selectRep $ provideAP $ do
|
||||
|
|
Loading…
Reference in a new issue