diff --git a/src/Vervis/Federation/Ticket.hs b/src/Vervis/Federation/Ticket.hs index 3fb9711..24ec549 100644 --- a/src/Vervis/Federation/Ticket.hs +++ b/src/Vervis/Federation/Ticket.hs @@ -179,10 +179,9 @@ projectOfferTicketF findRelevantCollections hLocal $ activityAudience $ actbActivity body mremotesHttp <- runDBExcept $ do - (sid, jid, ibid, fsid, next, tids) <- - getProjectAndDeps deps + (sid, jid, ibid, fsid, tids) <- getProjectAndDeps deps lift $ join <$> do - mractid <- insertTicket jid ibid next tids + mractid <- insertTicket jid ibid tids for mractid $ \ ractid -> for msig $ \ sig -> do remoteRecips <- deliverLocal ractid colls sid fsid (sig,) <$> deliverRemoteDB (actbBL body) ractid jid sig remoteRecips @@ -234,11 +233,8 @@ projectOfferTicketF tids <- for deps $ \ dep -> do mtid <- lift $ getKeyBy $ UniqueTicket jid dep fromMaybeE mtid "Local dep: No such ticket number in DB" - return - ( sid, jid, projectInbox j, projectFollowers j, projectNextTicket j - , tids - ) - insertTicket jid ibid next deps = do + return (sid, jid, projectInbox j, projectFollowers j, tids) + insertTicket jid ibid deps = do let iidAuthor = remoteAuthorInstance author raidAuthor = remoteAuthorId author ractid <- either entityKey id <$> insertBy' RemoteActivity @@ -254,7 +250,9 @@ projectOfferTicketF delete ibiid return Nothing Just _ibirid -> do - update jid [ProjectNextTicket +=. 1] + next <- + ((subtract 1) . projectNextTicket) <$> + updateGet jid [ProjectNextTicket +=. 1] did <- insert Discussion fsid <- insert FollowerSet tid <- insert Ticket