More insertBy' usage, and remove withHostLock from new outbox post handler
This commit is contained in:
parent
735a6a39cb
commit
c9c7da5902
2 changed files with 14 additions and 26 deletions
|
@ -431,33 +431,21 @@ handleOutboxNote host (Note mluNote luAttrib aud muParent muContext mpublished c
|
||||||
return mid
|
return mid
|
||||||
return (did, Left <$> mmidParent, Just (sid, ticketFollowers t))
|
return (did, Left <$> mmidParent, Just (sid, ticketFollowers t))
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
(rd, rdnew) <- do
|
(rd, rdnew) <- lift $ do
|
||||||
let (hContext, luContext) = f2l uContext
|
let (hContext, luContext) = f2l uContext
|
||||||
miid <- lift $ getKeyBy $ UniqueInstance hContext
|
iid <- either entityKey id <$> insertBy' (Instance hContext)
|
||||||
mrd <-
|
mrd <- getValBy $ UniqueRemoteDiscussionIdent iid luContext
|
||||||
case miid of
|
|
||||||
Just iid -> lift $ getValBy $ UniqueRemoteDiscussionIdent iid luContext
|
|
||||||
Nothing -> return Nothing
|
|
||||||
case mrd of
|
case mrd of
|
||||||
Just rd -> return (rd, False)
|
Just rd -> return (rd, False)
|
||||||
Nothing -> lift $ withHostLock hContext $ do
|
Nothing -> do
|
||||||
(iid, inew) <-
|
did <- insert Discussion
|
||||||
case miid of
|
let rd = RemoteDiscussion iid luContext did
|
||||||
Just i -> return (i, False)
|
erd <- insertBy' rd
|
||||||
Nothing -> idAndNew <$> insertBy (Instance hContext)
|
case erd of
|
||||||
if inew
|
Left (Entity _ rd') -> do
|
||||||
then do
|
delete did
|
||||||
did <- insert Discussion
|
return (rd', False)
|
||||||
rd <- insertRecord $ RemoteDiscussion iid luContext did
|
Right _ -> return (rd, True)
|
||||||
return (rd, True)
|
|
||||||
else do
|
|
||||||
mrd <- getValBy $ UniqueRemoteDiscussionIdent iid luContext
|
|
||||||
case mrd of
|
|
||||||
Just rd -> return (rd, False)
|
|
||||||
Nothing -> do
|
|
||||||
did <- insert Discussion
|
|
||||||
rd <- insertRecord $ RemoteDiscussion iid luContext did
|
|
||||||
return (rd, True)
|
|
||||||
let did = remoteDiscussionDiscuss rd
|
let did = remoteDiscussionDiscuss rd
|
||||||
meparent <- for mparent $ \ parent ->
|
meparent <- for mparent $ \ parent ->
|
||||||
case parent of
|
case parent of
|
||||||
|
|
|
@ -338,7 +338,7 @@ keyListedByActorShared iid vkid host luKey luActor = do
|
||||||
RoomModeInstant -> do
|
RoomModeInstant -> do
|
||||||
when reject $ throwE "Actor key storage limit is 0 and set to reject"
|
when reject $ throwE "Actor key storage limit is 0 and set to reject"
|
||||||
luInbox <- actorInbox <$> ExceptT (keyListedByActor manager host luKey luActor)
|
luInbox <- actorInbox <$> ExceptT (keyListedByActor manager host luKey luActor)
|
||||||
lift $ runDB $ either entityKey id <$> insertBy (RemoteActor luActor iid luInbox Nothing)
|
lift $ runDB $ either entityKey id <$> insertBy' (RemoteActor luActor iid luInbox Nothing)
|
||||||
RoomModeCached m -> do
|
RoomModeCached m -> do
|
||||||
eresult <- do
|
eresult <- do
|
||||||
ments <- lift $ runDB $ do
|
ments <- lift $ runDB $ do
|
||||||
|
@ -361,7 +361,7 @@ keyListedByActorShared iid vkid host luKey luActor = do
|
||||||
vkExists <- isJust <$> get vkid
|
vkExists <- isJust <$> get vkid
|
||||||
case mrsid of
|
case mrsid of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
rsid <- insert $ RemoteActor luActor iid luInbox Nothing
|
rsid <- either entityKey id <$> insertBy' (RemoteActor luActor iid luInbox Nothing)
|
||||||
when vkExists $ insert_ $ VerifKeySharedUsage vkid rsid
|
when vkExists $ insert_ $ VerifKeySharedUsage vkid rsid
|
||||||
return $ Right rsid
|
return $ Right rsid
|
||||||
Just rsid -> runExceptT $ do
|
Just rsid -> runExceptT $ do
|
||||||
|
|
Loading…
Reference in a new issue