diff --git a/src/Vervis/RemoteActorStore.hs b/src/Vervis/RemoteActorStore.hs index 4dd0d66..60698b4 100644 --- a/src/Vervis/RemoteActorStore.hs +++ b/src/Vervis/RemoteActorStore.hs @@ -138,15 +138,20 @@ instanceAndActor -> LocalURI -> YesodDB site (InstanceId, RemoteActorId, Maybe Bool) instanceAndActor host luActor luInbox = do - (iid, inew) <- idAndNew <$> insertBy (Instance host) - let rs = RemoteActor luActor iid luInbox Nothing - if inew - then do - rsid <- insert rs - return (iid, rsid, Nothing) - else do - (rsid, rsnew) <- idAndNew <$> insertBy rs - return (iid, rsid, Just rsnew) + (iid, inew) <- idAndNew <$> insertBy' (Instance host) + (raid, ranew) <- + idAndNew <$> insertBy' (RemoteActor luActor iid luInbox Nothing) + return $ + ( iid + , raid + , if inew + then if ranew + then Nothing + else Just False + else if ranew + then Just True + else Just False + ) actorRoom :: ( PersistQueryRead (YesodPersistBackend site)