diff --git a/src/Vervis/Actor2.hs b/src/Vervis/Actor2.hs index 13a9d88..a5db385 100644 --- a/src/Vervis/Actor2.hs +++ b/src/Vervis/Actor2.hs @@ -1,6 +1,7 @@ {- This file is part of Vervis. - - - Written in 2019, 2020, 2022, 2023 by fr33domlover . + - Written in 2019, 2020, 2022, 2023, 2024 + - by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - @@ -189,6 +190,10 @@ sendActivity -- ^ Activity to send to remote actors -> Act () sendActivity senderByKey senderActorID localRecips remoteRecips fwdHosts itemID action = do + envelope <- do + senderByHash <- hashLocalActor senderByKey + prepareSendH senderActorID senderByHash itemID action + sendByHttp envelope remoteRecips moreRemoteRecips <- do let justSender = Just senderByKey author = (senderByKey, senderActorID, itemID) @@ -207,29 +212,24 @@ sendActivity senderByKey senderActorID localRecips remoteRecips fwdHosts itemID Right o -> return o let body = ActivityBody bodyBL bodyO act sendToLocalActors (Left author) body True justSender justSender localRecips - envelope <- do - senderByHash <- hashLocalActor senderByKey - prepareSendH senderActorID senderByHash itemID action - let (yesFwd, noFwd) = - let remoteRecipsList = - concatMap - (\ ((_, h), rrs) -> NE.toList $ NE.map (decideFwd h . remoteRecipientId) rrs) - moreRemoteRecips - moreList = - concatMap - (\ (h, lus) -> NE.toList $ NE.map (decideFwd h) lus) - remoteRecips - allRemotes = remoteRecipsList ++ moreList - in partitionEithers allRemotes - dt <- asksEnv stageDeliveryTheater - liftIO $ do - sendHttp dt (MethodDeliverLocal envelope True) yesFwd - sendHttp dt (MethodDeliverLocal envelope False) noFwd + sendByHttp envelope $ + map (\ ((_, h), rrs) -> (h, NE.map remoteRecipientId rrs)) + moreRemoteRecips where decideFwd h = if h `elem` fwdHosts then Left . ObjURI h else Right . ObjURI h + sendByHttp envelope recips = do + let recipsDecided = + concatMap + (\ (h, lus) -> NE.toList $ NE.map (decideFwd h) lus) + recips + (yesFwd, noFwd) = partitionEithers recipsDecided + dt <- asksEnv stageDeliveryTheater + liftIO $ do + sendHttp dt (MethodDeliverLocal envelope True) yesFwd + sendHttp dt (MethodDeliverLocal envelope False) noFwd prepareForwardIK :: (Route App, ActorKey)