Use insertBy' in instanceAndActor

This commit is contained in:
fr33domlover 2019-04-16 17:26:06 +00:00
parent c2ee6a7f16
commit 735a6a39cb

View file

@ -138,15 +138,20 @@ instanceAndActor
-> LocalURI -> LocalURI
-> YesodDB site (InstanceId, RemoteActorId, Maybe Bool) -> YesodDB site (InstanceId, RemoteActorId, Maybe Bool)
instanceAndActor host luActor luInbox = do instanceAndActor host luActor luInbox = do
(iid, inew) <- idAndNew <$> insertBy (Instance host) (iid, inew) <- idAndNew <$> insertBy' (Instance host)
let rs = RemoteActor luActor iid luInbox Nothing (raid, ranew) <-
if inew idAndNew <$> insertBy' (RemoteActor luActor iid luInbox Nothing)
then do return $
rsid <- insert rs ( iid
return (iid, rsid, Nothing) , raid
else do , if inew
(rsid, rsnew) <- idAndNew <$> insertBy rs then if ranew
return (iid, rsid, Just rsnew) then Nothing
else Just False
else if ranew
then Just True
else Just False
)
actorRoom actorRoom
:: ( PersistQueryRead (YesodPersistBackend site) :: ( PersistQueryRead (YesodPersistBackend site)