1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-29 01:14:51 +09:00

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
-> 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)