From 735a6a39cb35c7c8f39d46f31c8b25cd04353113 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Tue, 16 Apr 2019 17:26:06 +0000 Subject: [PATCH] Use insertBy' in instanceAndActor --- src/Vervis/RemoteActorStore.hs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) 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)